@ai-setting/roy-agent-core 1.5.95 → 1.5.97

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.
@@ -2,7 +2,7 @@ import {
2
2
  AgentComponent,
3
3
  AgentComponentConfigSchema,
4
4
  SummaryAgent
5
- } from "../../shared/@ai-setting/roy-agent-core-6rx2yt78.js";
5
+ } from "../../shared/@ai-setting/roy-agent-core-0dv02z65.js";
6
6
  import"../../shared/@ai-setting/roy-agent-core-j7jeqxhd.js";
7
7
  import"../../shared/@ai-setting/roy-agent-core-jhdv14ks.js";
8
8
  import"../../shared/@ai-setting/roy-agent-core-5h49ct1a.js";
@@ -8,7 +8,7 @@ import {
8
8
  getBuiltInHandler,
9
9
  larkCliHandler,
10
10
  timerHandler
11
- } from "../../shared/@ai-setting/roy-agent-core-8f37pvct.js";
11
+ } from "../../shared/@ai-setting/roy-agent-core-ztyz1smv.js";
12
12
  import {
13
13
  BUILT_IN_EVENT_SOURCE_TYPES,
14
14
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
package/dist/env/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  EventSourceComponent,
6
6
  builtInHandlers,
7
7
  larkCliHandler
8
- } from "../shared/@ai-setting/roy-agent-core-8f37pvct.js";
8
+ } from "../shared/@ai-setting/roy-agent-core-ztyz1smv.js";
9
9
  import {
10
10
  EventSourceInitHooks,
11
11
  getDefaultConfigForType,
@@ -42,7 +42,7 @@ import"../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
42
42
  import {
43
43
  AgentComponent,
44
44
  AgentComponentConfigSchema
45
- } from "../shared/@ai-setting/roy-agent-core-6rx2yt78.js";
45
+ } from "../shared/@ai-setting/roy-agent-core-0dv02z65.js";
46
46
  import"../shared/@ai-setting/roy-agent-core-j7jeqxhd.js";
47
47
  import"../shared/@ai-setting/roy-agent-core-jhdv14ks.js";
48
48
  import"../shared/@ai-setting/roy-agent-core-5h49ct1a.js";
package/dist/index.js CHANGED
@@ -72,7 +72,7 @@ import {
72
72
  getBuiltInHandler,
73
73
  larkCliHandler,
74
74
  timerHandler
75
- } from "./shared/@ai-setting/roy-agent-core-8f37pvct.js";
75
+ } from "./shared/@ai-setting/roy-agent-core-ztyz1smv.js";
76
76
  import {
77
77
  BUILT_IN_EVENT_SOURCE_TYPES,
78
78
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
@@ -130,7 +130,7 @@ import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
130
130
  import {
131
131
  AgentComponent,
132
132
  AgentComponentConfigSchema
133
- } from "./shared/@ai-setting/roy-agent-core-6rx2yt78.js";
133
+ } from "./shared/@ai-setting/roy-agent-core-0dv02z65.js";
134
134
  import {
135
135
  createInvokeConfig,
136
136
  invoke,
@@ -644,6 +644,16 @@ class AgentComponent extends BaseComponent {
644
644
  iterations: 0,
645
645
  toolCalls: []
646
646
  };
647
+ const eventSourceSystemPrompt = context?.metadata?.systemPrompt;
648
+ if (eventSourceSystemPrompt) {
649
+ if (resolvedSystemPrompt) {
650
+ resolvedSystemPrompt = resolvedSystemPrompt + `
651
+
652
+ ` + eventSourceSystemPrompt;
653
+ } else {
654
+ resolvedSystemPrompt = eventSourceSystemPrompt;
655
+ }
656
+ }
647
657
  const hookCtx = {
648
658
  agent,
649
659
  iteration: 0,
@@ -209,6 +209,25 @@ function readBountyIMTlsSkipVerify(config) {
209
209
  const raw = topLevel !== undefined ? topLevel : fromOptions;
210
210
  return raw === true;
211
211
  }
212
+ function buildDefaultBountyIMSystemPrompt(input) {
213
+ const server = input.imServerUrl || "ws://localhost:4005/ws";
214
+ const httpScheme = server.startsWith("wss://") ? "https://" : "http://";
215
+ const endpoint = server.replace(/^wss?:\/\//, httpScheme).replace(/\/ws$/, "");
216
+ return [
217
+ "你正在通过 Bounty IM 与其他 agent 通信。",
218
+ `- 你的 IM 地址:${input.currentAddress}`,
219
+ `- IM Server URL:${server}`,
220
+ "",
221
+ "当需要回复收到的消息时,用 bounty com send CLI 投递:",
222
+ ` bounty com send --endpoint ${endpoint} -f ${input.currentAddress} -t <to-address> -b <body>`,
223
+ "",
224
+ "注意:每次交互都用同一个 from-address(你的地址),to-address 用收到的消息的 from 字段。"
225
+ ].join(`
226
+ `);
227
+ }
228
+ function resolveBountyIMSystemPrompt(input) {
229
+ return input.configSystemPrompt || buildDefaultBountyIMSystemPrompt(input);
230
+ }
212
231
  function shouldWriteBunTlsSkipEnv(tlsSkipVerify, isBunRuntimeOverride) {
213
232
  const isBun = isBunRuntimeOverride ?? typeof Bun !== "undefined";
214
233
  return tlsSkipVerify === true && isBun;
@@ -227,6 +246,14 @@ class BountyIMInstance {
227
246
  const { address } = readBountyIMConfig(this.config);
228
247
  return address || "unknown";
229
248
  }
249
+ getCurrentSystemPrompt() {
250
+ const imServerUrl = readBountyIMConfig(this.config).imServerUrl;
251
+ return resolveBountyIMSystemPrompt({
252
+ configSystemPrompt: this.config.systemPrompt,
253
+ currentAddress: this.getCurrentAddress(),
254
+ imServerUrl
255
+ });
256
+ }
230
257
  getStatus() {
231
258
  return this.status;
232
259
  }
@@ -357,11 +384,13 @@ class BountyIMInstance {
357
384
  \uD83D\uDCA1 回复: bounty com send -f ${toAddress} -t ${fromAddress} -b "回复内容"` : this.formatMessage(rawEvent);
358
385
  const event = {
359
386
  id: `es-${this.config.id}-${Date.now()}`,
360
- type: eventType,
387
+ type: "event-source.event.bounty-im",
361
388
  timestamp: Date.now(),
362
389
  metadata: {
363
390
  source: "event-source",
364
391
  sourceId: this.config.id,
392
+ sourceMessageType: eventType,
393
+ systemPrompt: this.getCurrentSystemPrompt(),
365
394
  agent
366
395
  },
367
396
  payload: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.5.95",
3
+ "version": "1.5.97",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",