@personaai/runtime 0.21.0 → 0.23.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 +613 -453
- package/dist/index.cjs +923 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +145 -3
- package/dist/index.d.ts +145 -3
- package/dist/index.js +928 -21
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ChatMessageInput, CreateRestToolInput, LogLevel, Logger } from '@personaai/sdk';
|
|
1
|
+
import { ChatMessageInput, CreateRestToolInput, AgentEnvironment, LogLevel, Logger } from '@personaai/sdk';
|
|
2
|
+
import { WebhookEventType, WebhookEvent } from '@personaai/sdk/webhooks';
|
|
2
3
|
import { RcpTool } from 'rcp-sdk';
|
|
3
4
|
export { RcpTool } from 'rcp-sdk';
|
|
4
5
|
|
|
@@ -39,6 +40,12 @@ interface RuntimeRequest {
|
|
|
39
40
|
* auth-required route handler sees it.
|
|
40
41
|
*/
|
|
41
42
|
userId: string | null;
|
|
43
|
+
/**
|
|
44
|
+
* The exact request body bytes, before JSON parsing. Only needed by
|
|
45
|
+
* `POST /webhooks/persona` (the signature is over the raw bytes, and a
|
|
46
|
+
* re-serialised body won't match); adapters set it for that route.
|
|
47
|
+
*/
|
|
48
|
+
rawBody?: Uint8Array | string;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
/** A complete response with a known-length body — every route except streaming chat. */
|
|
@@ -78,6 +85,10 @@ interface RunContext {
|
|
|
78
85
|
messages?: ChatMessageInput[];
|
|
79
86
|
/** Input parameters provided to the workflow run. */
|
|
80
87
|
input?: unknown;
|
|
88
|
+
/** The environment this run asked for (from `selectVersion`, `defaultEnvironment` or the client). */
|
|
89
|
+
environment?: 'development' | 'production';
|
|
90
|
+
/** The published version this run asked for. */
|
|
91
|
+
agentVersion?: number;
|
|
81
92
|
}
|
|
82
93
|
interface RunResult {
|
|
83
94
|
/** Assembled assistant text (concatenated TEXT_MESSAGE_CHUNK deltas), same as `ChatResult.text`. */
|
|
@@ -87,6 +98,14 @@ interface RunResult {
|
|
|
87
98
|
interrupted: boolean;
|
|
88
99
|
/** True when a RUN_ERROR event was seen — the run still completed (as far as the stream is concerned); see README on the `onError` vs `erroredInBand` distinction. */
|
|
89
100
|
erroredInBand: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Persona's own id for this run (`RUN_STARTED.runId`): what
|
|
103
|
+
* `POST /feedback` and `client.traces.getByRunId()` take. Not the
|
|
104
|
+
* runtime's `x-persona-run-id` resume id.
|
|
105
|
+
*/
|
|
106
|
+
personaRunId?: string;
|
|
107
|
+
/** The run's thread (also set when the run created one). */
|
|
108
|
+
threadId?: string;
|
|
90
109
|
}
|
|
91
110
|
interface ErrorContext {
|
|
92
111
|
userId: string | null;
|
|
@@ -128,11 +147,31 @@ interface MemoryWriteContext {
|
|
|
128
147
|
agentId?: string;
|
|
129
148
|
path: string;
|
|
130
149
|
}
|
|
150
|
+
interface FeedbackContext {
|
|
151
|
+
userId: string;
|
|
152
|
+
/** Persona's run id the rating is for. */
|
|
153
|
+
runId: string;
|
|
154
|
+
score: 1 | -1;
|
|
155
|
+
comment?: string;
|
|
156
|
+
tags?: string[];
|
|
157
|
+
}
|
|
158
|
+
/** A Project-wide admin action taken through an admin capability (deploy, traces, evals). */
|
|
159
|
+
interface AdminActionContext {
|
|
160
|
+
/** Your user who did it (Persona's audit log only knows the API key). */
|
|
161
|
+
userId: string;
|
|
162
|
+
capability: 'deploy' | 'traces' | 'evals';
|
|
163
|
+
/** e.g. `agent.version.deploy`, `trace.replay`, `eval_run.start`. */
|
|
164
|
+
action: string;
|
|
165
|
+
/** Ids the action touched. */
|
|
166
|
+
target: Record<string, unknown>;
|
|
167
|
+
}
|
|
131
168
|
interface VoiceSessionCreateContext {
|
|
132
169
|
userId: string;
|
|
133
170
|
agentId: string;
|
|
134
171
|
/** Set when the session resumed an existing conversation (optional `threadId` on the request). */
|
|
135
172
|
threadId?: string;
|
|
173
|
+
environment?: 'development' | 'production';
|
|
174
|
+
agentVersion?: number;
|
|
136
175
|
}
|
|
137
176
|
/**
|
|
138
177
|
* Lifecycle hooks — the host application's voice inside the runtime's
|
|
@@ -163,6 +202,15 @@ interface RuntimeHooks {
|
|
|
163
202
|
onThreadCreate?(ctx: ThreadCreateContext): void | Promise<void>;
|
|
164
203
|
/** Fires after a memory file is written via `PUT /memory/file`. */
|
|
165
204
|
onMemoryWrite?(ctx: MemoryWriteContext): void | Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* Fires after a Project-wide change or replay through an admin capability
|
|
207
|
+
* (publish, deploy, rollback, serve policy, replay, eval run and dataset
|
|
208
|
+
* changes). Persona's audit log names only the API key, so record your
|
|
209
|
+
* user here.
|
|
210
|
+
*/
|
|
211
|
+
onAdminAction?(ctx: AdminActionContext): void | Promise<void>;
|
|
212
|
+
/** Fires after an end user's rating is saved via `POST /feedback`. */
|
|
213
|
+
onFeedback?(ctx: FeedbackContext): void | Promise<void>;
|
|
166
214
|
/** Fires after a voice session ticket is minted via `POST /voice/sessions`. */
|
|
167
215
|
onVoiceSessionCreate?(ctx: VoiceSessionCreateContext): void | Promise<void>;
|
|
168
216
|
}
|
|
@@ -224,6 +272,69 @@ interface RuntimeCapabilities {
|
|
|
224
272
|
* end-user-scoped. @default false
|
|
225
273
|
*/
|
|
226
274
|
messages?: boolean;
|
|
275
|
+
/** Project secrets (`/secrets`) — write-only values, but creating/rotating them is configuration. @default false */
|
|
276
|
+
secrets?: boolean;
|
|
277
|
+
/** REST tool sources (`/rest-tool-sources`) CRUD + Test Connection. @default false */
|
|
278
|
+
restToolSources?: boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Agent versions (`/agents/:id/versions`, `/agents/:id/deployments`):
|
|
281
|
+
* publish, diff, stats, deploy, rollback, serve policy. Key scope
|
|
282
|
+
* `deploy:write`. @default false
|
|
283
|
+
*/
|
|
284
|
+
deploy?: boolean;
|
|
285
|
+
/** Traces and replays (`/traces`): every end user's conversations. Key scope `traces:read` (+ `agent:invoke` to replay). @default false */
|
|
286
|
+
traces?: boolean;
|
|
287
|
+
/** Datasets and eval runs (`/datasets`, `/eval-runs`). Key scope `eval:run`. @default false */
|
|
288
|
+
evals?: boolean;
|
|
289
|
+
/** Budget status and usage stats (`/observe/budget`, `/observe/usage`), read-only. Key scope `traces:read`. @default false */
|
|
290
|
+
observe?: boolean;
|
|
291
|
+
}
|
|
292
|
+
/** What {@link CreateRuntimeOptions.selectVersion} is asked about. */
|
|
293
|
+
interface VersionSelectionContext {
|
|
294
|
+
userId: string;
|
|
295
|
+
agentId: string;
|
|
296
|
+
/** Which route is starting the run. */
|
|
297
|
+
kind: 'chat' | 'voice';
|
|
298
|
+
}
|
|
299
|
+
/** Which published version of an Agent a run uses. Empty = the Agent's own default. */
|
|
300
|
+
interface VersionSelection {
|
|
301
|
+
environment?: AgentEnvironment;
|
|
302
|
+
/** A published version number; wins over `environment`. */
|
|
303
|
+
agentVersion?: number;
|
|
304
|
+
}
|
|
305
|
+
/** Handler for one Persona webhook event type. Throw to answer 500, so Persona retries. */
|
|
306
|
+
type WebhookHandler = (event: WebhookEvent, delivery: WebhookDelivery) => void | Promise<void>;
|
|
307
|
+
interface WebhookDelivery {
|
|
308
|
+
/** `X-Persona-Delivery` — the same on every retry of one delivery. */
|
|
309
|
+
id: string | undefined;
|
|
310
|
+
/** `X-Persona-Event`. */
|
|
311
|
+
type: WebhookEventType;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Receives Persona's outgoing webhooks (Platform → Observe → Webhooks) at
|
|
315
|
+
* `POST {mountPath}/webhooks/persona`. Public route: it checks
|
|
316
|
+
* `X-Persona-Signature` (HMAC-SHA256 over the raw body) instead of
|
|
317
|
+
* `resolveUser`. Needs the adapter to put the raw body on
|
|
318
|
+
* `RuntimeRequest.rawBody`.
|
|
319
|
+
*/
|
|
320
|
+
interface WebhooksOptions {
|
|
321
|
+
/** The endpoint's signing secret (`whsec_…`, shown once when you create the webhook). */
|
|
322
|
+
secret: string;
|
|
323
|
+
/** One handler per event type, and/or `'*'` for every event. */
|
|
324
|
+
on: Partial<Record<WebhookEventType | '*', WebhookHandler>>;
|
|
325
|
+
/** Reject deliveries whose signature timestamp is further than this from now. @default 300 */
|
|
326
|
+
toleranceSec?: number;
|
|
327
|
+
/**
|
|
328
|
+
* Where handled delivery ids are remembered, so a retried delivery
|
|
329
|
+
* (same `X-Persona-Delivery`) runs your handler once. `add` is called
|
|
330
|
+
* only after the handlers succeed. The default keeps the last 1000 ids
|
|
331
|
+
* in memory (one process); use your database or Redis when running
|
|
332
|
+
* several instances.
|
|
333
|
+
*/
|
|
334
|
+
dedupe?: {
|
|
335
|
+
has(deliveryId: string): boolean | Promise<boolean>;
|
|
336
|
+
add(deliveryId: string): void | Promise<void>;
|
|
337
|
+
};
|
|
227
338
|
}
|
|
228
339
|
/**
|
|
229
340
|
* Serves a list of code-defined REST tools (built with `defineRestTool`
|
|
@@ -381,6 +492,34 @@ interface CreateRuntimeOptions {
|
|
|
381
492
|
* this is provided.
|
|
382
493
|
*/
|
|
383
494
|
channels?: ChannelsOptions;
|
|
495
|
+
/**
|
|
496
|
+
* Picks the published version a run uses, per request — canaries, beta
|
|
497
|
+
* users on `development`, pinning one customer to a version. Applies to
|
|
498
|
+
* `/chat` and `/voice/sessions`. Return `undefined` for the default.
|
|
499
|
+
*/
|
|
500
|
+
selectVersion?: (ctx: VersionSelectionContext) => VersionSelection | undefined | Promise<VersionSelection | undefined>;
|
|
501
|
+
/**
|
|
502
|
+
* Shortcut for `selectVersion: () => ({ environment })`. Without either,
|
|
503
|
+
* an Agent runs its editable **draft** for your end users unless its
|
|
504
|
+
* "serve only deployed versions" policy is on — set this to
|
|
505
|
+
* `'production'` for a production app. `selectVersion` wins when both are set.
|
|
506
|
+
*/
|
|
507
|
+
defaultEnvironment?: AgentEnvironment;
|
|
508
|
+
/**
|
|
509
|
+
* Lets the browser choose with `environment` / `agentVersion` in the
|
|
510
|
+
* `/chat` and `/voice/sessions` body (e.g. an internal preview build).
|
|
511
|
+
* Off by default: otherwise any end user could run an unreleased version.
|
|
512
|
+
* When on, the browser's choice wins over `selectVersion`.
|
|
513
|
+
* @default false
|
|
514
|
+
*/
|
|
515
|
+
allowClientVersionSelection?: boolean;
|
|
516
|
+
/**
|
|
517
|
+
* Forward the incoming `traceparent` header to Persona on `/chat`, so the
|
|
518
|
+
* run's spans join your own OpenTelemetry trace. @default true
|
|
519
|
+
*/
|
|
520
|
+
forwardTraceparent?: boolean;
|
|
521
|
+
/** Receive Persona webhooks at `POST /webhooks/persona`. See {@link WebhooksOptions}. Unset by default. */
|
|
522
|
+
webhooks?: WebhooksOptions;
|
|
384
523
|
/** Log level for the runtime — off by default. Overrides the global level set via `setLogLevel()` from `@personaai/sdk`. */
|
|
385
524
|
logLevel?: LogLevel;
|
|
386
525
|
/** Custom logger instance — when provided, `logLevel` is ignored. */
|
|
@@ -407,6 +546,9 @@ declare class RuntimeHttpError extends Error {
|
|
|
407
546
|
constructor(status: number, code: string, message: string);
|
|
408
547
|
}
|
|
409
548
|
|
|
410
|
-
declare const RUNTIME_VERSION = "0.
|
|
549
|
+
declare const RUNTIME_VERSION = "0.23.0";
|
|
550
|
+
|
|
551
|
+
/** The API key scope each capability needs (`*` covers everything). */
|
|
552
|
+
declare const CAPABILITY_SCOPES: Record<keyof RuntimeCapabilities, string[]>;
|
|
411
553
|
|
|
412
|
-
export { type ChannelsOptions, type CreateRuntimeOptions, type ErrorContext, type FileUploadContext, type MemoryWriteContext, RUNTIME_VERSION, type RcpManifestOptions, type ResolveTwilioChannelUser, 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 TwilioChannelOptions, type TwilioChannelRequest, type TwilioChannelUser, type VoiceSessionCreateContext, type WorkflowNodeContext, createRuntime };
|
|
554
|
+
export { type AdminActionContext, CAPABILITY_SCOPES, type ChannelsOptions, type CreateRuntimeOptions, type ErrorContext, type FeedbackContext, type FileUploadContext, type MemoryWriteContext, RUNTIME_VERSION, type RcpManifestOptions, type ResolveTwilioChannelUser, 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 TwilioChannelOptions, type TwilioChannelRequest, type TwilioChannelUser, type VersionSelection, type VersionSelectionContext, type VoiceSessionCreateContext, type WebhookDelivery, type WebhookHandler, type WebhooksOptions, type WorkflowNodeContext, createRuntime };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ChatMessageInput, CreateRestToolInput, LogLevel, Logger } from '@personaai/sdk';
|
|
1
|
+
import { ChatMessageInput, CreateRestToolInput, AgentEnvironment, LogLevel, Logger } from '@personaai/sdk';
|
|
2
|
+
import { WebhookEventType, WebhookEvent } from '@personaai/sdk/webhooks';
|
|
2
3
|
import { RcpTool } from 'rcp-sdk';
|
|
3
4
|
export { RcpTool } from 'rcp-sdk';
|
|
4
5
|
|
|
@@ -39,6 +40,12 @@ interface RuntimeRequest {
|
|
|
39
40
|
* auth-required route handler sees it.
|
|
40
41
|
*/
|
|
41
42
|
userId: string | null;
|
|
43
|
+
/**
|
|
44
|
+
* The exact request body bytes, before JSON parsing. Only needed by
|
|
45
|
+
* `POST /webhooks/persona` (the signature is over the raw bytes, and a
|
|
46
|
+
* re-serialised body won't match); adapters set it for that route.
|
|
47
|
+
*/
|
|
48
|
+
rawBody?: Uint8Array | string;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
/** A complete response with a known-length body — every route except streaming chat. */
|
|
@@ -78,6 +85,10 @@ interface RunContext {
|
|
|
78
85
|
messages?: ChatMessageInput[];
|
|
79
86
|
/** Input parameters provided to the workflow run. */
|
|
80
87
|
input?: unknown;
|
|
88
|
+
/** The environment this run asked for (from `selectVersion`, `defaultEnvironment` or the client). */
|
|
89
|
+
environment?: 'development' | 'production';
|
|
90
|
+
/** The published version this run asked for. */
|
|
91
|
+
agentVersion?: number;
|
|
81
92
|
}
|
|
82
93
|
interface RunResult {
|
|
83
94
|
/** Assembled assistant text (concatenated TEXT_MESSAGE_CHUNK deltas), same as `ChatResult.text`. */
|
|
@@ -87,6 +98,14 @@ interface RunResult {
|
|
|
87
98
|
interrupted: boolean;
|
|
88
99
|
/** True when a RUN_ERROR event was seen — the run still completed (as far as the stream is concerned); see README on the `onError` vs `erroredInBand` distinction. */
|
|
89
100
|
erroredInBand: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Persona's own id for this run (`RUN_STARTED.runId`): what
|
|
103
|
+
* `POST /feedback` and `client.traces.getByRunId()` take. Not the
|
|
104
|
+
* runtime's `x-persona-run-id` resume id.
|
|
105
|
+
*/
|
|
106
|
+
personaRunId?: string;
|
|
107
|
+
/** The run's thread (also set when the run created one). */
|
|
108
|
+
threadId?: string;
|
|
90
109
|
}
|
|
91
110
|
interface ErrorContext {
|
|
92
111
|
userId: string | null;
|
|
@@ -128,11 +147,31 @@ interface MemoryWriteContext {
|
|
|
128
147
|
agentId?: string;
|
|
129
148
|
path: string;
|
|
130
149
|
}
|
|
150
|
+
interface FeedbackContext {
|
|
151
|
+
userId: string;
|
|
152
|
+
/** Persona's run id the rating is for. */
|
|
153
|
+
runId: string;
|
|
154
|
+
score: 1 | -1;
|
|
155
|
+
comment?: string;
|
|
156
|
+
tags?: string[];
|
|
157
|
+
}
|
|
158
|
+
/** A Project-wide admin action taken through an admin capability (deploy, traces, evals). */
|
|
159
|
+
interface AdminActionContext {
|
|
160
|
+
/** Your user who did it (Persona's audit log only knows the API key). */
|
|
161
|
+
userId: string;
|
|
162
|
+
capability: 'deploy' | 'traces' | 'evals';
|
|
163
|
+
/** e.g. `agent.version.deploy`, `trace.replay`, `eval_run.start`. */
|
|
164
|
+
action: string;
|
|
165
|
+
/** Ids the action touched. */
|
|
166
|
+
target: Record<string, unknown>;
|
|
167
|
+
}
|
|
131
168
|
interface VoiceSessionCreateContext {
|
|
132
169
|
userId: string;
|
|
133
170
|
agentId: string;
|
|
134
171
|
/** Set when the session resumed an existing conversation (optional `threadId` on the request). */
|
|
135
172
|
threadId?: string;
|
|
173
|
+
environment?: 'development' | 'production';
|
|
174
|
+
agentVersion?: number;
|
|
136
175
|
}
|
|
137
176
|
/**
|
|
138
177
|
* Lifecycle hooks — the host application's voice inside the runtime's
|
|
@@ -163,6 +202,15 @@ interface RuntimeHooks {
|
|
|
163
202
|
onThreadCreate?(ctx: ThreadCreateContext): void | Promise<void>;
|
|
164
203
|
/** Fires after a memory file is written via `PUT /memory/file`. */
|
|
165
204
|
onMemoryWrite?(ctx: MemoryWriteContext): void | Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* Fires after a Project-wide change or replay through an admin capability
|
|
207
|
+
* (publish, deploy, rollback, serve policy, replay, eval run and dataset
|
|
208
|
+
* changes). Persona's audit log names only the API key, so record your
|
|
209
|
+
* user here.
|
|
210
|
+
*/
|
|
211
|
+
onAdminAction?(ctx: AdminActionContext): void | Promise<void>;
|
|
212
|
+
/** Fires after an end user's rating is saved via `POST /feedback`. */
|
|
213
|
+
onFeedback?(ctx: FeedbackContext): void | Promise<void>;
|
|
166
214
|
/** Fires after a voice session ticket is minted via `POST /voice/sessions`. */
|
|
167
215
|
onVoiceSessionCreate?(ctx: VoiceSessionCreateContext): void | Promise<void>;
|
|
168
216
|
}
|
|
@@ -224,6 +272,69 @@ interface RuntimeCapabilities {
|
|
|
224
272
|
* end-user-scoped. @default false
|
|
225
273
|
*/
|
|
226
274
|
messages?: boolean;
|
|
275
|
+
/** Project secrets (`/secrets`) — write-only values, but creating/rotating them is configuration. @default false */
|
|
276
|
+
secrets?: boolean;
|
|
277
|
+
/** REST tool sources (`/rest-tool-sources`) CRUD + Test Connection. @default false */
|
|
278
|
+
restToolSources?: boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Agent versions (`/agents/:id/versions`, `/agents/:id/deployments`):
|
|
281
|
+
* publish, diff, stats, deploy, rollback, serve policy. Key scope
|
|
282
|
+
* `deploy:write`. @default false
|
|
283
|
+
*/
|
|
284
|
+
deploy?: boolean;
|
|
285
|
+
/** Traces and replays (`/traces`): every end user's conversations. Key scope `traces:read` (+ `agent:invoke` to replay). @default false */
|
|
286
|
+
traces?: boolean;
|
|
287
|
+
/** Datasets and eval runs (`/datasets`, `/eval-runs`). Key scope `eval:run`. @default false */
|
|
288
|
+
evals?: boolean;
|
|
289
|
+
/** Budget status and usage stats (`/observe/budget`, `/observe/usage`), read-only. Key scope `traces:read`. @default false */
|
|
290
|
+
observe?: boolean;
|
|
291
|
+
}
|
|
292
|
+
/** What {@link CreateRuntimeOptions.selectVersion} is asked about. */
|
|
293
|
+
interface VersionSelectionContext {
|
|
294
|
+
userId: string;
|
|
295
|
+
agentId: string;
|
|
296
|
+
/** Which route is starting the run. */
|
|
297
|
+
kind: 'chat' | 'voice';
|
|
298
|
+
}
|
|
299
|
+
/** Which published version of an Agent a run uses. Empty = the Agent's own default. */
|
|
300
|
+
interface VersionSelection {
|
|
301
|
+
environment?: AgentEnvironment;
|
|
302
|
+
/** A published version number; wins over `environment`. */
|
|
303
|
+
agentVersion?: number;
|
|
304
|
+
}
|
|
305
|
+
/** Handler for one Persona webhook event type. Throw to answer 500, so Persona retries. */
|
|
306
|
+
type WebhookHandler = (event: WebhookEvent, delivery: WebhookDelivery) => void | Promise<void>;
|
|
307
|
+
interface WebhookDelivery {
|
|
308
|
+
/** `X-Persona-Delivery` — the same on every retry of one delivery. */
|
|
309
|
+
id: string | undefined;
|
|
310
|
+
/** `X-Persona-Event`. */
|
|
311
|
+
type: WebhookEventType;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Receives Persona's outgoing webhooks (Platform → Observe → Webhooks) at
|
|
315
|
+
* `POST {mountPath}/webhooks/persona`. Public route: it checks
|
|
316
|
+
* `X-Persona-Signature` (HMAC-SHA256 over the raw body) instead of
|
|
317
|
+
* `resolveUser`. Needs the adapter to put the raw body on
|
|
318
|
+
* `RuntimeRequest.rawBody`.
|
|
319
|
+
*/
|
|
320
|
+
interface WebhooksOptions {
|
|
321
|
+
/** The endpoint's signing secret (`whsec_…`, shown once when you create the webhook). */
|
|
322
|
+
secret: string;
|
|
323
|
+
/** One handler per event type, and/or `'*'` for every event. */
|
|
324
|
+
on: Partial<Record<WebhookEventType | '*', WebhookHandler>>;
|
|
325
|
+
/** Reject deliveries whose signature timestamp is further than this from now. @default 300 */
|
|
326
|
+
toleranceSec?: number;
|
|
327
|
+
/**
|
|
328
|
+
* Where handled delivery ids are remembered, so a retried delivery
|
|
329
|
+
* (same `X-Persona-Delivery`) runs your handler once. `add` is called
|
|
330
|
+
* only after the handlers succeed. The default keeps the last 1000 ids
|
|
331
|
+
* in memory (one process); use your database or Redis when running
|
|
332
|
+
* several instances.
|
|
333
|
+
*/
|
|
334
|
+
dedupe?: {
|
|
335
|
+
has(deliveryId: string): boolean | Promise<boolean>;
|
|
336
|
+
add(deliveryId: string): void | Promise<void>;
|
|
337
|
+
};
|
|
227
338
|
}
|
|
228
339
|
/**
|
|
229
340
|
* Serves a list of code-defined REST tools (built with `defineRestTool`
|
|
@@ -381,6 +492,34 @@ interface CreateRuntimeOptions {
|
|
|
381
492
|
* this is provided.
|
|
382
493
|
*/
|
|
383
494
|
channels?: ChannelsOptions;
|
|
495
|
+
/**
|
|
496
|
+
* Picks the published version a run uses, per request — canaries, beta
|
|
497
|
+
* users on `development`, pinning one customer to a version. Applies to
|
|
498
|
+
* `/chat` and `/voice/sessions`. Return `undefined` for the default.
|
|
499
|
+
*/
|
|
500
|
+
selectVersion?: (ctx: VersionSelectionContext) => VersionSelection | undefined | Promise<VersionSelection | undefined>;
|
|
501
|
+
/**
|
|
502
|
+
* Shortcut for `selectVersion: () => ({ environment })`. Without either,
|
|
503
|
+
* an Agent runs its editable **draft** for your end users unless its
|
|
504
|
+
* "serve only deployed versions" policy is on — set this to
|
|
505
|
+
* `'production'` for a production app. `selectVersion` wins when both are set.
|
|
506
|
+
*/
|
|
507
|
+
defaultEnvironment?: AgentEnvironment;
|
|
508
|
+
/**
|
|
509
|
+
* Lets the browser choose with `environment` / `agentVersion` in the
|
|
510
|
+
* `/chat` and `/voice/sessions` body (e.g. an internal preview build).
|
|
511
|
+
* Off by default: otherwise any end user could run an unreleased version.
|
|
512
|
+
* When on, the browser's choice wins over `selectVersion`.
|
|
513
|
+
* @default false
|
|
514
|
+
*/
|
|
515
|
+
allowClientVersionSelection?: boolean;
|
|
516
|
+
/**
|
|
517
|
+
* Forward the incoming `traceparent` header to Persona on `/chat`, so the
|
|
518
|
+
* run's spans join your own OpenTelemetry trace. @default true
|
|
519
|
+
*/
|
|
520
|
+
forwardTraceparent?: boolean;
|
|
521
|
+
/** Receive Persona webhooks at `POST /webhooks/persona`. See {@link WebhooksOptions}. Unset by default. */
|
|
522
|
+
webhooks?: WebhooksOptions;
|
|
384
523
|
/** Log level for the runtime — off by default. Overrides the global level set via `setLogLevel()` from `@personaai/sdk`. */
|
|
385
524
|
logLevel?: LogLevel;
|
|
386
525
|
/** Custom logger instance — when provided, `logLevel` is ignored. */
|
|
@@ -407,6 +546,9 @@ declare class RuntimeHttpError extends Error {
|
|
|
407
546
|
constructor(status: number, code: string, message: string);
|
|
408
547
|
}
|
|
409
548
|
|
|
410
|
-
declare const RUNTIME_VERSION = "0.
|
|
549
|
+
declare const RUNTIME_VERSION = "0.23.0";
|
|
550
|
+
|
|
551
|
+
/** The API key scope each capability needs (`*` covers everything). */
|
|
552
|
+
declare const CAPABILITY_SCOPES: Record<keyof RuntimeCapabilities, string[]>;
|
|
411
553
|
|
|
412
|
-
export { type ChannelsOptions, type CreateRuntimeOptions, type ErrorContext, type FileUploadContext, type MemoryWriteContext, RUNTIME_VERSION, type RcpManifestOptions, type ResolveTwilioChannelUser, 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 TwilioChannelOptions, type TwilioChannelRequest, type TwilioChannelUser, type VoiceSessionCreateContext, type WorkflowNodeContext, createRuntime };
|
|
554
|
+
export { type AdminActionContext, CAPABILITY_SCOPES, type ChannelsOptions, type CreateRuntimeOptions, type ErrorContext, type FeedbackContext, type FileUploadContext, type MemoryWriteContext, RUNTIME_VERSION, type RcpManifestOptions, type ResolveTwilioChannelUser, 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 TwilioChannelOptions, type TwilioChannelRequest, type TwilioChannelUser, type VersionSelection, type VersionSelectionContext, type VoiceSessionCreateContext, type WebhookDelivery, type WebhookHandler, type WebhooksOptions, type WorkflowNodeContext, createRuntime };
|