@ai-setting/roy-agent-core 1.4.12 → 1.4.13

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 (57) hide show
  1. package/dist/index.d.ts +7825 -0
  2. package/dist/index.js +13073 -19300
  3. package/dist/shared/chunk-0q6s9wm6.js +249 -0
  4. package/dist/shared/chunk-1aakcfp1.js +15 -0
  5. package/dist/shared/chunk-1d4rwms4.js +25 -0
  6. package/dist/shared/chunk-1pf5mfgd.js +82 -0
  7. package/dist/shared/chunk-1qwabsm0.js +154 -0
  8. package/dist/shared/chunk-25x2pdtp.js +107 -0
  9. package/dist/shared/chunk-2b5kbhx3.js +366 -0
  10. package/dist/shared/chunk-91bas8w5.js +20 -0
  11. package/dist/shared/chunk-9qzt1v1p.js +10 -0
  12. package/dist/shared/chunk-a9qmy3sc.js +296 -0
  13. package/dist/shared/chunk-g6j5n3gv.js +549 -0
  14. package/dist/shared/chunk-hs7tbmje.js +24 -0
  15. package/dist/shared/chunk-mf5xqbdh.js +14 -0
  16. package/dist/shared/chunk-q9j99fsm.js +368 -0
  17. package/dist/{env/workflow/engine/index.js → shared/chunk-rncy3rtd.js} +330 -1581
  18. package/dist/shared/chunk-t1rh6jtm.js +205 -0
  19. package/dist/{env/task/hooks/index.js → shared/chunk-wbkh7wat.js} +3 -18
  20. package/dist/shared/chunk-yqmx37vm.js +10 -0
  21. package/dist/shared/chunk-ze20rksg.js +102 -0
  22. package/package.json +7 -7
  23. package/dist/config/index.js +0 -1670
  24. package/dist/env/agent/index.js +0 -3035
  25. package/dist/env/commands/index.js +0 -1685
  26. package/dist/env/debug/formatters/index.js +0 -639
  27. package/dist/env/debug/index.js +0 -2300
  28. package/dist/env/hook/index.js +0 -273
  29. package/dist/env/index.js +0 -12591
  30. package/dist/env/llm/index.js +0 -2736
  31. package/dist/env/log-trace/index.js +0 -1779
  32. package/dist/env/mcp/index.js +0 -2173
  33. package/dist/env/mcp/tool/index.js +0 -1149
  34. package/dist/env/memory/built-in/index.js +0 -225
  35. package/dist/env/memory/index.js +0 -2171
  36. package/dist/env/memory/plugin/index.js +0 -1263
  37. package/dist/env/prompt/index.js +0 -2107
  38. package/dist/env/session/index.js +0 -3594
  39. package/dist/env/session/storage/index.js +0 -2049
  40. package/dist/env/skill/index.js +0 -1635
  41. package/dist/env/skill/tool/index.js +0 -114
  42. package/dist/env/task/delegate/index.js +0 -1844
  43. package/dist/env/task/index.js +0 -3578
  44. package/dist/env/task/plugins/index.js +0 -1626
  45. package/dist/env/task/storage/index.js +0 -1464
  46. package/dist/env/task/tools/index.js +0 -344
  47. package/dist/env/task/tools/operation/index.js +0 -270
  48. package/dist/env/tool/built-in/index.js +0 -1151
  49. package/dist/env/tool/index.js +0 -2284
  50. package/dist/env/workflow/decorators/index.js +0 -449
  51. package/dist/env/workflow/index.js +0 -6214
  52. package/dist/env/workflow/nodes/index.js +0 -650
  53. package/dist/env/workflow/service/index.js +0 -262
  54. package/dist/env/workflow/storage/index.js +0 -1236
  55. package/dist/env/workflow/tools/index.js +0 -1081
  56. package/dist/env/workflow/types/index.js +0 -479
  57. package/dist/env/workflow/utils/index.js +0 -1631
@@ -0,0 +1,205 @@
1
+ import {
2
+ exports_search_query_parser,
3
+ init_search_query_parser
4
+ } from "./chunk-ze20rksg.js";
5
+ import {
6
+ getDatabase
7
+ } from "./chunk-1pf5mfgd.js";
8
+ import"./chunk-a9qmy3sc.js";
9
+ import"./chunk-q9j99fsm.js";
10
+ import"./chunk-1qwabsm0.js";
11
+ import {
12
+ __toCommonJS
13
+ } from "./chunk-wbkh7wat.js";
14
+
15
+ // src/env/workflow/storage/workflow-repo.ts
16
+ import { randomUUID } from "crypto";
17
+ function rowToWorkflow(row) {
18
+ const metadata = JSON.parse(row.metadata);
19
+ if (row.task_id !== null) {
20
+ metadata.taskId = row.task_id;
21
+ }
22
+ return {
23
+ id: row.id,
24
+ name: row.name,
25
+ version: row.version,
26
+ description: row.description || undefined,
27
+ definition: JSON.parse(row.definition),
28
+ config: JSON.parse(row.config),
29
+ metadata,
30
+ tags: JSON.parse(row.tags),
31
+ createdAt: new Date(row.created_at),
32
+ updatedAt: new Date(row.updated_at)
33
+ };
34
+ }
35
+
36
+ class WorkflowRepository {
37
+ db;
38
+ constructor(db) {
39
+ this.db = db || getDatabase();
40
+ }
41
+ create(workflow) {
42
+ const id = randomUUID();
43
+ const now = new Date().toISOString();
44
+ const stmt = this.db.prepare(`
45
+ INSERT INTO workflows (id, name, version, description, definition, config, metadata, tags, task_id, created_at, updated_at)
46
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
47
+ `);
48
+ stmt.run(id, workflow.name, workflow.version, workflow.description || null, JSON.stringify(workflow.definition), JSON.stringify(workflow.config), JSON.stringify(workflow.metadata), JSON.stringify(workflow.tags), workflow.metadata?.taskId || null, now, now);
49
+ return {
50
+ ...workflow,
51
+ id,
52
+ createdAt: new Date(now),
53
+ updatedAt: new Date(now)
54
+ };
55
+ }
56
+ createFromDefinition(definition, options) {
57
+ const workflow = {
58
+ name: definition.name,
59
+ version: definition.version,
60
+ description: definition.description,
61
+ definition,
62
+ config: options?.config || definition.config || {},
63
+ metadata: options?.metadata || definition.metadata || {},
64
+ tags: options?.tags || definition.metadata?.tags || []
65
+ };
66
+ return this.create(workflow);
67
+ }
68
+ getById(id) {
69
+ const row = this.db.prepare("SELECT * FROM workflows WHERE id = ?").get(id);
70
+ if (!row)
71
+ return;
72
+ return rowToWorkflow(row);
73
+ }
74
+ getByName(name) {
75
+ const row = this.db.prepare("SELECT * FROM workflows WHERE name = ? ORDER BY updated_at DESC LIMIT 1").get(name);
76
+ if (!row)
77
+ return;
78
+ return rowToWorkflow(row);
79
+ }
80
+ getByNameAndVersion(name, version) {
81
+ const row = this.db.prepare("SELECT * FROM workflows WHERE name = ? AND version = ?").get(name, version);
82
+ if (!row)
83
+ return;
84
+ return rowToWorkflow(row);
85
+ }
86
+ list(options) {
87
+ let sql = "SELECT * FROM workflows";
88
+ const params = [];
89
+ const conditions = [];
90
+ if (options?.tag) {
91
+ conditions.push("tags LIKE ?");
92
+ params.push(`%${options.tag}%`);
93
+ }
94
+ if (options?.taskId !== undefined) {
95
+ conditions.push("task_id = ?");
96
+ params.push(options.taskId);
97
+ }
98
+ if (conditions.length > 0) {
99
+ sql += " WHERE " + conditions.join(" AND ");
100
+ }
101
+ const orderBy = options?.orderBy || "updated_at";
102
+ const order = options?.order || "desc";
103
+ sql += ` ORDER BY ${orderBy} ${order.toUpperCase()}`;
104
+ if (options?.limit !== undefined) {
105
+ sql += " LIMIT ?";
106
+ params.push(options.limit);
107
+ }
108
+ if (options?.offset !== undefined) {
109
+ sql += " OFFSET ?";
110
+ params.push(options.offset);
111
+ }
112
+ const rows = this.db.prepare(sql).all(...params);
113
+ let workflows = rows.map(rowToWorkflow);
114
+ if (options?.search) {
115
+ const { parseSearchQuery, matchesQuery } = (init_search_query_parser(), __toCommonJS(exports_search_query_parser));
116
+ const query = parseSearchQuery(options.search);
117
+ workflows = workflows.filter((w) => {
118
+ const descMatch = w.description ? matchesQuery(w.description, query) : false;
119
+ const tagsMatch = w.tags.some((tag) => matchesQuery(tag, query));
120
+ return descMatch || tagsMatch;
121
+ });
122
+ }
123
+ return workflows;
124
+ }
125
+ listVersions(name) {
126
+ const rows = this.db.prepare("SELECT * FROM workflows WHERE name = ? ORDER BY version DESC").all(name);
127
+ return rows.map(rowToWorkflow);
128
+ }
129
+ update(id, updates) {
130
+ const existing = this.getById(id);
131
+ if (!existing)
132
+ return;
133
+ const now = new Date().toISOString();
134
+ const setClauses = ["updated_at = ?"];
135
+ const params = [now];
136
+ if (updates.name !== undefined) {
137
+ setClauses.push("name = ?");
138
+ params.push(updates.name);
139
+ }
140
+ if (updates.version !== undefined) {
141
+ setClauses.push("version = ?");
142
+ params.push(updates.version);
143
+ }
144
+ if (updates.description !== undefined) {
145
+ setClauses.push("description = ?");
146
+ params.push(updates.description);
147
+ }
148
+ if (updates.definition !== undefined) {
149
+ setClauses.push("definition = ?");
150
+ params.push(JSON.stringify(updates.definition));
151
+ }
152
+ if (updates.config !== undefined) {
153
+ setClauses.push("config = ?");
154
+ params.push(JSON.stringify(updates.config));
155
+ }
156
+ if (updates.metadata !== undefined) {
157
+ setClauses.push("metadata = ?");
158
+ params.push(JSON.stringify(updates.metadata));
159
+ if (updates.metadata.taskId !== undefined) {
160
+ setClauses.push("task_id = ?");
161
+ params.push(updates.metadata.taskId);
162
+ }
163
+ }
164
+ if (updates.tags !== undefined) {
165
+ setClauses.push("tags = ?");
166
+ params.push(JSON.stringify(updates.tags));
167
+ }
168
+ params.push(id);
169
+ this.db.prepare(`UPDATE workflows SET ${setClauses.join(", ")} WHERE id = ?`).run(...params);
170
+ return this.getById(id);
171
+ }
172
+ delete(id) {
173
+ const existing = this.getById(id);
174
+ if (!existing)
175
+ return false;
176
+ this.db.prepare("DELETE FROM workflows WHERE id = ?").run(id);
177
+ return true;
178
+ }
179
+ exists(id) {
180
+ const result = this.db.prepare("SELECT 1 FROM workflows WHERE id = ?").get(id);
181
+ return result !== undefined;
182
+ }
183
+ existsByNameAndVersion(name, version) {
184
+ const result = this.db.prepare("SELECT 1 FROM workflows WHERE name = ? AND version = ?").get(name, version);
185
+ return result !== undefined;
186
+ }
187
+ count() {
188
+ const result = this.db.prepare("SELECT COUNT(*) as count FROM workflows").get();
189
+ return result.count;
190
+ }
191
+ search(query, limit) {
192
+ let sql = "SELECT * FROM workflows WHERE name LIKE ? ORDER BY updated_at DESC";
193
+ const params = [`%${query}%`];
194
+ if (limit !== undefined) {
195
+ sql += " LIMIT ?";
196
+ params.push(limit);
197
+ }
198
+ const rows = this.db.prepare(sql).all(...params);
199
+ return rows.map(rowToWorkflow);
200
+ }
201
+ }
202
+ export {
203
+ rowToWorkflow,
204
+ WorkflowRepository
205
+ };
@@ -1,4 +1,4 @@
1
- // @bun
1
+ import { createRequire } from "node:module";
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -47,21 +47,6 @@ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
47
47
  return c > 3 && r && Object.defineProperty(target, key, r), r;
48
48
  };
49
49
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
50
- var __require = import.meta.require;
50
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
51
51
 
52
- // packages/core/src/env/task/hooks/task-hook-points.ts
53
- var TaskHookPoints = {
54
- BEFORE_CREATE: "task:before.create",
55
- AFTER_CREATE: "task:after.create",
56
- BEFORE_UPDATE: "task:before.update",
57
- AFTER_UPDATE: "task:after.update",
58
- BEFORE_DELETE: "task:before.delete",
59
- AFTER_DELETE: "task:after.delete",
60
- DELEGATE_BEFORE: "task:delegate:before",
61
- DELEGATE_AFTER: "task:delegate:after",
62
- OPERATION_BEFORE_CREATE: "task:operation:before.create",
63
- OPERATION_AFTER_CREATE: "task:operation:after.create"
64
- };
65
- export {
66
- TaskHookPoints
67
- };
52
+ export { __toCommonJS, __export, __legacyDecorateClassTS, __esm, __require };
@@ -0,0 +1,10 @@
1
+ import {
2
+ SQLiteSpanStorage,
3
+ init_span_storage
4
+ } from "./chunk-1qwabsm0.js";
5
+ import"./chunk-wbkh7wat.js";
6
+ init_span_storage();
7
+
8
+ export {
9
+ SQLiteSpanStorage
10
+ };
@@ -0,0 +1,102 @@
1
+ import {
2
+ __esm,
3
+ __export
4
+ } from "./chunk-wbkh7wat.js";
5
+
6
+ // src/env/session/search-query-parser.ts
7
+ var exports_search_query_parser = {};
8
+ __export(exports_search_query_parser, {
9
+ parseSearchQuery: () => parseSearchQuery,
10
+ matchesQuery: () => matchesQuery
11
+ });
12
+ function parseSearchQuery(query) {
13
+ const result = {
14
+ required: [],
15
+ excluded: [],
16
+ phrases: []
17
+ };
18
+ if (!query || !query.trim()) {
19
+ return result;
20
+ }
21
+ const phraseRegex = /"([^"]+)"/g;
22
+ let match;
23
+ while ((match = phraseRegex.exec(query)) !== null) {
24
+ result.phrases.push(match[1].toLowerCase());
25
+ }
26
+ query = query.replace(phraseRegex, "");
27
+ query = query.replace(/\s+/g, " ").trim();
28
+ if (!query) {
29
+ return result;
30
+ }
31
+ const parts = [];
32
+ let remaining = query;
33
+ const singleOpRegex = /\s+(AND|OR|NOT)\s+/gi;
34
+ let opMatch;
35
+ while ((opMatch = singleOpRegex.exec(remaining)) !== null) {
36
+ const op = opMatch[1].toUpperCase();
37
+ const beforeText = remaining.slice(0, opMatch.index).trim();
38
+ if (beforeText) {
39
+ parts.push({ text: beforeText, operator: undefined });
40
+ }
41
+ parts.push({ text: op, operator: op });
42
+ remaining = remaining.slice(opMatch.index + opMatch[0].length);
43
+ singleOpRegex.lastIndex = 0;
44
+ }
45
+ if (remaining.trim()) {
46
+ parts.push({ text: remaining.trim(), operator: undefined });
47
+ }
48
+ let currentOperator = "AND";
49
+ for (const part of parts) {
50
+ if (part.operator) {
51
+ currentOperator = part.operator;
52
+ } else {
53
+ const wordRegex = /[\w\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff]+/gu;
54
+ const words = part.text.match(wordRegex) || [];
55
+ for (const word of words) {
56
+ const lowerWord = word.toLowerCase();
57
+ if (lowerWord === "and" || lowerWord === "or" || lowerWord === "not") {
58
+ currentOperator = lowerWord.toUpperCase();
59
+ continue;
60
+ }
61
+ if (currentOperator === "NOT") {
62
+ if (!result.excluded.includes(lowerWord)) {
63
+ result.excluded.push(lowerWord);
64
+ }
65
+ } else {
66
+ if (!result.required.includes(lowerWord)) {
67
+ result.required.push(lowerWord);
68
+ }
69
+ }
70
+ currentOperator = "AND";
71
+ }
72
+ }
73
+ }
74
+ return result;
75
+ }
76
+ function matchesQuery(content, query) {
77
+ if (!content) {
78
+ return query.required.length === 0 && query.phrases.length === 0;
79
+ }
80
+ const lowerContent = content.toLowerCase();
81
+ for (const term of query.excluded) {
82
+ if (lowerContent.includes(term.toLowerCase())) {
83
+ return false;
84
+ }
85
+ }
86
+ for (const phrase of query.phrases) {
87
+ if (!lowerContent.includes(phrase)) {
88
+ return false;
89
+ }
90
+ }
91
+ if (query.required.length > 0) {
92
+ for (const term of query.required) {
93
+ if (!lowerContent.includes(term)) {
94
+ return false;
95
+ }
96
+ }
97
+ }
98
+ return true;
99
+ }
100
+ var init_search_query_parser = () => {};
101
+
102
+ export { parseSearchQuery, matchesQuery, exports_search_query_parser, init_search_query_parser };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.4.12",
3
+ "version": "1.4.13",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",
@@ -25,6 +25,11 @@
25
25
  "dist",
26
26
  "README.md"
27
27
  ],
28
+ "scripts": {
29
+ "build": "bun run bunup",
30
+ "clean": "rm -rf dist",
31
+ "typecheck": "npx tsc --noEmit --skipLibCheck --project tsconfig.json"
32
+ },
28
33
  "dependencies": {
29
34
  "@ai-sdk/anthropic": "^3.0.0",
30
35
  "@ai-sdk/google": "^3.0.0",
@@ -70,10 +75,5 @@
70
75
  "license": "MIT",
71
76
  "bugs": {
72
77
  "url": "https://github.com/ai-setting/roy-agent/issues"
73
- },
74
- "scripts": {
75
- "build": "bun run bunup",
76
- "clean": "rm -rf dist",
77
- "typecheck": "npx tsc --noEmit --skipLibCheck --project tsconfig.json"
78
78
  }
79
- }
79
+ }