fluxy-bot 0.2.4 → 0.2.5
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 +1 -1
- package/supervisor/fluxy-agent.ts +41 -1
- package/supervisor/index.ts +1 -1
package/package.json
CHANGED
|
@@ -22,6 +22,42 @@ interface ActiveQuery {
|
|
|
22
22
|
|
|
23
23
|
const activeQueries = new Map<string, ActiveQuery>();
|
|
24
24
|
|
|
25
|
+
export interface AgentAttachment {
|
|
26
|
+
type: 'image' | 'file';
|
|
27
|
+
name: string;
|
|
28
|
+
mediaType: string;
|
|
29
|
+
data: string; // base64
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Build a multi-part prompt with attachments for the SDK */
|
|
33
|
+
function buildMultiPartPrompt(text: string, attachments: AgentAttachment[]): AsyncIterable<SDKUserMessage> {
|
|
34
|
+
return (async function* () {
|
|
35
|
+
const content: any[] = [];
|
|
36
|
+
|
|
37
|
+
for (const att of attachments) {
|
|
38
|
+
if (att.type === 'image') {
|
|
39
|
+
content.push({
|
|
40
|
+
type: 'image',
|
|
41
|
+
source: { type: 'base64', media_type: att.mediaType, data: att.data },
|
|
42
|
+
});
|
|
43
|
+
} else {
|
|
44
|
+
content.push({
|
|
45
|
+
type: 'document',
|
|
46
|
+
source: { type: 'base64', media_type: att.mediaType, data: att.data },
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
content.push({ type: 'text', text: text || '(attached files)' });
|
|
52
|
+
|
|
53
|
+
yield {
|
|
54
|
+
type: 'user' as const,
|
|
55
|
+
message: { role: 'user' as const, content },
|
|
56
|
+
parent_tool_use_id: null,
|
|
57
|
+
} as SDKUserMessage;
|
|
58
|
+
})();
|
|
59
|
+
}
|
|
60
|
+
|
|
25
61
|
/** Read the OAuth token stored by claude-auth */
|
|
26
62
|
function readOAuthToken(): string | null {
|
|
27
63
|
try {
|
|
@@ -56,6 +92,7 @@ export async function startFluxyAgentQuery(
|
|
|
56
92
|
prompt: string,
|
|
57
93
|
model: string,
|
|
58
94
|
onMessage: (type: string, data: any) => void,
|
|
95
|
+
attachments?: AgentAttachment[],
|
|
59
96
|
): Promise<void> {
|
|
60
97
|
const oauthToken = readOAuthToken();
|
|
61
98
|
if (!oauthToken) {
|
|
@@ -71,9 +108,12 @@ export async function startFluxyAgentQuery(
|
|
|
71
108
|
|
|
72
109
|
let fullText = '';
|
|
73
110
|
|
|
111
|
+
const sdkPrompt: string | AsyncIterable<SDKUserMessage> =
|
|
112
|
+
attachments?.length ? buildMultiPartPrompt(prompt, attachments) : prompt;
|
|
113
|
+
|
|
74
114
|
try {
|
|
75
115
|
const claudeQuery = query({
|
|
76
|
-
prompt,
|
|
116
|
+
prompt: sdkPrompt,
|
|
77
117
|
options: {
|
|
78
118
|
model,
|
|
79
119
|
cwd: DATA_DIR,
|
package/supervisor/index.ts
CHANGED
|
@@ -128,7 +128,7 @@ export async function startSupervisor() {
|
|
|
128
128
|
if (config.ai.provider === 'anthropic') {
|
|
129
129
|
startFluxyAgentQuery(convId, content, config.ai.model, (type, eventData) => {
|
|
130
130
|
ws.send(JSON.stringify({ type, data: eventData }));
|
|
131
|
-
});
|
|
131
|
+
}, data.attachments);
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
134
|
|