@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/dist/index.d.cts CHANGED
@@ -113,6 +113,10 @@ interface MemoryWriteContext {
113
113
  agentId?: string;
114
114
  path: string;
115
115
  }
116
+ interface VoiceSessionCreateContext {
117
+ userId: string;
118
+ agentId: string;
119
+ }
116
120
  /**
117
121
  * Lifecycle hooks — the host application's voice inside the runtime's
118
122
  * request handling. Plain async event listeners, not middleware: the
@@ -138,6 +142,8 @@ interface RuntimeHooks {
138
142
  onThreadCreate?(ctx: ThreadCreateContext): void | Promise<void>;
139
143
  /** Fires after a memory file is written via `PUT /memory/file`. */
140
144
  onMemoryWrite?(ctx: MemoryWriteContext): void | Promise<void>;
145
+ /** Fires after a voice session ticket is minted via `POST /voice/sessions`. */
146
+ onVoiceSessionCreate?(ctx: VoiceSessionCreateContext): void | Promise<void>;
141
147
  }
142
148
 
143
149
  /**
@@ -248,4 +254,4 @@ declare class RuntimeHttpError extends Error {
248
254
 
249
255
  declare const RUNTIME_VERSION = "0.5.4";
250
256
 
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 };
257
+ 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,10 @@ interface MemoryWriteContext {
113
113
  agentId?: string;
114
114
  path: string;
115
115
  }
116
+ interface VoiceSessionCreateContext {
117
+ userId: string;
118
+ agentId: string;
119
+ }
116
120
  /**
117
121
  * Lifecycle hooks — the host application's voice inside the runtime's
118
122
  * request handling. Plain async event listeners, not middleware: the
@@ -138,6 +142,8 @@ interface RuntimeHooks {
138
142
  onThreadCreate?(ctx: ThreadCreateContext): void | Promise<void>;
139
143
  /** Fires after a memory file is written via `PUT /memory/file`. */
140
144
  onMemoryWrite?(ctx: MemoryWriteContext): void | Promise<void>;
145
+ /** Fires after a voice session ticket is minted via `POST /voice/sessions`. */
146
+ onVoiceSessionCreate?(ctx: VoiceSessionCreateContext): void | Promise<void>;
141
147
  }
142
148
 
143
149
  /**
@@ -248,4 +254,4 @@ declare class RuntimeHttpError extends Error {
248
254
 
249
255
  declare const RUNTIME_VERSION = "0.5.4";
250
256
 
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 };
257
+ 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,18 @@ 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 ticket = await ctx.client.voice.createSession(agentId);
723
+ await ctx.hooks?.onVoiceSessionCreate?.({
724
+ userId: request.userId,
725
+ agentId
726
+ });
727
+ return json(201, ticket);
728
+ };
729
+
718
730
  // src/routes/agents.ts
719
731
  var listAgents = async (request, ctx) => {
720
732
  const items = await ctx.client.agents.list({
@@ -1256,6 +1268,10 @@ function buildRoutes(capabilities) {
1256
1268
  { method: "DELETE", pattern: ["threads", ":id"], handler: deleteThread },
1257
1269
  { method: "GET", pattern: ["threads", ":id", "messages"], handler: getThreadMessages },
1258
1270
  { method: "POST", pattern: ["threads", ":id", "reset"], handler: resetThread },
1271
+ // Voice — always on, end-user-scoped real-time voice sessions
1272
+ // (powered by Gemini Live). Mints a ticket only; the host's own
1273
+ // frontend opens the WebSocket directly, this runtime never proxies it.
1274
+ { method: "POST", pattern: ["voice", "sessions"], handler: createVoiceSession },
1259
1275
  // Agents — read-only discovery always on; write ops behind agentsWrite.
1260
1276
  { method: "GET", pattern: ["agents"], handler: listAgents },
1261
1277
  // Files — always on, end-user-scoped uploads.