@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.
@@ -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
- args: ["/d", "/s", "/c", commandLine],
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 ? attachments.flatMap((attachment) => (attachment.localPath ? [attachment.localPath] : [])) : [];
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 ? attachments.flatMap((attachment) => (attachment.localPath ? [attachment.localPath] : [])) : [];
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qearlyao/familiar",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {