@ai-setting/roy-agent-cli 1.5.103 → 1.5.104

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.
@@ -7427,7 +7427,7 @@ var require_dist = __commonJS((exports) => {
7427
7427
  var require_package = __commonJS((exports, module) => {
7428
7428
  module.exports = {
7429
7429
  name: "@ai-setting/roy-agent-cli",
7430
- version: "1.5.103",
7430
+ version: "1.5.104",
7431
7431
  type: "module",
7432
7432
  description: "CLI for roy-agent - Non-interactive command execution",
7433
7433
  main: "./dist/index.js",
@@ -9084,13 +9084,23 @@ class QueryExecutor {
9084
9084
  this.output.info(`执行: ${message}`);
9085
9085
  }
9086
9086
  const contextHandler = new ContextHandlerService(this.env, this.sessionComponent, { maxRetries: 1, autoCompact: true });
9087
- const { systemPrompt: agentContextSystemPrompt, ...restAgentContext } = agentContext ?? {};
9087
+ const {
9088
+ systemPrompt: agentContextSystemPrompt,
9089
+ eventSourceSystemPrompt: agentContextPreloadedPrompts,
9090
+ ...restAgentContext
9091
+ } = agentContext ?? {};
9092
+ let eventSourceFinalPrompt;
9093
+ if (typeof agentContextSystemPrompt === "string" && agentContextSystemPrompt.length > 0) {
9094
+ eventSourceFinalPrompt = agentContextSystemPrompt;
9095
+ } else if (typeof agentContextPreloadedPrompts === "string" && agentContextPreloadedPrompts.length > 0) {
9096
+ eventSourceFinalPrompt = agentContextPreloadedPrompts;
9097
+ }
9088
9098
  const context = {
9089
9099
  sessionId,
9090
9100
  metadata: {
9091
9101
  originalQuery: message,
9092
9102
  traceId,
9093
- systemPrompt: agentContextSystemPrompt
9103
+ systemPrompt: eventSourceFinalPrompt
9094
9104
  },
9095
9105
  ...restAgentContext
9096
9106
  };
@@ -9668,6 +9678,41 @@ async function startSingleEventSourceImpl(eventSourceComponent, output, eventSou
9668
9678
  }
9669
9679
  }
9670
9680
 
9681
+ // src/commands/collect-event-source-system-prompts.ts
9682
+ import { resolveBountyIMSystemPrompt } from "@ai-setting/roy-agent-core";
9683
+ function resolveSystemPromptForSource(config) {
9684
+ if (config.type === "bounty-im") {
9685
+ const imServerUrl = config.imServerUrl || config.options && config.options.imServerUrl;
9686
+ const address = config.address || config.options && config.options.address || "unknown";
9687
+ return resolveBountyIMSystemPrompt({
9688
+ configSystemPrompt: config.systemPrompt,
9689
+ currentAddress: address,
9690
+ imServerUrl
9691
+ });
9692
+ }
9693
+ return config.systemPrompt;
9694
+ }
9695
+ function collectEventSourceSystemPrompts(eventSourceIds, eventSourceComponent) {
9696
+ const result = [];
9697
+ for (const id of eventSourceIds) {
9698
+ const config = eventSourceComponent.get(id);
9699
+ if (!config)
9700
+ continue;
9701
+ const prompt = resolveSystemPromptForSource(config);
9702
+ if (!prompt)
9703
+ continue;
9704
+ result.push({ id, type: config.type, prompt });
9705
+ }
9706
+ return result;
9707
+ }
9708
+ function joinResolvedSystemPrompts(prompts) {
9709
+ return prompts.map((p) => p.prompt).join(`
9710
+
9711
+ ---
9712
+
9713
+ `);
9714
+ }
9715
+
9671
9716
  // src/commands/shared/ask-user-handler.ts
9672
9717
  import * as readline from "readline";
9673
9718
  import chalk3 from "chalk";
@@ -10145,6 +10190,7 @@ ${COLORS.system("[通知2] ❯ " + message.replace(/\n/g, `
10145
10190
  await this.executeInternal(message, { showPrompt: true });
10146
10191
  }
10147
10192
  currentAgentContext = undefined;
10193
+ eventSourceSystemPrompts = [];
10148
10194
  isIdle() {
10149
10195
  return !this.isExecuting;
10150
10196
  }
@@ -10589,10 +10635,13 @@ function createInteractiveCommand(externalEnvService) {
10589
10635
  sessionTitle,
10590
10636
  onExecute: async (message, traceId, agentContext) => {
10591
10637
  resetStreamAbort();
10638
+ const preloadedPrompts = this.eventSourceSystemPrompts;
10639
+ const eventSourceSystemPrompt = preloadedPrompts.length > 0 ? joinResolvedSystemPrompts(preloadedPrompts) : undefined;
10592
10640
  const mergedContext = {
10593
10641
  ...currentAgentContext,
10594
10642
  model: args.model,
10595
- ...agentContext
10643
+ ...agentContext,
10644
+ eventSourceSystemPrompt
10596
10645
  };
10597
10646
  const effectiveSessionId = mergedContext.eventSessionId ?? sessionId;
10598
10647
  const result = await queryExecutor.execute(message, effectiveSessionId, {
@@ -10673,6 +10722,10 @@ function createInteractiveCommand(externalEnvService) {
10673
10722
  process.exit(1);
10674
10723
  }
10675
10724
  const summary = await startEventSources(eventSourceIds, eventSourceComponent, output);
10725
+ this.eventSourceSystemPrompts = collectEventSourceSystemPrompts(eventSourceIds, eventSourceComponent);
10726
+ if (this.eventSourceSystemPrompts.length > 0) {
10727
+ output.info(`\uD83D\uDCE6 Preloaded ${this.eventSourceSystemPrompts.length} event-source systemPrompt(s)`);
10728
+ }
10676
10729
  if (eventSourceIds.length === 1 && summary.failedCount > 0) {
10677
10730
  process.exit(1);
10678
10731
  }
package/dist/index.js CHANGED
@@ -7426,7 +7426,7 @@ var require_dist = __commonJS((exports) => {
7426
7426
  var require_package = __commonJS((exports, module) => {
7427
7427
  module.exports = {
7428
7428
  name: "@ai-setting/roy-agent-cli",
7429
- version: "1.5.103",
7429
+ version: "1.5.104",
7430
7430
  type: "module",
7431
7431
  description: "CLI for roy-agent - Non-interactive command execution",
7432
7432
  main: "./dist/index.js",
@@ -9083,13 +9083,23 @@ class QueryExecutor {
9083
9083
  this.output.info(`执行: ${message}`);
9084
9084
  }
9085
9085
  const contextHandler = new ContextHandlerService(this.env, this.sessionComponent, { maxRetries: 1, autoCompact: true });
9086
- const { systemPrompt: agentContextSystemPrompt, ...restAgentContext } = agentContext ?? {};
9086
+ const {
9087
+ systemPrompt: agentContextSystemPrompt,
9088
+ eventSourceSystemPrompt: agentContextPreloadedPrompts,
9089
+ ...restAgentContext
9090
+ } = agentContext ?? {};
9091
+ let eventSourceFinalPrompt;
9092
+ if (typeof agentContextSystemPrompt === "string" && agentContextSystemPrompt.length > 0) {
9093
+ eventSourceFinalPrompt = agentContextSystemPrompt;
9094
+ } else if (typeof agentContextPreloadedPrompts === "string" && agentContextPreloadedPrompts.length > 0) {
9095
+ eventSourceFinalPrompt = agentContextPreloadedPrompts;
9096
+ }
9087
9097
  const context = {
9088
9098
  sessionId,
9089
9099
  metadata: {
9090
9100
  originalQuery: message,
9091
9101
  traceId,
9092
- systemPrompt: agentContextSystemPrompt
9102
+ systemPrompt: eventSourceFinalPrompt
9093
9103
  },
9094
9104
  ...restAgentContext
9095
9105
  };
@@ -9667,6 +9677,41 @@ async function startSingleEventSourceImpl(eventSourceComponent, output, eventSou
9667
9677
  }
9668
9678
  }
9669
9679
 
9680
+ // src/commands/collect-event-source-system-prompts.ts
9681
+ import { resolveBountyIMSystemPrompt } from "@ai-setting/roy-agent-core";
9682
+ function resolveSystemPromptForSource(config) {
9683
+ if (config.type === "bounty-im") {
9684
+ const imServerUrl = config.imServerUrl || config.options && config.options.imServerUrl;
9685
+ const address = config.address || config.options && config.options.address || "unknown";
9686
+ return resolveBountyIMSystemPrompt({
9687
+ configSystemPrompt: config.systemPrompt,
9688
+ currentAddress: address,
9689
+ imServerUrl
9690
+ });
9691
+ }
9692
+ return config.systemPrompt;
9693
+ }
9694
+ function collectEventSourceSystemPrompts(eventSourceIds, eventSourceComponent) {
9695
+ const result = [];
9696
+ for (const id of eventSourceIds) {
9697
+ const config = eventSourceComponent.get(id);
9698
+ if (!config)
9699
+ continue;
9700
+ const prompt = resolveSystemPromptForSource(config);
9701
+ if (!prompt)
9702
+ continue;
9703
+ result.push({ id, type: config.type, prompt });
9704
+ }
9705
+ return result;
9706
+ }
9707
+ function joinResolvedSystemPrompts(prompts) {
9708
+ return prompts.map((p) => p.prompt).join(`
9709
+
9710
+ ---
9711
+
9712
+ `);
9713
+ }
9714
+
9670
9715
  // src/commands/shared/ask-user-handler.ts
9671
9716
  import * as readline from "readline";
9672
9717
  import chalk3 from "chalk";
@@ -10144,6 +10189,7 @@ ${COLORS.system("[通知2] ❯ " + message.replace(/\n/g, `
10144
10189
  await this.executeInternal(message, { showPrompt: true });
10145
10190
  }
10146
10191
  currentAgentContext = undefined;
10192
+ eventSourceSystemPrompts = [];
10147
10193
  isIdle() {
10148
10194
  return !this.isExecuting;
10149
10195
  }
@@ -10588,10 +10634,13 @@ function createInteractiveCommand(externalEnvService) {
10588
10634
  sessionTitle,
10589
10635
  onExecute: async (message, traceId, agentContext) => {
10590
10636
  resetStreamAbort();
10637
+ const preloadedPrompts = this.eventSourceSystemPrompts;
10638
+ const eventSourceSystemPrompt = preloadedPrompts.length > 0 ? joinResolvedSystemPrompts(preloadedPrompts) : undefined;
10591
10639
  const mergedContext = {
10592
10640
  ...currentAgentContext,
10593
10641
  model: args.model,
10594
- ...agentContext
10642
+ ...agentContext,
10643
+ eventSourceSystemPrompt
10595
10644
  };
10596
10645
  const effectiveSessionId = mergedContext.eventSessionId ?? sessionId;
10597
10646
  const result = await queryExecutor.execute(message, effectiveSessionId, {
@@ -10672,6 +10721,10 @@ function createInteractiveCommand(externalEnvService) {
10672
10721
  process.exit(1);
10673
10722
  }
10674
10723
  const summary = await startEventSources(eventSourceIds, eventSourceComponent, output);
10724
+ this.eventSourceSystemPrompts = collectEventSourceSystemPrompts(eventSourceIds, eventSourceComponent);
10725
+ if (this.eventSourceSystemPrompts.length > 0) {
10726
+ output.info(`\uD83D\uDCE6 Preloaded ${this.eventSourceSystemPrompts.length} event-source systemPrompt(s)`);
10727
+ }
10675
10728
  if (eventSourceIds.length === 1 && summary.failedCount > 0) {
10676
10729
  process.exit(1);
10677
10730
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-cli",
3
- "version": "1.5.103",
3
+ "version": "1.5.104",
4
4
  "type": "module",
5
5
  "description": "CLI for roy-agent - Non-interactive command execution",
6
6
  "main": "./dist/index.js",