agent-relay-runner 0.60.0 → 0.60.1
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/package.json
CHANGED
package/src/runner.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { dirname, join } from "node:path";
|
|
|
5
5
|
import type { AgentLifecycle, AgentProfile, ContextState, Message, MessageSessionMeta, ProviderCapabilities, SendMessageInput, TaskStatusInput, WorkspaceMetadata } from "agent-relay-sdk";
|
|
6
6
|
import { errMessage, RelayBusClient, RelayHttpClient } from "agent-relay-sdk";
|
|
7
7
|
import { contextStateFromProbeMetrics, readContextProbeState } from "agent-relay-sdk/context-probe";
|
|
8
|
-
import { providerMessageText } from "./adapter";
|
|
8
|
+
import { providerAttachmentText, providerMessageText } from "./adapter";
|
|
9
9
|
import type { ManagedProcess, ProviderAdapter, ProviderConfig, ProviderPermissionDecision, ProviderPermissionDecisionInput, ProviderSessionEvent, ProviderStatusUpdate, RunnerSpawnConfig, SemanticStatus, TerminalAttachSpec } from "./adapter";
|
|
10
10
|
import { messagesWithCachedAttachments } from "./attachment-cache";
|
|
11
11
|
import { resolveProjectName } from "./config";
|
|
@@ -853,12 +853,35 @@ export class AgentRunner {
|
|
|
853
853
|
if (!this.process) throw new Error("provider process is unavailable");
|
|
854
854
|
if (!this.options.adapter.deliverInitialPrompt) throw new Error("provider does not support prompt injection");
|
|
855
855
|
const messageId = typeof params.messageId === "number" ? params.messageId : undefined;
|
|
856
|
+
const attachments = Array.isArray(params.attachments)
|
|
857
|
+
? params.attachments.filter((item): item is Record<string, unknown> => item !== null && typeof item === "object" && !Array.isArray(item))
|
|
858
|
+
: [];
|
|
856
859
|
if (messageId) this.pendingPromptMessageId = messageId;
|
|
860
|
+
const prompt = await this.promptInjectionText(body, messageId, attachments);
|
|
857
861
|
// Mark so the matching UserPromptSubmit echo isn't double-posted: a chat-box
|
|
858
862
|
// prompt already created its own session message shown in the dashboard.
|
|
859
|
-
this.recordInjectedPrompt(
|
|
860
|
-
await this.options.adapter.deliverInitialPrompt(this.process,
|
|
861
|
-
return { injected: true, messageId };
|
|
863
|
+
this.recordInjectedPrompt(prompt.trim());
|
|
864
|
+
await this.options.adapter.deliverInitialPrompt(this.process, prompt);
|
|
865
|
+
return { injected: true, messageId, attachmentCount: attachments.length };
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
private async promptInjectionText(body: string, messageId: number | undefined, attachments: Record<string, unknown>[]): Promise<string> {
|
|
869
|
+
if (!attachments.length) return body;
|
|
870
|
+
const messages = await messagesWithCachedAttachments([{
|
|
871
|
+
id: messageId ?? 0,
|
|
872
|
+
from: "user",
|
|
873
|
+
to: this.agentId,
|
|
874
|
+
kind: "session",
|
|
875
|
+
body,
|
|
876
|
+
payload: { attachments },
|
|
877
|
+
readBy: [],
|
|
878
|
+
createdAt: Date.now(),
|
|
879
|
+
}], this.http, {
|
|
880
|
+
agentId: this.agentId,
|
|
881
|
+
onError: (message) => logger.warn("attachments", message),
|
|
882
|
+
});
|
|
883
|
+
const attachmentText = providerAttachmentText(messages[0]!);
|
|
884
|
+
return attachmentText ? `${body}\n\n${attachmentText}` : body;
|
|
862
885
|
}
|
|
863
886
|
|
|
864
887
|
private async restartProvider(): Promise<void> {
|