@personaai/runtime 0.6.0 → 0.7.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/README.md CHANGED
@@ -92,6 +92,7 @@ user; `resolveUser` returning `null` or throwing responds `401`.
92
92
  | `DELETE` | `/threads/:id` | `client.threads.delete(id)` → `204` |
93
93
  | `GET` | `/threads/:id/messages` | `client.threads.getMessages(id)` — full history + graph state, the same data `chat.stream()` resumes from; load a past conversation on page reopen. |
94
94
  | `POST` | `/threads/:id/reset` | `client.threads.reset(id)` — clears message history/files/todos/subagent traces in place, keeping the same Thread id/title. |
95
+ | `POST` | `/voice/sessions` | `client.voice.createSession(agentId)` → `{ticket, wsUrl, expiresAt, session}`. `agentId` required in the body. This route only mints the ticket — your frontend takes `wsUrl` (ticket already embedded) and opens `new WebSocket(wsUrl)` **directly to Persona**, not back through this runtime. Real-time audio, powered by Gemini Live. `201` |
95
96
  | `GET` | `/agents` | `client.agents.list({page, limit, search, category, scope})` — read-only discovery, e.g. "let the user pick an agent." |
96
97
  | `GET` | `/files` | `client.files.list({page, limit})` |
97
98
  | `POST` | `/files` | `client.files.upload({filename, content, contentType?, agentId?, threadId?})` — multipart, `file` part required. `201` |
@@ -230,7 +231,7 @@ resolved identity, is the capability on."
230
231
 
231
232
  Plain async event listeners, not middleware — the runtime proceeds with sensible defaults when a
232
233
  hook is omitted, and a hook that wants to reject a run just throws (the throw is caught and
233
- routed through the same sanitized error response as any other failure). **All eight are wired.**
234
+ routed through the same sanitized error response as any other failure). **All nine are wired.**
234
235
 
235
236
  ```ts
236
237
  createRuntime({
@@ -273,6 +274,11 @@ createRuntime({
273
274
  onMemoryWrite(ctx) {
274
275
  // ctx: { userId, agentId?, path } — fires after PUT /memory/file succeeds.
275
276
  },
277
+ onVoiceSessionCreate(ctx) {
278
+ // ctx: { userId, agentId } — fires after POST /voice/sessions mints a
279
+ // ticket. Note this only covers the mint; the actual call happens on
280
+ // a direct browser-to-Persona WebSocket this runtime never sees.
281
+ },
276
282
  },
277
283
  });
278
284
  ```
package/dist/index.cjs CHANGED
@@ -743,6 +743,18 @@ var resetThread = async (_request, ctx) => {
743
743
  return json(200, thread);
744
744
  };
745
745
 
746
+ // src/routes/voice.ts
747
+ var createVoiceSession = async (request, ctx) => {
748
+ const body = requireBodyObject(request.body);
749
+ const agentId = requireStringField(body, "agentId");
750
+ const ticket = await ctx.client.voice.createSession(agentId);
751
+ await ctx.hooks?.onVoiceSessionCreate?.({
752
+ userId: request.userId,
753
+ agentId
754
+ });
755
+ return json(201, ticket);
756
+ };
757
+
746
758
  // src/routes/agents.ts
747
759
  var listAgents = async (request, ctx) => {
748
760
  const items = await ctx.client.agents.list({
@@ -1284,6 +1296,10 @@ function buildRoutes(capabilities) {
1284
1296
  { method: "DELETE", pattern: ["threads", ":id"], handler: deleteThread },
1285
1297
  { method: "GET", pattern: ["threads", ":id", "messages"], handler: getThreadMessages },
1286
1298
  { method: "POST", pattern: ["threads", ":id", "reset"], handler: resetThread },
1299
+ // Voice — always on, end-user-scoped real-time voice sessions
1300
+ // (powered by Gemini Live). Mints a ticket only; the host's own
1301
+ // frontend opens the WebSocket directly, this runtime never proxies it.
1302
+ { method: "POST", pattern: ["voice", "sessions"], handler: createVoiceSession },
1287
1303
  // Agents — read-only discovery always on; write ops behind agentsWrite.
1288
1304
  { method: "GET", pattern: ["agents"], handler: listAgents },
1289
1305
  // Files — always on, end-user-scoped uploads.