@ai-setting/roy-agent-core 1.7.76 → 1.7.77

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 (36) hide show
  1. package/dist/env/agent/agent-component.js +2 -2
  2. package/dist/env/agent/index.js +2 -2
  3. package/dist/env/event-source/event-source-handlers.js +6 -6
  4. package/dist/env/event-source/index.js +7 -7
  5. package/dist/env/index.js +11 -11
  6. package/dist/env/task/backend/index.js +37 -1
  7. package/dist/env/task/backend/task-store-backend.d.ts +12 -0
  8. package/dist/env/task/backend/types.d.ts +19 -0
  9. package/dist/env/task/index.js +3 -3
  10. package/dist/env/task/mcp/index.js +3 -0
  11. package/dist/env/task/mcp/task-mcp-server.d.ts +1 -1
  12. package/dist/env/task/plugins/fake-user-message-helper.d.ts +10 -2
  13. package/dist/env/task/plugins/index.d.ts +1 -0
  14. package/dist/env/task/plugins/index.js +15 -4
  15. package/dist/env/task/plugins/lark-card-patch-notifier.js +1 -1
  16. package/dist/env/task/plugins/task-op-watermark-plugin.d.ts +112 -0
  17. package/dist/env/task/storage/index.js +2 -2
  18. package/dist/env/task/storage/sqlite-task-store.d.ts +54 -0
  19. package/dist/env/task/task-component.d.ts +16 -0
  20. package/dist/env/task/tools/operation/operation-types.d.ts +13 -13
  21. package/dist/env/workflow/plugins/index.js +2 -2
  22. package/dist/env/workflow/types/event.d.ts +4 -4
  23. package/dist/index.js +11 -11
  24. package/dist/shared/@ai-setting/{roy-agent-core-cxy143m4.js → roy-agent-core-0v27y99n.js} +1 -1
  25. package/dist/shared/@ai-setting/{roy-agent-core-t3rrb959.js → roy-agent-core-3gpygqcx.js} +3 -3
  26. package/dist/shared/@ai-setting/{roy-agent-core-q5r75vev.js → roy-agent-core-9vhq7fvv.js} +5 -1
  27. package/dist/shared/@ai-setting/{roy-agent-core-zycadbpx.js → roy-agent-core-ew6qb5yx.js} +1 -1
  28. package/dist/shared/@ai-setting/{roy-agent-core-abqhkbn3.js → roy-agent-core-ezvpreqz.js} +23 -0
  29. package/dist/shared/@ai-setting/roy-agent-core-h21gngxf.js +247 -0
  30. package/dist/shared/@ai-setting/{roy-agent-core-p3zv1mx5.js → roy-agent-core-hd3n57zs.js} +1 -1
  31. package/dist/shared/@ai-setting/{roy-agent-core-ntq0gz7q.js → roy-agent-core-q813vafd.js} +1 -1
  32. package/dist/shared/@ai-setting/{roy-agent-core-z43aj03k.js → roy-agent-core-rhtdspx6.js} +20 -1
  33. package/dist/shared/@ai-setting/{roy-agent-core-ghnagzrh.js → roy-agent-core-rsn44n9y.js} +3 -3
  34. package/dist/shared/@ai-setting/{roy-agent-core-nmx9934r.js → roy-agent-core-w0qjeq2v.js} +1 -1
  35. package/package.json +1 -1
  36. package/dist/shared/@ai-setting/roy-agent-core-f77k3gqt.js +0 -71
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  LarkCardPatchNotifier,
3
3
  formatDurationMs
4
- } from "./roy-agent-core-nmx9934r.js";
4
+ } from "./roy-agent-core-w0qjeq2v.js";
5
5
  import {
6
6
  WorkflowHookPoints,
7
7
  init_workflow_hook_points
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  init_sqlite_task_store
3
- } from "./roy-agent-core-abqhkbn3.js";
3
+ } from "./roy-agent-core-ezvpreqz.js";
4
4
 
5
5
  // src/env/task/storage/index.ts
6
6
  init_sqlite_task_store();
@@ -37,7 +37,7 @@ import {
37
37
  import {
38
38
  SQLiteTaskStore,
39
39
  getDefaultTaskDbPath
40
- } from "./roy-agent-core-abqhkbn3.js";
40
+ } from "./roy-agent-core-ezvpreqz.js";
41
41
  import {
42
42
  TaskHookPoints
43
43
  } from "./roy-agent-core-1pg0fepg.js";
@@ -471,6 +471,15 @@ class TaskComponent extends BaseComponent {
471
471
  async getTaskIdBySessionId(sessionId) {
472
472
  return this.store.getTaskIdBySessionId(sessionId);
473
473
  }
474
+ async getTaskIdsBySessionId(sessionId) {
475
+ const store = this.store;
476
+ if (typeof store.getTaskIdsBySessionId === "function") {
477
+ const ids = await store.getTaskIdsBySessionId(sessionId);
478
+ return Array.isArray(ids) ? ids : [];
479
+ }
480
+ const first = await this.store.getTaskIdBySessionId(sessionId);
481
+ return typeof first === "number" ? [first] : [];
482
+ }
474
483
  async getTaskWithOperations(id) {
475
484
  const task = await this.store.getTask(id);
476
485
  if (!task)
@@ -676,6 +685,16 @@ class TaskComponent extends BaseComponent {
676
685
  async listOperations(options) {
677
686
  return this.store.listOperations(options);
678
687
  }
688
+ async listOperationsFresh(options) {
689
+ const store = this.store;
690
+ if (typeof store.listOperationsFresh === "function") {
691
+ return await store.listOperationsFresh(options);
692
+ }
693
+ if (typeof store.invalidateOperationsCache === "function") {
694
+ store.invalidateOperationsCache(options.taskId);
695
+ }
696
+ return await this.store.listOperations(options);
697
+ }
679
698
  getTagService() {
680
699
  return this.tagService;
681
700
  }
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  createCompatibleDatabase,
9
9
  init_sqlite_task_store
10
- } from "./roy-agent-core-abqhkbn3.js";
10
+ } from "./roy-agent-core-ezvpreqz.js";
11
11
  import {
12
12
  TaskHookPoints
13
13
  } from "./roy-agent-core-1pg0fepg.js";
@@ -24,13 +24,13 @@ import {
24
24
  import {
25
25
  LarkCardPatchNotifier,
26
26
  humanizeValue
27
- } from "./roy-agent-core-nmx9934r.js";
27
+ } from "./roy-agent-core-w0qjeq2v.js";
28
28
  import {
29
29
  validateWorkflowDefinition
30
30
  } from "./roy-agent-core-1v4g0d4x.js";
31
31
  import {
32
32
  enqueueToAddFakeUserMessage
33
- } from "./roy-agent-core-f77k3gqt.js";
33
+ } from "./roy-agent-core-h21gngxf.js";
34
34
  import {
35
35
  BasePlugin
36
36
  } from "./roy-agent-core-az13yzmc.js";
@@ -60,7 +60,7 @@ function sanitizeInlineText(text, maxLen = 300) {
60
60
  if (!text)
61
61
  return "";
62
62
  const flat = text.replace(/\r\n?/g, `
63
- `).replace(/^#{1,6}\s+/gm, "").replace(/^\s*[-*+]\s+/gm, "· ").replace(/^\s*\d+\.\s+/gm, "· ").replace(/\*\*/g, "").replace(/`/g, "").replace(/\n+/g, " · ").replace(/\s{2,}/g, " ").replace(/(?:\s*·\s*){2,}/g, " · ").replace(/^(\s*·\s*)+/, "").replace(/(\s*·\s*)+$/, "").trim();
63
+ `).replace(/^#{1,6}\s+/gm, "").replace(/!\[([^\]]*)\]\([^)]*\)/g, (_m, alt) => alt.trim() ? `${alt.trim()}[图片]` : "[图片]").replace(/^\s*[-*+]\s+/gm, "· ").replace(/^\s*\d+\.\s+/gm, "· ").replace(/\*\*/g, "").replace(/`/g, "").replace(/\n+/g, " · ").replace(/\s{2,}/g, " ").replace(/(?:\s*·\s*){2,}/g, " · ").replace(/^(\s*·\s*)+/, "").replace(/(\s*·\s*)+$/, "").trim();
64
64
  return flat.length <= maxLen ? flat : `${flat.slice(0, maxLen)}…`;
65
65
  }
66
66
  var HEAD_TITLE_MAX_WIDTH = 40;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.7.76",
3
+ "version": "1.7.77",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",
@@ -1,71 +0,0 @@
1
- import {
2
- init_decorator,
3
- wrapFunction
4
- } from "./roy-agent-core-qq96p0tj.js";
5
-
6
- // src/env/task/plugins/fake-user-message-helper.ts
7
- init_decorator();
8
- var KIND_FIELD = "__fakeUserMessageKind";
9
- function ensureMetadata(toolResult) {
10
- if (!toolResult)
11
- return;
12
- if (!toolResult.result)
13
- toolResult.result = {};
14
- if (!toolResult.result.metadata)
15
- toolResult.result.metadata = {};
16
- return toolResult.result.metadata;
17
- }
18
- function stringContent(msg) {
19
- const c = msg?.content;
20
- return typeof c === "string" ? c : JSON.stringify(c);
21
- }
22
- function enqueueToAddFakeUserMessageImpl(toolResult, newMsg, newKind) {
23
- const meta = ensureMetadata(toolResult);
24
- if (!meta)
25
- return { willMerge: false, finalKind: newKind };
26
- const existing = meta.toAddFakeUserMessage;
27
- const existingKind = meta[KIND_FIELD];
28
- if (!existing) {
29
- meta.toAddFakeUserMessage = newMsg;
30
- meta[KIND_FIELD] = newKind;
31
- return { willMerge: false, finalKind: newKind };
32
- }
33
- let merged;
34
- if (newKind === "max-iter") {
35
- merged = {
36
- role: "user",
37
- content: `${stringContent(existing)}
38
-
39
- ${stringContent(newMsg)}`
40
- };
41
- } else if (newKind === "delegate" && existingKind === "max-iter") {
42
- merged = {
43
- role: "user",
44
- content: `${stringContent(newMsg)}
45
-
46
- ${stringContent(existing)}`
47
- };
48
- } else {
49
- merged = {
50
- role: "user",
51
- content: `${stringContent(existing)}
52
-
53
- ${stringContent(newMsg)}`
54
- };
55
- }
56
- meta.toAddFakeUserMessage = merged;
57
- const finalKind = newKind === "max-iter" || existingKind === "max-iter" ? "max-iter" : newKind;
58
- meta[KIND_FIELD] = finalKind;
59
- return { willMerge: true, finalKind };
60
- }
61
- var enqueueToAddFakeUserMessage = wrapFunction(enqueueToAddFakeUserMessageImpl, "plugin.fake-user-message.enqueue", {
62
- recordParams: false,
63
- recordResult: false,
64
- log: true,
65
- resultFilter: (result) => ({
66
- "fake-user-message.will_merge": result.willMerge,
67
- "fake-user-message.final_kind": result.finalKind
68
- })
69
- });
70
-
71
- export { enqueueToAddFakeUserMessage };