@personaai/runtime 0.8.0 → 0.9.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 +30 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
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) {
|
|
@@ -1459,6 +1479,14 @@ function createRuntime(options) {
|
|
|
1459
1479
|
requiresAuth: false
|
|
1460
1480
|
});
|
|
1461
1481
|
}
|
|
1482
|
+
if (options.rcpManifest) {
|
|
1483
|
+
routes.push({
|
|
1484
|
+
method: "GET",
|
|
1485
|
+
pattern: ["rcp", "manifest"],
|
|
1486
|
+
handler: rcpManifestRoute,
|
|
1487
|
+
requiresAuth: false
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1462
1490
|
const mode = resolveMode(options);
|
|
1463
1491
|
const heartbeatIntervalMs = options.heartbeatIntervalMs ?? 15e3;
|
|
1464
1492
|
const runGraceMs = options.runGraceMs ?? DEFAULT_RUN_GRACE_MS;
|
|
@@ -1625,7 +1653,8 @@ function createRuntime(options) {
|
|
|
1625
1653
|
runs,
|
|
1626
1654
|
capabilities,
|
|
1627
1655
|
logger: routeLogger,
|
|
1628
|
-
restToolsManifest: options.restToolsManifest
|
|
1656
|
+
restToolsManifest: options.restToolsManifest,
|
|
1657
|
+
rcpManifest: options.rcpManifest
|
|
1629
1658
|
});
|
|
1630
1659
|
const durationMs = Date.now() - startMs;
|
|
1631
1660
|
logger.info("handle succeeded", {
|