@personaai/runtime 0.20.0 → 0.21.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 +16 -14
- 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 +16 -14
- 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.21.0";
|
|
163
163
|
|
|
164
164
|
// src/routes/health.ts
|
|
165
165
|
var alwaysOnCapabilities = {
|
|
@@ -191,6 +191,17 @@ var healthRoute = async (_request, ctx) => {
|
|
|
191
191
|
};
|
|
192
192
|
|
|
193
193
|
// src/routeHelpers.ts
|
|
194
|
+
function parseFrontendTools(value) {
|
|
195
|
+
if (value === void 0 || value === null) return void 0;
|
|
196
|
+
if (!Array.isArray(value) || !value.every((t) => typeof t === "object" && t !== null && typeof t.name === "string")) {
|
|
197
|
+
throw new RuntimeHttpError(
|
|
198
|
+
400,
|
|
199
|
+
"INVALID_REQUEST",
|
|
200
|
+
'"tools" must be an array of { name, description?, parameters? } objects.'
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
return value.length > 0 ? value : void 0;
|
|
204
|
+
}
|
|
194
205
|
function json(status, value) {
|
|
195
206
|
return {
|
|
196
207
|
kind: "buffered",
|
|
@@ -627,17 +638,6 @@ function parseAttachments(value) {
|
|
|
627
638
|
}
|
|
628
639
|
return value.length > 0 ? value.map((a) => ({ fileId: a.fileId })) : void 0;
|
|
629
640
|
}
|
|
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
|
-
}
|
|
641
641
|
function parseChatBody(body) {
|
|
642
642
|
if (typeof body !== "object" || body === null) {
|
|
643
643
|
throw new RuntimeHttpError(400, "INVALID_REQUEST", "Request body must be a JSON object.");
|
|
@@ -668,7 +668,7 @@ function parseChatBody(body) {
|
|
|
668
668
|
// a 400 on any shape violation (not a flat string/number/boolean
|
|
669
669
|
// object, or over the byte cap) rather than coercing/dropping it.
|
|
670
670
|
context: validateTurnContext(b.context),
|
|
671
|
-
tools:
|
|
671
|
+
tools: parseFrontendTools(b.tools),
|
|
672
672
|
attachments: parseAttachments(b.attachments)
|
|
673
673
|
};
|
|
674
674
|
}
|
|
@@ -901,10 +901,12 @@ var createVoiceSession = async (request, ctx) => {
|
|
|
901
901
|
const threadId = typeof body.threadId === "string" && body.threadId ? body.threadId : void 0;
|
|
902
902
|
const contextOverride = typeof body.contextOverride === "string" && body.contextOverride ? body.contextOverride : void 0;
|
|
903
903
|
const context = validateTurnContext(body.context);
|
|
904
|
+
const tools = parseFrontendTools(body.tools);
|
|
904
905
|
const ticket = await ctx.client.voice.createSession(agentId, {
|
|
905
906
|
...threadId ? { threadId } : {},
|
|
906
907
|
...contextOverride ? { contextOverride } : {},
|
|
907
|
-
...context ? { context } : {}
|
|
908
|
+
...context ? { context } : {},
|
|
909
|
+
...tools ? { tools } : {}
|
|
908
910
|
});
|
|
909
911
|
await ctx.hooks?.onVoiceSessionCreate?.({
|
|
910
912
|
userId: request.userId,
|