@personaai/runtime 0.23.0 → 0.24.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 +14 -8
- package/dist/index.cjs +40 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.js +40 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ shared engine every framework adapter (`@personaai/adapters/express`, `@personaa
|
|
|
5
5
|
to be a thin translation layer over — see
|
|
6
6
|
[the SDK Ecosystem plan](https://github.com/hasanraiyan/agent-marketplace/blob/feat/ai/product-research/11-sdk-new/package-ecosystem.md).
|
|
7
7
|
|
|
8
|
-
**v0.
|
|
8
|
+
**v0.24.0** (built on `@personaai/sdk` 0.27.0):
|
|
9
9
|
|
|
10
10
|
- **`POST /feedback`**: your end users rate a run 👍/👎 (with a comment and tags). Always on.
|
|
11
11
|
- **Which version runs**: `selectVersion` / `defaultEnvironment` pick the published version for
|
|
@@ -352,14 +352,20 @@ createRuntime({
|
|
|
352
352
|
});
|
|
353
353
|
```
|
|
354
354
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
(`@personaai/sdk` has no version option for them yet).
|
|
355
|
+
It applies to `/chat`, `/voice/sessions`, `/messages/agent` and workflow runs. For a workflow,
|
|
356
|
+
`selectVersion` gets `{ userId, kind: 'workflow', workflowId }` and the choice applies to every
|
|
357
|
+
agent step (steps that a published workflow version pins keep their snapshot). The last two need
|
|
358
|
+
`@personaai/sdk` 0.27 or newer.
|
|
360
359
|
|
|
361
|
-
|
|
362
|
-
`
|
|
360
|
+
The browser can't choose: `environment` / `agentVersion` in the request body (for workflows,
|
|
361
|
+
`agentEnvironment` / `agentVersion`) are ignored unless you set
|
|
362
|
+
`allowClientVersionSelection: true` (e.g. for an internal preview build). Otherwise any end user
|
|
363
|
+
could run an unreleased version. `beforeRun` / `afterRun` see the chosen `environment` /
|
|
364
|
+
`agentVersion` on their context.
|
|
365
|
+
|
|
366
|
+
A valid incoming `traceparent` header is forwarded (`forwardTraceparent`, default `true`) on
|
|
367
|
+
`/chat`, `/voice/sessions`, `/messages/agent` and workflow runs (the last three with
|
|
368
|
+
`@personaai/sdk` 0.27+), so those runs join your OpenTelemetry trace.
|
|
363
369
|
|
|
364
370
|
## Receiving Persona webhooks
|
|
365
371
|
|
package/dist/index.cjs
CHANGED
|
@@ -193,7 +193,7 @@ function evictStaleRuns(runs, now, graceMs = DEFAULT_RUN_GRACE_MS, maxTracked =
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
// src/version.ts
|
|
196
|
-
var RUNTIME_VERSION = "0.
|
|
196
|
+
var RUNTIME_VERSION = "0.24.0";
|
|
197
197
|
|
|
198
198
|
// src/routes/health.ts
|
|
199
199
|
var alwaysOnCapabilities = {
|
|
@@ -359,17 +359,18 @@ function validateTurnContext(value) {
|
|
|
359
359
|
return context;
|
|
360
360
|
}
|
|
361
361
|
var ENVIRONMENTS = ["development", "production"];
|
|
362
|
-
function clientVersionFields(body) {
|
|
362
|
+
function clientVersionFields(body, envField = "environment") {
|
|
363
363
|
const out = {};
|
|
364
|
-
|
|
365
|
-
|
|
364
|
+
const env = body[envField];
|
|
365
|
+
if (env !== void 0 && env !== null) {
|
|
366
|
+
if (!ENVIRONMENTS.includes(env)) {
|
|
366
367
|
throw new RuntimeHttpError(
|
|
367
368
|
400,
|
|
368
369
|
"INVALID_REQUEST",
|
|
369
|
-
|
|
370
|
+
`"${envField}" must be "development" or "production".`
|
|
370
371
|
);
|
|
371
372
|
}
|
|
372
|
-
out.environment =
|
|
373
|
+
out.environment = env;
|
|
373
374
|
}
|
|
374
375
|
if (body.agentVersion !== void 0 && body.agentVersion !== null) {
|
|
375
376
|
const v = body.agentVersion;
|
|
@@ -384,10 +385,10 @@ function clientVersionFields(body) {
|
|
|
384
385
|
}
|
|
385
386
|
return out;
|
|
386
387
|
}
|
|
387
|
-
async function resolveRunVersion(body, ctx, selection) {
|
|
388
|
+
async function resolveRunVersion(body, ctx, selection, envField = "environment") {
|
|
388
389
|
const { selectVersion, defaultEnvironment, allowClientVersionSelection } = ctx.versioning;
|
|
389
390
|
if (allowClientVersionSelection) {
|
|
390
|
-
const fromClient = clientVersionFields(body);
|
|
391
|
+
const fromClient = clientVersionFields(body, envField);
|
|
391
392
|
if (fromClient.environment || fromClient.agentVersion) return fromClient;
|
|
392
393
|
}
|
|
393
394
|
if (selectVersion) {
|
|
@@ -1051,8 +1052,11 @@ var createVoiceSession = async (request, ctx) => {
|
|
|
1051
1052
|
agentId,
|
|
1052
1053
|
kind: "voice"
|
|
1053
1054
|
});
|
|
1055
|
+
const traceparent = incomingTraceparent(request.headers, ctx.forwardTraceparent);
|
|
1054
1056
|
const ticket = await ctx.client.voice.createSession(agentId, {
|
|
1055
1057
|
...version,
|
|
1058
|
+
// `traceparent` needs @personaai/sdk >= 0.27 (older SDKs ignore it).
|
|
1059
|
+
...traceparent ? { traceparent } : {},
|
|
1056
1060
|
...threadId ? { threadId } : {},
|
|
1057
1061
|
...contextOverride ? { contextOverride } : {},
|
|
1058
1062
|
...context ? { context } : {},
|
|
@@ -1143,12 +1147,23 @@ var sendAgentMessage = async (request, ctx) => {
|
|
|
1143
1147
|
const prompt = requireStringField(body, "prompt");
|
|
1144
1148
|
const channel = optionalChannel(body);
|
|
1145
1149
|
const displayName = optionalStringField(body, "displayName");
|
|
1150
|
+
const version = await resolveRunVersion(body, ctx, {
|
|
1151
|
+
userId: request.userId,
|
|
1152
|
+
agentId,
|
|
1153
|
+
kind: "messages"
|
|
1154
|
+
});
|
|
1155
|
+
const traceparent = incomingTraceparent(request.headers, ctx.forwardTraceparent);
|
|
1156
|
+
const runOptions = {
|
|
1157
|
+
...version,
|
|
1158
|
+
...traceparent ? { traceparent } : {}
|
|
1159
|
+
};
|
|
1146
1160
|
const delivery = await ctx.client.messages.sendFromAgent({
|
|
1147
1161
|
agentId,
|
|
1148
1162
|
to,
|
|
1149
1163
|
prompt,
|
|
1150
1164
|
...channel ? { channel } : {},
|
|
1151
|
-
...displayName ? { displayName } : {}
|
|
1165
|
+
...displayName ? { displayName } : {},
|
|
1166
|
+
...runOptions
|
|
1152
1167
|
});
|
|
1153
1168
|
return json(200, delivery);
|
|
1154
1169
|
};
|
|
@@ -1844,11 +1859,26 @@ var workflowStreamRoute = async (request, ctx) => {
|
|
|
1844
1859
|
workflowId,
|
|
1845
1860
|
input: body.input
|
|
1846
1861
|
};
|
|
1862
|
+
const agentVersion = await resolveRunVersion(
|
|
1863
|
+
request.body ?? {},
|
|
1864
|
+
ctx,
|
|
1865
|
+
{ userId, workflowId, kind: "workflow" },
|
|
1866
|
+
"agentEnvironment"
|
|
1867
|
+
);
|
|
1868
|
+
if (agentVersion.environment) runCtx.environment = agentVersion.environment;
|
|
1869
|
+
if (agentVersion.agentVersion) runCtx.agentVersion = agentVersion.agentVersion;
|
|
1870
|
+
const traceparent = incomingTraceparent(request.headers, ctx.forwardTraceparent);
|
|
1847
1871
|
await ctx.hooks?.beforeRun?.(runCtx);
|
|
1872
|
+
const runOptions = {
|
|
1873
|
+
...agentVersion.environment ? { agentEnvironment: agentVersion.environment } : {},
|
|
1874
|
+
...agentVersion.agentVersion ? { agentVersion: agentVersion.agentVersion } : {},
|
|
1875
|
+
...traceparent ? { traceparent } : {}
|
|
1876
|
+
};
|
|
1848
1877
|
const stream = ctx.client.workflows.stream(workflowId, {
|
|
1849
1878
|
input: body.input,
|
|
1850
1879
|
dryRun: body.dryRun,
|
|
1851
|
-
version: body.version
|
|
1880
|
+
version: body.version,
|
|
1881
|
+
...runOptions
|
|
1852
1882
|
});
|
|
1853
1883
|
const runId = crypto.randomUUID();
|
|
1854
1884
|
const driver = new RunDriver(runId, runCtx, stream, ctx.hooks, ctx.mode);
|