@qearlyao/familiar 0.2.1 → 0.2.2
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/dist/browser-tools.js +3 -1
- package/dist/discord.js +23 -2
- package/package.json +1 -1
package/dist/browser-tools.js
CHANGED
|
@@ -120,7 +120,9 @@ function buildSpawnInvocation(spec, currentPlatform = platform(), comSpec = proc
|
|
|
120
120
|
const commandLine = [spec.command, ...spec.args].map(quoteWindowsShellArg).join(" ");
|
|
121
121
|
return {
|
|
122
122
|
command: comSpec,
|
|
123
|
-
|
|
123
|
+
// cmd.exe strips one outer quote pair from the /c string. Wrap the whole
|
|
124
|
+
// already-quoted command so .cmd shims with spaced paths still receive argv.
|
|
125
|
+
args: ["/d", "/s", "/c", `"${commandLine}"`],
|
|
124
126
|
options: {
|
|
125
127
|
...options,
|
|
126
128
|
windowsVerbatimArguments: true,
|
package/dist/discord.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { once } from "node:events";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
3
4
|
import { ApplicationCommandOptionType, ApplicationCommandType, ApplicationIntegrationType, ChannelType, Client, Events, GatewayIntentBits, InteractionContextType, MessageFlags, Partials, } from "discord.js";
|
|
4
5
|
import { createAgentEventRecorder, storedAgentEventFromAgentEvent, thinkingDurationMs, updateAgentEventSummary, } from "./agent-events.js";
|
|
5
6
|
import { chatChannelKey, createChatLog } from "./chat-log.js";
|
|
@@ -326,6 +327,26 @@ async function delayBetweenBurstChunks(config, channel) {
|
|
|
326
327
|
function normalizeOutboundText(text) {
|
|
327
328
|
return text.trim() || "(empty response)";
|
|
328
329
|
}
|
|
330
|
+
async function discordAttachmentPayload(attachment) {
|
|
331
|
+
if (!attachment.localPath)
|
|
332
|
+
return undefined;
|
|
333
|
+
return {
|
|
334
|
+
attachment: await readFile(attachment.localPath),
|
|
335
|
+
name: attachment.name,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
async function discordAttachmentPayloads(attachments) {
|
|
339
|
+
const payloads = [];
|
|
340
|
+
for (const attachment of attachments) {
|
|
341
|
+
const payload = await discordAttachmentPayload(attachment);
|
|
342
|
+
if (payload)
|
|
343
|
+
payloads.push(payload);
|
|
344
|
+
}
|
|
345
|
+
return payloads;
|
|
346
|
+
}
|
|
347
|
+
export const __test = {
|
|
348
|
+
discordAttachmentPayloads,
|
|
349
|
+
};
|
|
329
350
|
function parseAgentReply(text) {
|
|
330
351
|
const normalized = text.replace(/\r\n/g, "\n").trim();
|
|
331
352
|
if (normalized === SILENT_RESPONSE_MARKER) {
|
|
@@ -344,7 +365,7 @@ async function sendReply(config, message, text, replyToMessageId, attachments =
|
|
|
344
365
|
for (const [index, chunk] of chunks.entries()) {
|
|
345
366
|
if (index > 0)
|
|
346
367
|
await delayBetweenBurstChunks(config, message.channel);
|
|
347
|
-
const files = index === 0 ?
|
|
368
|
+
const files = index === 0 ? await discordAttachmentPayloads(attachments) : [];
|
|
348
369
|
let sent;
|
|
349
370
|
if (index === 0 && config.discord.replyMode === "reply") {
|
|
350
371
|
try {
|
|
@@ -379,7 +400,7 @@ async function sendChannelMessage(config, channel, text, attachments = []) {
|
|
|
379
400
|
for (const [index, chunk] of chunks.entries()) {
|
|
380
401
|
if (index > 0)
|
|
381
402
|
await delayBetweenBurstChunks(config, channel);
|
|
382
|
-
const files = index === 0 ?
|
|
403
|
+
const files = index === 0 ? await discordAttachmentPayloads(attachments) : [];
|
|
383
404
|
const sent = await channel.send(files.length > 0 ? { content: chunk, files } : chunk);
|
|
384
405
|
sentIds.push(sent.id);
|
|
385
406
|
}
|