@personaai/runtime 0.8.0 → 0.9.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
@@ -1,4 +1,6 @@
1
1
  import { ChatMessageInput, CreateRestToolInput, LogLevel, Logger } from '@personaai/sdk';
2
+ import { RcpTool } from 'rcp-sdk';
3
+ export { RcpTool } from 'rcp-sdk';
2
4
 
3
5
  type RuntimeMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
4
6
  /** A single uploaded file — present on `RuntimeRequest.file` for a multipart `POST /files`. */
@@ -214,6 +216,25 @@ interface RestToolsManifestOptions {
214
216
  */
215
217
  authToken?: string;
216
218
  }
219
+ /**
220
+ * Serves a list of code-defined RCP (REST Connector Protocol, npm `rcp-sdk`)
221
+ * tools as a conformant `{ rcpVersion, auth, tools }` manifest at
222
+ * `GET {mountPath}/rcp/manifest` — register that URL as an RCP source and
223
+ * any RCP client (Persona included) discovers/calls these tools live.
224
+ * Independent of {@link RestToolsManifestOptions} — unrelated protocols,
225
+ * both servable from the same runtime instance if you want both.
226
+ */
227
+ interface RcpManifestOptions {
228
+ /** RCP tool definitions to serve — build each with `defineTool` from `rcp-sdk/server`. */
229
+ tools: RcpTool[];
230
+ /**
231
+ * Required `Authorization: Bearer <token>` value the manifest route
232
+ * checks incoming requests against. Omitting this leaves the route open
233
+ * (`auth: { type: 'none' }` in the served manifest) — only acceptable
234
+ * for local/dev testing.
235
+ */
236
+ authToken?: string;
237
+ }
217
238
  interface CreateRuntimeOptions {
218
239
  /** Base URL of the Persona Developer Platform API, e.g. "https://api.persona.hasanraiyan.me". */
219
240
  baseUrl: string;
@@ -258,6 +279,8 @@ interface CreateRuntimeOptions {
258
279
  capabilities?: RuntimeCapabilities;
259
280
  /** Serves a code-defined REST tool list for a Persona REST Tool Source to discover. See {@link RestToolsManifestOptions}. Unset by default — the route only exists when this is provided. */
260
281
  restToolsManifest?: RestToolsManifestOptions;
282
+ /** Serves a conformant RCP manifest for any RCP client to discover. See {@link RcpManifestOptions}. Unset by default — the route only exists when this is provided. */
283
+ rcpManifest?: RcpManifestOptions;
261
284
  /** Log level for the runtime — off by default. Overrides the global level set via `setLogLevel()` from `@personaai/sdk`. */
262
285
  logLevel?: LogLevel;
263
286
  /** Custom logger instance — when provided, `logLevel` is ignored. */
@@ -286,4 +309,4 @@ declare class RuntimeHttpError extends Error {
286
309
 
287
310
  declare const RUNTIME_VERSION = "0.5.4";
288
311
 
289
- export { type CreateRuntimeOptions, type ErrorContext, type FileUploadContext, type MemoryWriteContext, RUNTIME_VERSION, type ResolveUser, type RestToolManifestEntry, type RestToolsManifestOptions, 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 };
312
+ export { type CreateRuntimeOptions, type ErrorContext, type FileUploadContext, type MemoryWriteContext, RUNTIME_VERSION, type RcpManifestOptions, type ResolveUser, type RestToolManifestEntry, type RestToolsManifestOptions, 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
@@ -1,4 +1,6 @@
1
1
  import { ChatMessageInput, CreateRestToolInput, LogLevel, Logger } from '@personaai/sdk';
2
+ import { RcpTool } from 'rcp-sdk';
3
+ export { RcpTool } from 'rcp-sdk';
2
4
 
3
5
  type RuntimeMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
4
6
  /** A single uploaded file — present on `RuntimeRequest.file` for a multipart `POST /files`. */
@@ -214,6 +216,25 @@ interface RestToolsManifestOptions {
214
216
  */
215
217
  authToken?: string;
216
218
  }
219
+ /**
220
+ * Serves a list of code-defined RCP (REST Connector Protocol, npm `rcp-sdk`)
221
+ * tools as a conformant `{ rcpVersion, auth, tools }` manifest at
222
+ * `GET {mountPath}/rcp/manifest` — register that URL as an RCP source and
223
+ * any RCP client (Persona included) discovers/calls these tools live.
224
+ * Independent of {@link RestToolsManifestOptions} — unrelated protocols,
225
+ * both servable from the same runtime instance if you want both.
226
+ */
227
+ interface RcpManifestOptions {
228
+ /** RCP tool definitions to serve — build each with `defineTool` from `rcp-sdk/server`. */
229
+ tools: RcpTool[];
230
+ /**
231
+ * Required `Authorization: Bearer <token>` value the manifest route
232
+ * checks incoming requests against. Omitting this leaves the route open
233
+ * (`auth: { type: 'none' }` in the served manifest) — only acceptable
234
+ * for local/dev testing.
235
+ */
236
+ authToken?: string;
237
+ }
217
238
  interface CreateRuntimeOptions {
218
239
  /** Base URL of the Persona Developer Platform API, e.g. "https://api.persona.hasanraiyan.me". */
219
240
  baseUrl: string;
@@ -258,6 +279,8 @@ interface CreateRuntimeOptions {
258
279
  capabilities?: RuntimeCapabilities;
259
280
  /** Serves a code-defined REST tool list for a Persona REST Tool Source to discover. See {@link RestToolsManifestOptions}. Unset by default — the route only exists when this is provided. */
260
281
  restToolsManifest?: RestToolsManifestOptions;
282
+ /** Serves a conformant RCP manifest for any RCP client to discover. See {@link RcpManifestOptions}. Unset by default — the route only exists when this is provided. */
283
+ rcpManifest?: RcpManifestOptions;
261
284
  /** Log level for the runtime — off by default. Overrides the global level set via `setLogLevel()` from `@personaai/sdk`. */
262
285
  logLevel?: LogLevel;
263
286
  /** Custom logger instance — when provided, `logLevel` is ignored. */
@@ -286,4 +309,4 @@ declare class RuntimeHttpError extends Error {
286
309
 
287
310
  declare const RUNTIME_VERSION = "0.5.4";
288
311
 
289
- export { type CreateRuntimeOptions, type ErrorContext, type FileUploadContext, type MemoryWriteContext, RUNTIME_VERSION, type ResolveUser, type RestToolManifestEntry, type RestToolsManifestOptions, 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 };
312
+ export { type CreateRuntimeOptions, type ErrorContext, type FileUploadContext, type MemoryWriteContext, RUNTIME_VERSION, type RcpManifestOptions, type ResolveUser, type RestToolManifestEntry, type RestToolsManifestOptions, 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
@@ -226,6 +226,26 @@ var restToolsManifestRoute = async (request, ctx) => {
226
226
  return json(200, { tools: manifest.tools });
227
227
  };
228
228
 
229
+ // src/routes/rcpManifest.ts
230
+ var rcpManifestRoute = async (request, ctx) => {
231
+ const manifest = ctx.rcpManifest;
232
+ if (!manifest) {
233
+ throw new RuntimeHttpError(404, "NOT_FOUND", "No RCP manifest is configured.");
234
+ }
235
+ if (manifest.authToken) {
236
+ const header = request.headers.authorization;
237
+ const expected = `Bearer ${manifest.authToken}`;
238
+ if (header !== expected) {
239
+ throw new RuntimeHttpError(401, "UNAUTHORIZED", "Invalid or missing manifest bearer token.");
240
+ }
241
+ }
242
+ return json(200, {
243
+ rcpVersion: "0.1",
244
+ auth: manifest.authToken ? { type: "header", header: "Authorization", scheme: "Bearer" } : { type: "none" },
245
+ tools: manifest.tools
246
+ });
247
+ };
248
+
229
249
  // src/runDriver.ts
230
250
  import { EventType } from "@personaai/sdk";
231
251
  function formatSseFrame(event) {
@@ -736,7 +756,11 @@ var createVoiceSession = async (request, ctx) => {
736
756
  const body = requireBodyObject(request.body);
737
757
  const agentId = requireStringField(body, "agentId");
738
758
  const threadId = typeof body.threadId === "string" && body.threadId ? body.threadId : void 0;
739
- const ticket = await ctx.client.voice.createSession(agentId, threadId ? { threadId } : {});
759
+ const contextOverride = typeof body.contextOverride === "string" && body.contextOverride ? body.contextOverride : void 0;
760
+ const ticket = await ctx.client.voice.createSession(agentId, {
761
+ ...threadId ? { threadId } : {},
762
+ ...contextOverride ? { contextOverride } : {}
763
+ });
740
764
  await ctx.hooks?.onVoiceSessionCreate?.({
741
765
  userId: request.userId,
742
766
  agentId,
@@ -1459,6 +1483,14 @@ function createRuntime(options) {
1459
1483
  requiresAuth: false
1460
1484
  });
1461
1485
  }
1486
+ if (options.rcpManifest) {
1487
+ routes.push({
1488
+ method: "GET",
1489
+ pattern: ["rcp", "manifest"],
1490
+ handler: rcpManifestRoute,
1491
+ requiresAuth: false
1492
+ });
1493
+ }
1462
1494
  const mode = resolveMode(options);
1463
1495
  const heartbeatIntervalMs = options.heartbeatIntervalMs ?? 15e3;
1464
1496
  const runGraceMs = options.runGraceMs ?? DEFAULT_RUN_GRACE_MS;
@@ -1625,7 +1657,8 @@ function createRuntime(options) {
1625
1657
  runs,
1626
1658
  capabilities,
1627
1659
  logger: routeLogger,
1628
- restToolsManifest: options.restToolsManifest
1660
+ restToolsManifest: options.restToolsManifest,
1661
+ rcpManifest: options.rcpManifest
1629
1662
  });
1630
1663
  const durationMs = Date.now() - startMs;
1631
1664
  logger.info("handle succeeded", {