@personaai/runtime 0.6.0 → 0.7.1

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.d.cts CHANGED
@@ -113,6 +113,12 @@ interface MemoryWriteContext {
113
113
  agentId?: string;
114
114
  path: string;
115
115
  }
116
+ interface VoiceSessionCreateContext {
117
+ userId: string;
118
+ agentId: string;
119
+ /** Set when the session resumed an existing conversation (optional `threadId` on the request). */
120
+ threadId?: string;
121
+ }
116
122
  /**
117
123
  * Lifecycle hooks — the host application's voice inside the runtime's
118
124
  * request handling. Plain async event listeners, not middleware: the
@@ -138,6 +144,8 @@ interface RuntimeHooks {
138
144
  onThreadCreate?(ctx: ThreadCreateContext): void | Promise<void>;
139
145
  /** Fires after a memory file is written via `PUT /memory/file`. */
140
146
  onMemoryWrite?(ctx: MemoryWriteContext): void | Promise<void>;
147
+ /** Fires after a voice session ticket is minted via `POST /voice/sessions`. */
148
+ onVoiceSessionCreate?(ctx: VoiceSessionCreateContext): void | Promise<void>;
141
149
  }
142
150
 
143
151
  /**
@@ -248,4 +256,4 @@ declare class RuntimeHttpError extends Error {
248
256
 
249
257
  declare const RUNTIME_VERSION = "0.5.4";
250
258
 
251
- export { type CreateRuntimeOptions, type ErrorContext, type FileUploadContext, type MemoryWriteContext, RUNTIME_VERSION, type ResolveUser, type RunContext, type RunResult, type Runtime, type RuntimeBinaryResponse, type RuntimeBufferedResponse, type RuntimeCapabilities, type RuntimeHooks, RuntimeHttpError, type RuntimeMethod, type RuntimeRequest, type RuntimeResponse, type RuntimeStreamResponse, type RuntimeUploadedFile, type ThreadCreateContext, type ToolCallContext, createRuntime };
259
+ export { type CreateRuntimeOptions, type ErrorContext, type FileUploadContext, type MemoryWriteContext, RUNTIME_VERSION, type ResolveUser, type RunContext, type RunResult, type Runtime, type RuntimeBinaryResponse, type RuntimeBufferedResponse, type RuntimeCapabilities, type RuntimeHooks, RuntimeHttpError, type RuntimeMethod, type RuntimeRequest, type RuntimeResponse, type RuntimeStreamResponse, type RuntimeUploadedFile, type ThreadCreateContext, type ToolCallContext, type VoiceSessionCreateContext, createRuntime };
package/dist/index.d.ts CHANGED
@@ -113,6 +113,12 @@ interface MemoryWriteContext {
113
113
  agentId?: string;
114
114
  path: string;
115
115
  }
116
+ interface VoiceSessionCreateContext {
117
+ userId: string;
118
+ agentId: string;
119
+ /** Set when the session resumed an existing conversation (optional `threadId` on the request). */
120
+ threadId?: string;
121
+ }
116
122
  /**
117
123
  * Lifecycle hooks — the host application's voice inside the runtime's
118
124
  * request handling. Plain async event listeners, not middleware: the
@@ -138,6 +144,8 @@ interface RuntimeHooks {
138
144
  onThreadCreate?(ctx: ThreadCreateContext): void | Promise<void>;
139
145
  /** Fires after a memory file is written via `PUT /memory/file`. */
140
146
  onMemoryWrite?(ctx: MemoryWriteContext): void | Promise<void>;
147
+ /** Fires after a voice session ticket is minted via `POST /voice/sessions`. */
148
+ onVoiceSessionCreate?(ctx: VoiceSessionCreateContext): void | Promise<void>;
141
149
  }
142
150
 
143
151
  /**
@@ -248,4 +256,4 @@ declare class RuntimeHttpError extends Error {
248
256
 
249
257
  declare const RUNTIME_VERSION = "0.5.4";
250
258
 
251
- export { type CreateRuntimeOptions, type ErrorContext, type FileUploadContext, type MemoryWriteContext, RUNTIME_VERSION, type ResolveUser, type RunContext, type RunResult, type Runtime, type RuntimeBinaryResponse, type RuntimeBufferedResponse, type RuntimeCapabilities, type RuntimeHooks, RuntimeHttpError, type RuntimeMethod, type RuntimeRequest, type RuntimeResponse, type RuntimeStreamResponse, type RuntimeUploadedFile, type ThreadCreateContext, type ToolCallContext, createRuntime };
259
+ export { type CreateRuntimeOptions, type ErrorContext, type FileUploadContext, type MemoryWriteContext, RUNTIME_VERSION, type ResolveUser, type RunContext, type RunResult, type Runtime, type RuntimeBinaryResponse, type RuntimeBufferedResponse, type RuntimeCapabilities, type RuntimeHooks, RuntimeHttpError, type RuntimeMethod, type RuntimeRequest, type RuntimeResponse, type RuntimeStreamResponse, type RuntimeUploadedFile, type ThreadCreateContext, type ToolCallContext, type VoiceSessionCreateContext, createRuntime };
package/dist/index.js CHANGED
@@ -715,6 +715,20 @@ var resetThread = async (_request, ctx) => {
715
715
  return json(200, thread);
716
716
  };
717
717
 
718
+ // src/routes/voice.ts
719
+ var createVoiceSession = async (request, ctx) => {
720
+ const body = requireBodyObject(request.body);
721
+ const agentId = requireStringField(body, "agentId");
722
+ const threadId = typeof body.threadId === "string" && body.threadId ? body.threadId : void 0;
723
+ const ticket = await ctx.client.voice.createSession(agentId, threadId ? { threadId } : {});
724
+ await ctx.hooks?.onVoiceSessionCreate?.({
725
+ userId: request.userId,
726
+ agentId,
727
+ threadId
728
+ });
729
+ return json(201, ticket);
730
+ };
731
+
718
732
  // src/routes/agents.ts
719
733
  var listAgents = async (request, ctx) => {
720
734
  const items = await ctx.client.agents.list({
@@ -1256,6 +1270,10 @@ function buildRoutes(capabilities) {
1256
1270
  { method: "DELETE", pattern: ["threads", ":id"], handler: deleteThread },
1257
1271
  { method: "GET", pattern: ["threads", ":id", "messages"], handler: getThreadMessages },
1258
1272
  { method: "POST", pattern: ["threads", ":id", "reset"], handler: resetThread },
1273
+ // Voice — always on, end-user-scoped real-time voice sessions
1274
+ // (powered by Gemini Live). Mints a ticket only; the host's own
1275
+ // frontend opens the WebSocket directly, this runtime never proxies it.
1276
+ { method: "POST", pattern: ["voice", "sessions"], handler: createVoiceSession },
1259
1277
  // Agents — read-only discovery always on; write ops behind agentsWrite.
1260
1278
  { method: "GET", pattern: ["agents"], handler: listAgents },
1261
1279
  // Files — always on, end-user-scoped uploads.