@personaai/runtime 0.18.0 → 0.20.0
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/index.cjs +40 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -159,7 +159,7 @@ function evictStaleRuns(runs, now, graceMs = DEFAULT_RUN_GRACE_MS, maxTracked =
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
// src/version.ts
|
|
162
|
-
var RUNTIME_VERSION = "0.
|
|
162
|
+
var RUNTIME_VERSION = "0.20.0";
|
|
163
163
|
|
|
164
164
|
// src/routes/health.ts
|
|
165
165
|
var alwaysOnCapabilities = {
|
|
@@ -606,6 +606,38 @@ async function* withHeartbeats(source, intervalMs = 15e3) {
|
|
|
606
606
|
}
|
|
607
607
|
|
|
608
608
|
// src/routes/chat.ts
|
|
609
|
+
var MAX_ATTACHMENTS = 4;
|
|
610
|
+
function parseAttachments(value) {
|
|
611
|
+
if (value === void 0 || value === null) return void 0;
|
|
612
|
+
if (!Array.isArray(value) || !value.every(
|
|
613
|
+
(a) => typeof a === "object" && a !== null && typeof a.fileId === "string" && a.fileId.length > 0 && a.fileId.length <= 64
|
|
614
|
+
)) {
|
|
615
|
+
throw new RuntimeHttpError(
|
|
616
|
+
400,
|
|
617
|
+
"INVALID_REQUEST",
|
|
618
|
+
'"attachments" must be an array of { fileId } objects.'
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
if (value.length > MAX_ATTACHMENTS) {
|
|
622
|
+
throw new RuntimeHttpError(
|
|
623
|
+
400,
|
|
624
|
+
"INVALID_REQUEST",
|
|
625
|
+
`At most ${MAX_ATTACHMENTS} attachments per message.`
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
return value.length > 0 ? value.map((a) => ({ fileId: a.fileId })) : void 0;
|
|
629
|
+
}
|
|
630
|
+
function parseTools(value) {
|
|
631
|
+
if (value === void 0 || value === null) return void 0;
|
|
632
|
+
if (!Array.isArray(value) || !value.every((t) => typeof t === "object" && t !== null && typeof t.name === "string")) {
|
|
633
|
+
throw new RuntimeHttpError(
|
|
634
|
+
400,
|
|
635
|
+
"INVALID_REQUEST",
|
|
636
|
+
'"tools" must be an array of { name, description?, parameters? } objects.'
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
return value.length > 0 ? value : void 0;
|
|
640
|
+
}
|
|
609
641
|
function parseChatBody(body) {
|
|
610
642
|
if (typeof body !== "object" || body === null) {
|
|
611
643
|
throw new RuntimeHttpError(400, "INVALID_REQUEST", "Request body must be a JSON object.");
|
|
@@ -635,7 +667,9 @@ function parseChatBody(body) {
|
|
|
635
667
|
// ever read live by an RCP tool's resolver. validateTurnContext throws
|
|
636
668
|
// a 400 on any shape violation (not a flat string/number/boolean
|
|
637
669
|
// object, or over the byte cap) rather than coercing/dropping it.
|
|
638
|
-
context: validateTurnContext(b.context)
|
|
670
|
+
context: validateTurnContext(b.context),
|
|
671
|
+
tools: parseTools(b.tools),
|
|
672
|
+
attachments: parseAttachments(b.attachments)
|
|
639
673
|
};
|
|
640
674
|
}
|
|
641
675
|
var chatRoute = async (request, ctx) => {
|
|
@@ -667,7 +701,9 @@ var chatRoute = async (request, ctx) => {
|
|
|
667
701
|
threadId: body.threadId,
|
|
668
702
|
resume: body.resume,
|
|
669
703
|
contextOverride: body.contextOverride,
|
|
670
|
-
context: body.context
|
|
704
|
+
context: body.context,
|
|
705
|
+
tools: body.tools,
|
|
706
|
+
attachments: body.attachments
|
|
671
707
|
});
|
|
672
708
|
const runId = crypto.randomUUID();
|
|
673
709
|
logger.info("chat run created", {
|
|
@@ -998,6 +1034,7 @@ var createAgent = async (request, ctx) => {
|
|
|
998
1034
|
webSearchEnabled: typeof body.webSearchEnabled === "boolean" ? body.webSearchEnabled : void 0,
|
|
999
1035
|
sandboxEnabled: typeof body.sandboxEnabled === "boolean" ? body.sandboxEnabled : void 0,
|
|
1000
1036
|
frontendToolsEnabled: typeof body.frontendToolsEnabled === "boolean" ? body.frontendToolsEnabled : void 0,
|
|
1037
|
+
imageInputEnabled: typeof body.imageInputEnabled === "boolean" ? body.imageInputEnabled : void 0,
|
|
1001
1038
|
visibility: body.visibility,
|
|
1002
1039
|
category: body.category,
|
|
1003
1040
|
skills: Array.isArray(body.skills) ? body.skills : void 0,
|