@mindstudio-ai/remy 0.1.236 → 0.1.238
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/headless.js +29 -9
- package/dist/index.js +29 -9
- package/package.json +1 -1
package/dist/headless.js
CHANGED
|
@@ -7032,7 +7032,10 @@ async function runTurn(params) {
|
|
|
7032
7032
|
onEvent({
|
|
7033
7033
|
type: "user_message",
|
|
7034
7034
|
text: userMessage,
|
|
7035
|
-
hidden: hidden || void 0
|
|
7035
|
+
hidden: hidden || void 0,
|
|
7036
|
+
// Include attachments so the live event can render a queued voice/image/file
|
|
7037
|
+
// bubble; a voice message has empty text and the transcript lives here.
|
|
7038
|
+
...hasAttachments && { attachments }
|
|
7036
7039
|
});
|
|
7037
7040
|
const isFirstMessage = state.messages.filter((m) => m.role === "user").length === 1;
|
|
7038
7041
|
const STATUS_EXCLUDED_TOOLS = /* @__PURE__ */ new Set([
|
|
@@ -7566,14 +7569,15 @@ function filenameFromUrl(url) {
|
|
|
7566
7569
|
return `upload-${Date.now()}`;
|
|
7567
7570
|
}
|
|
7568
7571
|
}
|
|
7569
|
-
function resolveUniqueFilename(name) {
|
|
7570
|
-
|
|
7572
|
+
function resolveUniqueFilename(name, claimed) {
|
|
7573
|
+
const isFree = (candidate) => !claimed.has(candidate) && !existsSync(join(UPLOADS_DIR, candidate));
|
|
7574
|
+
if (isFree(name)) {
|
|
7571
7575
|
return name;
|
|
7572
7576
|
}
|
|
7573
7577
|
const ext = extname(name);
|
|
7574
7578
|
const base = name.slice(0, name.length - ext.length);
|
|
7575
7579
|
let counter = 1;
|
|
7576
|
-
while (
|
|
7580
|
+
while (!isFree(`${base}-${counter}${ext}`)) {
|
|
7577
7581
|
counter++;
|
|
7578
7582
|
}
|
|
7579
7583
|
return `${base}-${counter}${ext}`;
|
|
@@ -7589,11 +7593,18 @@ async function persistAttachments(attachments) {
|
|
|
7589
7593
|
return { documents: [], images: [] };
|
|
7590
7594
|
}
|
|
7591
7595
|
mkdirSync(UPLOADS_DIR, { recursive: true });
|
|
7596
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
7597
|
+
const names = nonVoice.map((att) => {
|
|
7598
|
+
const name = resolveUniqueFilename(
|
|
7599
|
+
att.filename || filenameFromUrl(att.url),
|
|
7600
|
+
claimed
|
|
7601
|
+
);
|
|
7602
|
+
claimed.add(name);
|
|
7603
|
+
return name;
|
|
7604
|
+
});
|
|
7592
7605
|
const results = await Promise.allSettled(
|
|
7593
|
-
nonVoice.map(async (att) => {
|
|
7594
|
-
const name =
|
|
7595
|
-
att.filename || filenameFromUrl(att.url)
|
|
7596
|
-
);
|
|
7606
|
+
nonVoice.map(async (att, i) => {
|
|
7607
|
+
const name = names[i];
|
|
7597
7608
|
const localPath = join(UPLOADS_DIR, name);
|
|
7598
7609
|
const res = await fetch(att.url, {
|
|
7599
7610
|
signal: AbortSignal.timeout(3e4)
|
|
@@ -8152,7 +8163,16 @@ var HeadlessSession = class {
|
|
|
8152
8163
|
this.emit("turn_started", {}, rid);
|
|
8153
8164
|
return;
|
|
8154
8165
|
case "user_message":
|
|
8155
|
-
this.emit(
|
|
8166
|
+
this.emit(
|
|
8167
|
+
"user_message",
|
|
8168
|
+
{
|
|
8169
|
+
text: e.text,
|
|
8170
|
+
// Forward attachments so queued voice/image/file sends render live;
|
|
8171
|
+
// otherwise the bubble is blank until a get_history refresh.
|
|
8172
|
+
...e.attachments && { attachments: e.attachments }
|
|
8173
|
+
},
|
|
8174
|
+
rid
|
|
8175
|
+
);
|
|
8156
8176
|
return;
|
|
8157
8177
|
// Terminal events — translate to `completed`.
|
|
8158
8178
|
// Post-turn queue drain happens in handleMessage AFTER runTurn returns,
|
package/dist/index.js
CHANGED
|
@@ -7764,7 +7764,10 @@ async function runTurn(params) {
|
|
|
7764
7764
|
onEvent({
|
|
7765
7765
|
type: "user_message",
|
|
7766
7766
|
text: userMessage,
|
|
7767
|
-
hidden: hidden || void 0
|
|
7767
|
+
hidden: hidden || void 0,
|
|
7768
|
+
// Include attachments so the live event can render a queued voice/image/file
|
|
7769
|
+
// bubble; a voice message has empty text and the transcript lives here.
|
|
7770
|
+
...hasAttachments && { attachments }
|
|
7768
7771
|
});
|
|
7769
7772
|
const isFirstMessage = state.messages.filter((m) => m.role === "user").length === 1;
|
|
7770
7773
|
const STATUS_EXCLUDED_TOOLS = /* @__PURE__ */ new Set([
|
|
@@ -8389,14 +8392,15 @@ function filenameFromUrl(url) {
|
|
|
8389
8392
|
return `upload-${Date.now()}`;
|
|
8390
8393
|
}
|
|
8391
8394
|
}
|
|
8392
|
-
function resolveUniqueFilename(name) {
|
|
8393
|
-
|
|
8395
|
+
function resolveUniqueFilename(name, claimed) {
|
|
8396
|
+
const isFree = (candidate) => !claimed.has(candidate) && !existsSync(join(UPLOADS_DIR, candidate));
|
|
8397
|
+
if (isFree(name)) {
|
|
8394
8398
|
return name;
|
|
8395
8399
|
}
|
|
8396
8400
|
const ext = extname(name);
|
|
8397
8401
|
const base = name.slice(0, name.length - ext.length);
|
|
8398
8402
|
let counter = 1;
|
|
8399
|
-
while (
|
|
8403
|
+
while (!isFree(`${base}-${counter}${ext}`)) {
|
|
8400
8404
|
counter++;
|
|
8401
8405
|
}
|
|
8402
8406
|
return `${base}-${counter}${ext}`;
|
|
@@ -8411,11 +8415,18 @@ async function persistAttachments(attachments) {
|
|
|
8411
8415
|
return { documents: [], images: [] };
|
|
8412
8416
|
}
|
|
8413
8417
|
mkdirSync(UPLOADS_DIR, { recursive: true });
|
|
8418
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
8419
|
+
const names = nonVoice.map((att) => {
|
|
8420
|
+
const name = resolveUniqueFilename(
|
|
8421
|
+
att.filename || filenameFromUrl(att.url),
|
|
8422
|
+
claimed
|
|
8423
|
+
);
|
|
8424
|
+
claimed.add(name);
|
|
8425
|
+
return name;
|
|
8426
|
+
});
|
|
8414
8427
|
const results = await Promise.allSettled(
|
|
8415
|
-
nonVoice.map(async (att) => {
|
|
8416
|
-
const name =
|
|
8417
|
-
att.filename || filenameFromUrl(att.url)
|
|
8418
|
-
);
|
|
8428
|
+
nonVoice.map(async (att, i) => {
|
|
8429
|
+
const name = names[i];
|
|
8419
8430
|
const localPath = join(UPLOADS_DIR, name);
|
|
8420
8431
|
const res = await fetch(att.url, {
|
|
8421
8432
|
signal: AbortSignal.timeout(3e4)
|
|
@@ -9037,7 +9048,16 @@ var init_headless = __esm({
|
|
|
9037
9048
|
this.emit("turn_started", {}, rid);
|
|
9038
9049
|
return;
|
|
9039
9050
|
case "user_message":
|
|
9040
|
-
this.emit(
|
|
9051
|
+
this.emit(
|
|
9052
|
+
"user_message",
|
|
9053
|
+
{
|
|
9054
|
+
text: e.text,
|
|
9055
|
+
// Forward attachments so queued voice/image/file sends render live;
|
|
9056
|
+
// otherwise the bubble is blank until a get_history refresh.
|
|
9057
|
+
...e.attachments && { attachments: e.attachments }
|
|
9058
|
+
},
|
|
9059
|
+
rid
|
|
9060
|
+
);
|
|
9041
9061
|
return;
|
|
9042
9062
|
// Terminal events — translate to `completed`.
|
|
9043
9063
|
// Post-turn queue drain happens in handleMessage AFTER runTurn returns,
|