@personaai/runtime 0.19.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 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.19.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",
@@ -606,16 +617,26 @@ async function* withHeartbeats(source, intervalMs = 15e3) {
606
617
  }
607
618
 
608
619
  // src/routes/chat.ts
609
- function parseTools(value) {
620
+ var MAX_ATTACHMENTS = 4;
621
+ function parseAttachments(value) {
610
622
  if (value === void 0 || value === null) return void 0;
611
- if (!Array.isArray(value) || !value.every((t) => typeof t === "object" && t !== null && typeof t.name === "string")) {
623
+ if (!Array.isArray(value) || !value.every(
624
+ (a) => typeof a === "object" && a !== null && typeof a.fileId === "string" && a.fileId.length > 0 && a.fileId.length <= 64
625
+ )) {
612
626
  throw new RuntimeHttpError(
613
627
  400,
614
628
  "INVALID_REQUEST",
615
- '"tools" must be an array of { name, description?, parameters? } objects.'
629
+ '"attachments" must be an array of { fileId } objects.'
616
630
  );
617
631
  }
618
- return value.length > 0 ? value : void 0;
632
+ if (value.length > MAX_ATTACHMENTS) {
633
+ throw new RuntimeHttpError(
634
+ 400,
635
+ "INVALID_REQUEST",
636
+ `At most ${MAX_ATTACHMENTS} attachments per message.`
637
+ );
638
+ }
639
+ return value.length > 0 ? value.map((a) => ({ fileId: a.fileId })) : void 0;
619
640
  }
620
641
  function parseChatBody(body) {
621
642
  if (typeof body !== "object" || body === null) {
@@ -647,7 +668,8 @@ function parseChatBody(body) {
647
668
  // a 400 on any shape violation (not a flat string/number/boolean
648
669
  // object, or over the byte cap) rather than coercing/dropping it.
649
670
  context: validateTurnContext(b.context),
650
- tools: parseTools(b.tools)
671
+ tools: parseFrontendTools(b.tools),
672
+ attachments: parseAttachments(b.attachments)
651
673
  };
652
674
  }
653
675
  var chatRoute = async (request, ctx) => {
@@ -680,7 +702,8 @@ var chatRoute = async (request, ctx) => {
680
702
  resume: body.resume,
681
703
  contextOverride: body.contextOverride,
682
704
  context: body.context,
683
- tools: body.tools
705
+ tools: body.tools,
706
+ attachments: body.attachments
684
707
  });
685
708
  const runId = crypto.randomUUID();
686
709
  logger.info("chat run created", {
@@ -878,10 +901,12 @@ var createVoiceSession = async (request, ctx) => {
878
901
  const threadId = typeof body.threadId === "string" && body.threadId ? body.threadId : void 0;
879
902
  const contextOverride = typeof body.contextOverride === "string" && body.contextOverride ? body.contextOverride : void 0;
880
903
  const context = validateTurnContext(body.context);
904
+ const tools = parseFrontendTools(body.tools);
881
905
  const ticket = await ctx.client.voice.createSession(agentId, {
882
906
  ...threadId ? { threadId } : {},
883
907
  ...contextOverride ? { contextOverride } : {},
884
- ...context ? { context } : {}
908
+ ...context ? { context } : {},
909
+ ...tools ? { tools } : {}
885
910
  });
886
911
  await ctx.hooks?.onVoiceSessionCreate?.({
887
912
  userId: request.userId,
@@ -1011,6 +1036,7 @@ var createAgent = async (request, ctx) => {
1011
1036
  webSearchEnabled: typeof body.webSearchEnabled === "boolean" ? body.webSearchEnabled : void 0,
1012
1037
  sandboxEnabled: typeof body.sandboxEnabled === "boolean" ? body.sandboxEnabled : void 0,
1013
1038
  frontendToolsEnabled: typeof body.frontendToolsEnabled === "boolean" ? body.frontendToolsEnabled : void 0,
1039
+ imageInputEnabled: typeof body.imageInputEnabled === "boolean" ? body.imageInputEnabled : void 0,
1014
1040
  visibility: body.visibility,
1015
1041
  category: body.category,
1016
1042
  skills: Array.isArray(body.skills) ? body.skills : void 0,