@ai-setting/roy-agent-core 1.7.37 → 1.7.39
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 +7 -7
- package/dist/env/agent/index.js +10 -10
- package/dist/env/commands/index.js +7 -7
- package/dist/env/context/index.js +7 -3
- package/dist/env/debug/index.js +7 -7
- package/dist/env/event-source/index.js +24 -14
- package/dist/env/hook/index.js +5 -5
- package/dist/env/index.js +33 -32
- package/dist/env/llm/index.js +7 -7
- package/dist/env/log-trace/index.js +7 -7
- package/dist/env/mcp/index.js +7 -7
- package/dist/env/memory/index.js +7 -7
- package/dist/env/plugin/index.js +7 -7
- package/dist/env/prompt/index.js +7 -7
- package/dist/env/session/index.js +7 -7
- package/dist/env/skill/index.js +7 -7
- package/dist/env/task/delegate/index.js +7 -6
- package/dist/env/task/index.js +12 -11
- package/dist/env/task/plugins/index.js +7 -7
- package/dist/env/task/storage/index.js +2 -2
- 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 +8 -8
- package/dist/env/workflow/engine/index.js +9 -9
- package/dist/env/workflow/index.js +17 -17
- 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 -11
- package/dist/env/workflow/utils/index.js +4 -4
- package/dist/index.js +53 -43
- package/dist/shared/@ai-setting/{roy-agent-core-yf0ex8y1.js → roy-agent-core-333apxaa.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-pxyyrxnn.js → roy-agent-core-34je386q.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-q8vew3zh.js → roy-agent-core-3h7ajma5.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-e4v61k3j.js → roy-agent-core-47wrv4ex.js} +94 -32
- package/dist/shared/@ai-setting/{roy-agent-core-9drbkjfr.js → roy-agent-core-4cj6hram.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-fytqnxrd.js → roy-agent-core-4cqcdk7k.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-zda3rfr3.js → roy-agent-core-4kbvfnn1.js} +54 -5
- package/dist/shared/@ai-setting/{roy-agent-core-bb57xjfh.js → roy-agent-core-5exnp10h.js} +11 -8
- package/dist/shared/@ai-setting/{roy-agent-core-jq7g5nxz.js → roy-agent-core-5j4awbgc.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-1vj7dd14.js → roy-agent-core-6mnwqcqf.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wgttzq8e.js → roy-agent-core-6vbgswjw.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-1q6gjxba.js → roy-agent-core-6vwf03cz.js} +10 -7
- package/dist/shared/@ai-setting/{roy-agent-core-a8zf7ts4.js → roy-agent-core-754b0078.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-j9ejsmsj.js → roy-agent-core-8nv07zgr.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-yw07bvqz.js → roy-agent-core-9cqpdrnk.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-q3zvkbj6.js → roy-agent-core-9qn92jhf.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-m7dppx2p.js → roy-agent-core-9t675te0.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-fym6zz5a.js → roy-agent-core-a236mps6.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-qhjm0bxm.js → roy-agent-core-a9pbda78.js} +23 -13
- package/dist/shared/@ai-setting/{roy-agent-core-s53yya0w.js → roy-agent-core-asxe1nt4.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-em8618g6.js → roy-agent-core-cazvr63z.js} +237 -14
- package/dist/shared/@ai-setting/{roy-agent-core-ds5f75pg.js → roy-agent-core-ck60j1q9.js} +19 -1
- package/dist/shared/@ai-setting/{roy-agent-core-w457586k.js → roy-agent-core-cw89yj9d.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-462v5d24.js → roy-agent-core-cysnmvcy.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-88tfzaxg.js → roy-agent-core-f18jk3cw.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qz9jb9sp.js → roy-agent-core-hkj5v9xq.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-dzfyjzgw.js → roy-agent-core-jadrj0bz.js} +27 -2
- package/dist/shared/@ai-setting/{roy-agent-core-dfay0w56.js → roy-agent-core-jawzpf5k.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-zekkw27m.js → roy-agent-core-jg8cv1f7.js} +128 -29
- package/dist/shared/@ai-setting/{roy-agent-core-mwaesrpc.js → roy-agent-core-jjw7xcxv.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-2qke91fm.js → roy-agent-core-krppch0s.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-mxwaq8ey.js → roy-agent-core-m3ffkexb.js} +13 -13
- package/dist/shared/@ai-setting/{roy-agent-core-2wbdfrtg.js → roy-agent-core-n1ceexfz.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-1btakphh.js → roy-agent-core-pc8x07p0.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-d5gwqrr5.js → roy-agent-core-pd0exvnq.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-1nvqn17p.js → roy-agent-core-qfktfbrr.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-x4wev4rn.js → roy-agent-core-rczz7e81.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-e3qjt852.js → roy-agent-core-rgpkygbc.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-rx8whb18.js → roy-agent-core-s44egzrh.js} +35 -4
- package/dist/shared/@ai-setting/{roy-agent-core-k5csz66y.js → roy-agent-core-tm57tmds.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qhtejtpc.js → roy-agent-core-vsrfzaze.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-whta3f53.js → roy-agent-core-wn59p0zw.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-mdaew65f.js → roy-agent-core-wybj8emq.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ddq5hcp5.js → roy-agent-core-x6c45yqd.js} +3 -1
- package/dist/shared/@ai-setting/roy-agent-core-xyys5m1a.js +159 -0
- package/dist/shared/@ai-setting/{roy-agent-core-wphva2vs.js → roy-agent-core-y1n63tse.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-jcdsghyr.js → roy-agent-core-yjjqm4ww.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-n3pwkwjh.js → roy-agent-core-za09t5g3.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-n82acszf.js → roy-agent-core-zbb3sk72.js} +17 -3
- package/package.json +1 -1
- /package/dist/shared/@ai-setting/{roy-agent-core-k5hxvaf0.js → roy-agent-core-3ztzc83c.js} +0 -0
|
@@ -2,17 +2,19 @@ import {
|
|
|
2
2
|
BUILT_IN_EVENT_SOURCE_TYPES,
|
|
3
3
|
BUILT_IN_EVENT_SOURCE_TYPE_LIST,
|
|
4
4
|
EventSourceInitHooks,
|
|
5
|
+
defaultLarkCliRunner,
|
|
5
6
|
getDefaultConfigForType,
|
|
6
7
|
isBuiltInEventSourceType,
|
|
7
8
|
isValidEventSourceType,
|
|
8
9
|
validateEventSourceConfig
|
|
9
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-ck60j1q9.js";
|
|
10
11
|
import"./roy-agent-core-fs0mn2jk.js";
|
|
11
12
|
export {
|
|
12
13
|
validateEventSourceConfig,
|
|
13
14
|
isValidEventSourceType,
|
|
14
15
|
isBuiltInEventSourceType,
|
|
15
16
|
getDefaultConfigForType,
|
|
17
|
+
defaultLarkCliRunner,
|
|
16
18
|
EventSourceInitHooks,
|
|
17
19
|
BUILT_IN_EVENT_SOURCE_TYPE_LIST,
|
|
18
20
|
BUILT_IN_EVENT_SOURCE_TYPES
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TracedAs,
|
|
3
|
+
init_decorator
|
|
4
|
+
} from "./roy-agent-core-a9pbda78.js";
|
|
5
|
+
import {
|
|
6
|
+
__legacyDecorateClassTS,
|
|
7
|
+
__require
|
|
8
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
9
|
+
|
|
10
|
+
// src/env/event-source/event-store.ts
|
|
11
|
+
init_decorator();
|
|
12
|
+
import { randomUUID } from "node:crypto";
|
|
13
|
+
function getDatabaseClass() {
|
|
14
|
+
if (typeof Bun !== "undefined") {
|
|
15
|
+
const { Database } = __require("bun:sqlite");
|
|
16
|
+
return Database;
|
|
17
|
+
} else {
|
|
18
|
+
return __require("better-sqlite3");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function createCompatibleDatabase(path) {
|
|
22
|
+
const Database = getDatabaseClass();
|
|
23
|
+
const db = new Database(path);
|
|
24
|
+
if (typeof db.run !== "function") {
|
|
25
|
+
db.run = function(sql, ...params) {
|
|
26
|
+
if (params.length > 0) {
|
|
27
|
+
return this.prepare(sql).run(...params);
|
|
28
|
+
} else {
|
|
29
|
+
return this.exec(sql);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return db;
|
|
34
|
+
}
|
|
35
|
+
class EventStoreImpl {
|
|
36
|
+
db;
|
|
37
|
+
insertStmt;
|
|
38
|
+
getByIdStmt;
|
|
39
|
+
recentStmt;
|
|
40
|
+
constructor(options) {
|
|
41
|
+
this.db = createCompatibleDatabase(options.dbPath);
|
|
42
|
+
try {
|
|
43
|
+
this.db.exec("PRAGMA journal_mode=WAL");
|
|
44
|
+
this.db.exec("PRAGMA synchronous=NORMAL");
|
|
45
|
+
this.db.exec("PRAGMA busy_timeout=5000");
|
|
46
|
+
} catch {}
|
|
47
|
+
this.db.exec(`CREATE TABLE IF NOT EXISTS event_store (
|
|
48
|
+
event_id TEXT PRIMARY KEY,
|
|
49
|
+
es_type TEXT NOT NULL,
|
|
50
|
+
sender_id TEXT NOT NULL,
|
|
51
|
+
text TEXT,
|
|
52
|
+
metadata TEXT NOT NULL,
|
|
53
|
+
raw_event TEXT,
|
|
54
|
+
created_at INTEGER NOT NULL
|
|
55
|
+
);`);
|
|
56
|
+
this.db.exec(`CREATE INDEX IF NOT EXISTS idx_es_sender_time
|
|
57
|
+
ON event_store (es_type, sender_id, created_at DESC);`);
|
|
58
|
+
this.insertStmt = this.db.prepare(`INSERT INTO event_store (event_id, es_type, sender_id, text, metadata, raw_event, created_at)
|
|
59
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)`);
|
|
60
|
+
this.getByIdStmt = this.db.prepare(`SELECT event_id, es_type, sender_id, text, metadata, raw_event, created_at
|
|
61
|
+
FROM event_store WHERE event_id = ?`);
|
|
62
|
+
this.recentStmt = this.db.prepare(`SELECT event_id, es_type, sender_id, text, metadata, raw_event, created_at
|
|
63
|
+
FROM event_store
|
|
64
|
+
WHERE es_type = ? AND sender_id = ?
|
|
65
|
+
ORDER BY created_at DESC
|
|
66
|
+
LIMIT ?`);
|
|
67
|
+
}
|
|
68
|
+
async insertTriggerEvent(input, esType) {
|
|
69
|
+
const eventId = `evt_${Date.now()}_${randomUUID()}`;
|
|
70
|
+
const createdAt = Date.now();
|
|
71
|
+
const metadataJson = JSON.stringify(input.metadata ?? {});
|
|
72
|
+
const rawEventJson = input.rawEvent === undefined ? null : safeStringify(input.rawEvent);
|
|
73
|
+
this.insertStmt.run(eventId, esType, input.senderId, input.text ?? null, metadataJson, rawEventJson, createdAt);
|
|
74
|
+
return eventId;
|
|
75
|
+
}
|
|
76
|
+
async getEventById(eventId) {
|
|
77
|
+
const row = this.getByIdStmt.get(eventId);
|
|
78
|
+
if (!row)
|
|
79
|
+
return null;
|
|
80
|
+
return rowToPersistedEvent(row);
|
|
81
|
+
}
|
|
82
|
+
async getRecentEvents(esType, senderId, limit) {
|
|
83
|
+
const rows = this.recentStmt.all(esType, senderId, limit);
|
|
84
|
+
return rows.map((r) => rowToPersistedEvent(r));
|
|
85
|
+
}
|
|
86
|
+
close() {
|
|
87
|
+
this.db.close();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
__legacyDecorateClassTS([
|
|
91
|
+
TracedAs("event_store.insert_trigger", { recordParams: true, recordResult: true })
|
|
92
|
+
], EventStoreImpl.prototype, "insertTriggerEvent", null);
|
|
93
|
+
__legacyDecorateClassTS([
|
|
94
|
+
TracedAs("event_store.query_by_id", { recordParams: true, recordResult: false })
|
|
95
|
+
], EventStoreImpl.prototype, "getEventById", null);
|
|
96
|
+
function rowToPersistedEvent(row) {
|
|
97
|
+
let metadata;
|
|
98
|
+
try {
|
|
99
|
+
metadata = row.metadata ? JSON.parse(row.metadata) : {};
|
|
100
|
+
} catch {
|
|
101
|
+
metadata = {};
|
|
102
|
+
}
|
|
103
|
+
let rawEvent;
|
|
104
|
+
if (row.raw_event) {
|
|
105
|
+
try {
|
|
106
|
+
rawEvent = JSON.parse(row.raw_event);
|
|
107
|
+
} catch {
|
|
108
|
+
rawEvent = null;
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
rawEvent = null;
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
eventId: row.event_id,
|
|
115
|
+
esType: row.es_type,
|
|
116
|
+
senderId: row.sender_id,
|
|
117
|
+
text: row.text ?? null,
|
|
118
|
+
metadata,
|
|
119
|
+
rawEvent,
|
|
120
|
+
createdAt: typeof row.created_at === "bigint" ? Number(row.created_at) : row.created_at
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function safeStringify(obj) {
|
|
124
|
+
const seen = new WeakSet;
|
|
125
|
+
try {
|
|
126
|
+
return JSON.stringify(obj, (_key, value) => {
|
|
127
|
+
if (typeof value === "function")
|
|
128
|
+
return "[Function]";
|
|
129
|
+
if (value === undefined)
|
|
130
|
+
return "[undefined]";
|
|
131
|
+
if (value === null)
|
|
132
|
+
return null;
|
|
133
|
+
if (value instanceof Error)
|
|
134
|
+
return `${value.name}: ${value.message}`;
|
|
135
|
+
if (typeof value === "object") {
|
|
136
|
+
if (seen.has(value))
|
|
137
|
+
return "[Circular]";
|
|
138
|
+
seen.add(value);
|
|
139
|
+
}
|
|
140
|
+
if (typeof value === "bigint")
|
|
141
|
+
return value.toString();
|
|
142
|
+
return value;
|
|
143
|
+
});
|
|
144
|
+
} catch {
|
|
145
|
+
return "{}";
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
var sharedEventStore = null;
|
|
149
|
+
function setSharedEventStore(store) {
|
|
150
|
+
sharedEventStore = store;
|
|
151
|
+
}
|
|
152
|
+
function getSharedEventStore() {
|
|
153
|
+
return sharedEventStore;
|
|
154
|
+
}
|
|
155
|
+
function resetSharedEventStore() {
|
|
156
|
+
sharedEventStore = null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { EventStoreImpl, setSharedEventStore, getSharedEventStore, resetSharedEventStore };
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
hasDecoratorNodes,
|
|
4
4
|
init_node_registry_helper,
|
|
5
5
|
registerDecoratorNodeType
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-hkj5v9xq.js";
|
|
7
7
|
import"./roy-agent-core-1ce3fqrk.js";
|
|
8
8
|
import"./roy-agent-core-ddwa0n6h.js";
|
|
9
|
-
import"./roy-agent-core-
|
|
9
|
+
import"./roy-agent-core-a9pbda78.js";
|
|
10
10
|
import"./roy-agent-core-8seq65bp.js";
|
|
11
11
|
import"./roy-agent-core-jnszp0jq.js";
|
|
12
12
|
import"./roy-agent-core-fs0mn2jk.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init_decorator,
|
|
3
3
|
wrapFunction
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-a9pbda78.js";
|
|
5
5
|
import {
|
|
6
6
|
createLogger,
|
|
7
7
|
init_logger
|
|
@@ -111,6 +111,9 @@ async function runWithEnvContextAsync(context, fn) {
|
|
|
111
111
|
}
|
|
112
112
|
return fn();
|
|
113
113
|
}
|
|
114
|
+
function normalizeParentTaskId(value) {
|
|
115
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : undefined;
|
|
116
|
+
}
|
|
114
117
|
function createEnvContext(options) {
|
|
115
118
|
let replyChannel = options.replyChannel;
|
|
116
119
|
if (replyChannel && options.messageId && !replyChannel.messageId) {
|
|
@@ -184,13 +187,24 @@ function getEventFromEnvContext(ctx) {
|
|
|
184
187
|
}
|
|
185
188
|
return;
|
|
186
189
|
}
|
|
187
|
-
var logger, envContextStorage, setCurrentTaskId;
|
|
190
|
+
var logger, envContextStorage, resolveEnvParentTaskId, setCurrentTaskId;
|
|
188
191
|
var init_env_context = __esm(() => {
|
|
189
192
|
init_logger();
|
|
190
193
|
init_decorator();
|
|
191
194
|
init_env_event();
|
|
192
195
|
logger = createLogger("env:context:env-context");
|
|
193
196
|
envContextStorage = new AsyncLocalStorage;
|
|
197
|
+
resolveEnvParentTaskId = wrapFunction(function _resolveEnvParentTaskId(envEvent, parentEnvContext) {
|
|
198
|
+
const fromEvent = normalizeParentTaskId(envEvent?.metadata?.parentTaskId);
|
|
199
|
+
return fromEvent ?? normalizeParentTaskId(parentEnvContext?.parentTaskId);
|
|
200
|
+
}, "env-context.resolveEnvParentTaskId", {
|
|
201
|
+
recordParams: false,
|
|
202
|
+
recordResult: false,
|
|
203
|
+
log: false,
|
|
204
|
+
resultFilter: (parentTaskId) => ({
|
|
205
|
+
parentTaskId: parentTaskId ?? null
|
|
206
|
+
})
|
|
207
|
+
});
|
|
194
208
|
setCurrentTaskId = wrapFunction(function _setCurrentTaskId(taskId) {
|
|
195
209
|
const prev = getCurrentTaskId();
|
|
196
210
|
const ctx = envContextStorage.getStore();
|
|
@@ -204,4 +218,4 @@ var init_env_context = __esm(() => {
|
|
|
204
218
|
}, "env-context.setCurrentTaskId", { recordParams: true, recordResult: false, log: true });
|
|
205
219
|
});
|
|
206
220
|
|
|
207
|
-
export { isLarkEvent, isGithubEvent, isJiraEvent, getLarkMessageId, getLarkChatId, getLarkUserId, EVENT_ENV_PREFIX, serializeEventToEnv, restoreEventFromEnv, init_env_event, envContextStorage, getEnvContext, getEnvContextOrEmpty, hasEnvContext, getCurrentTaskId, runWithEnvContext, runWithEnvContextAsync, createEnvContext, mergeEnvContext, setCurrentTaskId, getEventFromEnvContext, init_env_context };
|
|
221
|
+
export { isLarkEvent, isGithubEvent, isJiraEvent, getLarkMessageId, getLarkChatId, getLarkUserId, EVENT_ENV_PREFIX, serializeEventToEnv, restoreEventFromEnv, init_env_event, envContextStorage, getEnvContext, getEnvContextOrEmpty, hasEnvContext, getCurrentTaskId, runWithEnvContext, runWithEnvContextAsync, normalizeParentTaskId, resolveEnvParentTaskId, createEnvContext, mergeEnvContext, setCurrentTaskId, getEventFromEnvContext, init_env_context };
|
package/package.json
CHANGED
|
File without changes
|