@agents24/node 0.5.40 → 0.5.42
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 +17 -1
- package/compatibility.json +6 -6
- package/dist/bff.cjs +269 -8
- package/dist/bff.cjs.map +1 -1
- package/dist/bff.d.cts +6 -2
- package/dist/bff.d.ts +6 -2
- package/dist/bff.js +269 -8
- package/dist/bff.js.map +1 -1
- package/dist/{client-BfSwZnv3.d.cts → client-aKlZQ7rZ.d.cts} +66 -1
- package/dist/{client-BfSwZnv3.d.ts → client-aKlZQ7rZ.d.ts} +66 -1
- package/dist/index.cjs +66 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -1
- package/dist/types/bff-agent-resolution.d.ts +4 -0
- package/dist/types/bff-agent-resolution.d.ts.map +1 -1
- package/dist/types/bff-bootstrap.d.ts.map +1 -1
- package/dist/types/bff-conversation-submission.d.ts.map +1 -1
- package/dist/types/bff-customer-operations.d.ts +51 -0
- package/dist/types/bff-customer-operations.d.ts.map +1 -0
- package/dist/types/bff-multi-agent.d.ts.map +1 -1
- package/dist/types/bff-request.d.ts +1 -1
- package/dist/types/bff-request.d.ts.map +1 -1
- package/dist/types/bff.d.ts +1 -1
- package/dist/types/bff.d.ts.map +1 -1
- package/dist/types/embed-types.d.ts +2 -0
- package/dist/types/embed-types.d.ts.map +1 -1
- package/dist/types/embed.d.ts.map +1 -1
- package/dist/types/generated/embed.d.ts +5 -1
- package/dist/types/generated/embed.d.ts.map +1 -1
- package/dist/types/generated/manifest.d.ts +1 -1
- package/dist/types/generated/manifest.d.ts.map +1 -1
- package/dist/types/generated/personal-skills.d.ts +59 -0
- package/dist/types/generated/personal-skills.d.ts.map +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@agents24/node`
|
|
2
2
|
|
|
3
|
-
Last Updated: 2026-
|
|
3
|
+
Last Updated: 2026-12-02
|
|
4
4
|
|
|
5
5
|
`@agents24/node/relay` exports `createArtifactRelay()` for one outbound app-profile connection serving multiple draft/published Artifacts. `relayClients` manages durable client identity, status, revocation, and short-lived tickets. Persist the client ID outside conversation state and pass `relay_client_id` at initial run admission. Local URLs and signing secrets stay in the application. See [the relay contract](https://github.com/agents24/talmudpedia/blob/main/docs/design-docs/shared_artifact_relay.md).
|
|
6
6
|
|
|
@@ -78,6 +78,22 @@ and `DELETE /threads/{threadId}` operate across the configured Agent set.
|
|
|
78
78
|
Run-owned routes resolve the authoritative Agent from the stored run. The same
|
|
79
79
|
browser client continues to use `createBffAgentClient({ basePath })`.
|
|
80
80
|
|
|
81
|
+
### Customer operations
|
|
82
|
+
|
|
83
|
+
`capabilities` opts a handler into the signed-in customer's own operations:
|
|
84
|
+
`skills.personal`, `connections.personal`, `tools.host` and `relay.connect`.
|
|
85
|
+
Nothing is exposed by default, and bootstrap advertises what you enable. The
|
|
86
|
+
customer, integration, Agent version and knowledge scopes always come from
|
|
87
|
+
your server. A request that names them is refused. Chat accepts
|
|
88
|
+
`personalSkills`, `selectedAppIds`, `callerRestrictions` and
|
|
89
|
+
`executionLimits`, which can only narrow a turn. `GET /runs/{runId}` and
|
|
90
|
+
`PUT /caller-authority` need no capability.
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
createAgents24BffHandler({ client, agents, integrationId, resolvePrincipal,
|
|
94
|
+
capabilities: ["skills.personal", "relay.connect"] });
|
|
95
|
+
```
|
|
96
|
+
|
|
81
97
|
The BFF resolves every host principal to an opaque integration-scoped customer
|
|
82
98
|
principal through `agents24.embed.resolveCustomerPrincipal(...)`, caches that
|
|
83
99
|
lookup with a bounded 60-second single-flight window across BFF routes, and
|
package/compatibility.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"contractHash": "
|
|
2
|
+
"contractHash": "6875c581eac70164a9965c2e851630094c1166fefae1e3f53c50dde22fc9a235",
|
|
3
3
|
"contractVersion": "0.3.0",
|
|
4
4
|
"corpus": "conformance/v1/corpus.json",
|
|
5
5
|
"generatedBy": "@agents24/sdk-contract",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"runtime": "run-stream.v3"
|
|
20
20
|
},
|
|
21
21
|
"@agents24/node": {
|
|
22
|
-
"contract": "
|
|
22
|
+
"contract": "6875c581eac70164a9965c2e851630094c1166fefae1e3f53c50dde22fc9a235",
|
|
23
23
|
"node": "^22.0.0 || ^24.0.0"
|
|
24
24
|
},
|
|
25
25
|
"@agents24/react": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"protocolOwner": "@agents24/client"
|
|
32
32
|
},
|
|
33
33
|
"agents24": {
|
|
34
|
-
"contract": "
|
|
34
|
+
"contract": "6875c581eac70164a9965c2e851630094c1166fefae1e3f53c50dde22fc9a235",
|
|
35
35
|
"python": ">=3.10"
|
|
36
36
|
}
|
|
37
37
|
},
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"schemaVersion": "agents24.compatibility.v1",
|
|
49
49
|
"targetOperationCounts": {
|
|
50
|
-
"client":
|
|
51
|
-
"node":
|
|
52
|
-
"python":
|
|
50
|
+
"client": 62,
|
|
51
|
+
"node": 269,
|
|
52
|
+
"python": 263
|
|
53
53
|
}
|
|
54
54
|
}
|
package/dist/bff.cjs
CHANGED
|
@@ -125,9 +125,9 @@ function json(value, headers, status = 200) {
|
|
|
125
125
|
responseHeaders.set("Content-Type", "application/json; charset=utf-8");
|
|
126
126
|
return new Response(JSON.stringify(value), { status, headers: responseHeaders });
|
|
127
127
|
}
|
|
128
|
-
async function requestJson(request) {
|
|
128
|
+
async function requestJson(request, limit = JSON_LIMIT_BYTES) {
|
|
129
129
|
const contentLength = Number(request.headers.get("content-length") || 0);
|
|
130
|
-
if (contentLength >
|
|
130
|
+
if (contentLength > limit) throw new BffInputError(413, "REQUEST_TOO_LARGE", "The request body is too large.");
|
|
131
131
|
const value = await request.json().catch(() => null);
|
|
132
132
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
133
133
|
throw new BffInputError(400, "INVALID_JSON", "A JSON object is required.");
|
|
@@ -285,6 +285,237 @@ async function guardHistoricalRequest(input) {
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
+
// src/bff-customer-operations.ts
|
|
289
|
+
var SKILL_BODY_LIMIT_BYTES = 32 * 1048576;
|
|
290
|
+
var query = (call) => ({
|
|
291
|
+
externalUserId: call.owner.external_user_id,
|
|
292
|
+
integrationId: call.owner.integration_id,
|
|
293
|
+
runtimeTarget: call.owner.runtime_target
|
|
294
|
+
});
|
|
295
|
+
var relayOwner = (call) => {
|
|
296
|
+
if (call.owner.runtime_target !== "published") throw new BffInputError(409, "RELAY_PUBLISHED_ONLY", "Local tools serve published Agents only.");
|
|
297
|
+
return {
|
|
298
|
+
external_user_id: call.owner.external_user_id,
|
|
299
|
+
integration_id: call.owner.integration_id,
|
|
300
|
+
...call.agentVersionId ? { agent_version_id: call.agentVersionId } : {}
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
var integer = (url, name) => {
|
|
304
|
+
const raw = url.searchParams.get(name);
|
|
305
|
+
if (raw === null) return void 0;
|
|
306
|
+
const value = Number(raw);
|
|
307
|
+
if (!Number.isInteger(value) || value < 0) throw new BffInputError(400, "INVALID_PAGINATION", `${name} is invalid.`);
|
|
308
|
+
return value;
|
|
309
|
+
};
|
|
310
|
+
var text = (url, name) => url.searchParams.get(name) ?? void 0;
|
|
311
|
+
var SKILL = /^\/personal-skills\/([^/]+)$/;
|
|
312
|
+
var SESSION = (suffix) => new RegExp(`^/tool-sessions/([^/]+)${suffix}$`);
|
|
313
|
+
var payload = (call, extra = {}) => ({ ...call.body, ...extra, ...call.owner });
|
|
314
|
+
var OPERATIONS = [
|
|
315
|
+
{ method: "GET", pattern: /^\/personal-skills$/, capability: "skills.personal", run: (call) => call.embed.listPersonalSkills(call.agentId, {
|
|
316
|
+
...query(call),
|
|
317
|
+
q: text(call.url, "q"),
|
|
318
|
+
offset: integer(call.url, "offset"),
|
|
319
|
+
limit: integer(call.url, "limit"),
|
|
320
|
+
includeArchived: call.url.searchParams.get("include_archived") === "true"
|
|
321
|
+
}) },
|
|
322
|
+
{
|
|
323
|
+
method: "POST",
|
|
324
|
+
pattern: /^\/personal-skills$/,
|
|
325
|
+
capability: "skills.personal",
|
|
326
|
+
keyed: true,
|
|
327
|
+
bodyLimit: SKILL_BODY_LIMIT_BYTES,
|
|
328
|
+
fields: ["skill_id", "expected_revision", "name", "description", "content", "assets", "asset_changes"],
|
|
329
|
+
run: (call) => call.embed.savePersonalSkill(call.agentId, payload(call), call.options)
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
method: "POST",
|
|
333
|
+
pattern: /^\/personal-skills\/import$/,
|
|
334
|
+
capability: "skills.personal",
|
|
335
|
+
keyed: true,
|
|
336
|
+
bodyLimit: SKILL_BODY_LIMIT_BYTES,
|
|
337
|
+
fields: ["markdown", "assets"],
|
|
338
|
+
run: (call) => call.embed.importPersonalSkill(call.agentId, payload(call), call.options)
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
method: "GET",
|
|
342
|
+
pattern: SKILL,
|
|
343
|
+
capability: "skills.personal",
|
|
344
|
+
run: (call) => call.embed.getPersonalSkill(call.agentId, call.ids[0], query(call))
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
method: "PATCH",
|
|
348
|
+
pattern: SKILL,
|
|
349
|
+
capability: "skills.personal",
|
|
350
|
+
keyed: true,
|
|
351
|
+
fields: ["expected_revision", "enabled", "archived", "agent_enabled"],
|
|
352
|
+
run: (call) => call.embed.setPersonalSkillState(call.agentId, call.ids[0], payload(call), call.options)
|
|
353
|
+
},
|
|
354
|
+
{ method: "GET", pattern: /^\/personal-skills\/([^/]+)\/versions\/([^/]+)\/asset$/, capability: "skills.personal", run: (call) => {
|
|
355
|
+
const path = text(call.url, "path");
|
|
356
|
+
if (!path) throw new BffInputError(400, "INVALID_PATH", "path is required.");
|
|
357
|
+
return call.embed.readPersonalSkillAsset(call.agentId, call.ids[0], call.ids[1], { ...query(call), path });
|
|
358
|
+
} },
|
|
359
|
+
{
|
|
360
|
+
method: "GET",
|
|
361
|
+
pattern: /^\/personal-connections$/,
|
|
362
|
+
capability: "connections.personal",
|
|
363
|
+
run: (call) => call.embed.listPersonalConnections(call.agentId, query(call))
|
|
364
|
+
},
|
|
365
|
+
{ method: "GET", pattern: /^\/personal-connections\/catalog$/, capability: "connections.personal", run: (call) => call.embed.browsePersonalConnections(call.agentId, {
|
|
366
|
+
...query(call),
|
|
367
|
+
q: text(call.url, "q"),
|
|
368
|
+
category: text(call.url, "category"),
|
|
369
|
+
offset: integer(call.url, "offset"),
|
|
370
|
+
limit: integer(call.url, "limit")
|
|
371
|
+
}) },
|
|
372
|
+
{
|
|
373
|
+
method: "POST",
|
|
374
|
+
pattern: /^\/personal-connections$/,
|
|
375
|
+
capability: "connections.personal",
|
|
376
|
+
keyed: true,
|
|
377
|
+
fields: ["action", "toolkit", "server_id", "account_id", "native_callback_uri", "enabled", "selected", "label", "enabled_tool_names"],
|
|
378
|
+
run: (call) => call.embed.managePersonalConnection(call.agentId, payload(call), call.options)
|
|
379
|
+
},
|
|
380
|
+
// Ungated: raising a generation only ever withdraws authority.
|
|
381
|
+
{
|
|
382
|
+
method: "PUT",
|
|
383
|
+
pattern: /^\/caller-authority$/,
|
|
384
|
+
keyed: true,
|
|
385
|
+
fields: ["generation"],
|
|
386
|
+
run: (call) => call.embed.revokeCallerAuthority(call.agentId, payload(call), call.options)
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
method: "POST",
|
|
390
|
+
pattern: /^\/tool-sessions$/,
|
|
391
|
+
capability: "tools.host",
|
|
392
|
+
keyed: true,
|
|
393
|
+
fields: ["submission_id", "restrictions", "max_calls", "max_seconds", "deadline_at", "allow_cloud_computer", "personal_skills", "selected_app_ids"],
|
|
394
|
+
run: (call) => call.embed.openToolSession(call.agentId, payload(call, {
|
|
395
|
+
...call.agentVersionId ? { agent_version_id: call.agentVersionId } : {},
|
|
396
|
+
...call.resolution.knowledgeNamespaces === void 0 ? {} : { knowledge_namespaces: call.resolution.knowledgeNamespaces },
|
|
397
|
+
...call.resolution.knowledgeAccessScopes === void 0 ? {} : { knowledge_access_scopes: call.resolution.knowledgeAccessScopes }
|
|
398
|
+
}), call.options)
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
method: "POST",
|
|
402
|
+
pattern: SESSION("/discover"),
|
|
403
|
+
capability: "tools.host",
|
|
404
|
+
keyed: true,
|
|
405
|
+
fields: [],
|
|
406
|
+
run: (call) => call.embed.discoverHostTools(call.agentId, call.ids[0], call.owner, call.options)
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
method: "POST",
|
|
410
|
+
pattern: SESSION("/invoke"),
|
|
411
|
+
capability: "tools.host",
|
|
412
|
+
keyed: true,
|
|
413
|
+
fields: ["name", "arguments"],
|
|
414
|
+
run: (call) => call.embed.invokeHostTool(call.agentId, call.ids[0], payload(call), call.options)
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
method: "GET",
|
|
418
|
+
pattern: SESSION("/receipts/([^/]+)"),
|
|
419
|
+
capability: "tools.host",
|
|
420
|
+
run: (call) => call.embed.inspectHostTool(call.agentId, call.ids[0], call.ids[1], call.owner)
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
method: "POST",
|
|
424
|
+
pattern: SESSION("/receipts/([^/]+)/resume"),
|
|
425
|
+
capability: "tools.host",
|
|
426
|
+
keyed: true,
|
|
427
|
+
fields: ["decision"],
|
|
428
|
+
run: (call) => call.embed.resumeHostTool(call.agentId, call.ids[0], call.ids[1], payload(call), call.options)
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
method: "POST",
|
|
432
|
+
pattern: SESSION("/close"),
|
|
433
|
+
capability: "tools.host",
|
|
434
|
+
fields: [],
|
|
435
|
+
run: (call) => call.embed.closeToolSession(call.agentId, call.ids[0], call.owner, call.options)
|
|
436
|
+
},
|
|
437
|
+
{ method: "GET", pattern: /^\/relay$/, capability: "relay.connect", run: (call) => {
|
|
438
|
+
const owner = relayOwner(call);
|
|
439
|
+
return call.embed.getRelay(call.agentId, {
|
|
440
|
+
externalUserId: owner.external_user_id,
|
|
441
|
+
integrationId: owner.integration_id,
|
|
442
|
+
agentVersionId: call.agentVersionId
|
|
443
|
+
});
|
|
444
|
+
} },
|
|
445
|
+
{
|
|
446
|
+
method: "POST",
|
|
447
|
+
pattern: /^\/relay-clients$/,
|
|
448
|
+
capability: "relay.connect",
|
|
449
|
+
fields: ["id", "name"],
|
|
450
|
+
run: (call) => call.embed.createRelayClient(call.agentId, { ...call.body, ...relayOwner(call) })
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
method: "POST",
|
|
454
|
+
pattern: /^\/relay-clients\/([^/]+)\/tickets$/,
|
|
455
|
+
capability: "relay.connect",
|
|
456
|
+
fields: ["registrations"],
|
|
457
|
+
run: (call) => call.embed.issueRelayTicket(call.agentId, call.ids[0], { ...call.body, ...relayOwner(call) })
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
method: "POST",
|
|
461
|
+
pattern: /^\/relay-clients\/([^/]+)\/revoke$/,
|
|
462
|
+
capability: "relay.connect",
|
|
463
|
+
fields: [],
|
|
464
|
+
run: (call) => call.embed.revokeRelayClient(call.agentId, call.ids[0], relayOwner(call))
|
|
465
|
+
}
|
|
466
|
+
];
|
|
467
|
+
function customerOperation(method, path) {
|
|
468
|
+
return OPERATIONS.find((operation) => operation.method === method && operation.pattern.test(path));
|
|
469
|
+
}
|
|
470
|
+
async function dispatchCustomerOperation(operation, input) {
|
|
471
|
+
const { request } = input;
|
|
472
|
+
if (operation.capability && !input.capabilities.includes(operation.capability)) {
|
|
473
|
+
throw new BffInputError(403, "CAPABILITY_NOT_ENABLED", "This operation is not available.");
|
|
474
|
+
}
|
|
475
|
+
const idempotencyKey = stringValue(request.headers.get("idempotency-key"));
|
|
476
|
+
if (operation.keyed && !idempotencyKey) throw new BffInputError(400, "IDEMPOTENCY_REQUIRED", "An Idempotency-Key is required.");
|
|
477
|
+
const body = !operation.fields?.length ? {} : await requestJson(request, operation.bodyLimit);
|
|
478
|
+
if (Object.keys(body).some((field) => !operation.fields?.includes(field))) {
|
|
479
|
+
throw new BffInputError(400, "INVALID_REQUEST", "The request contains an unsupported field.");
|
|
480
|
+
}
|
|
481
|
+
const match = operation.pattern.exec(input.path);
|
|
482
|
+
return json(await operation.run({
|
|
483
|
+
embed: input.embed,
|
|
484
|
+
agentId: input.agent.agentId,
|
|
485
|
+
agentVersionId: input.agent.agentVersionId,
|
|
486
|
+
resolution: input.resolution,
|
|
487
|
+
owner: { external_user_id: input.externalUserId, integration_id: input.integrationId, runtime_target: input.runtimeTarget },
|
|
488
|
+
ids: match.slice(1).map((id) => routeId(`/${id}`, /^\/(.+)$/, "id")),
|
|
489
|
+
url: new URL(request.url),
|
|
490
|
+
body,
|
|
491
|
+
options: { ...idempotencyKey ? { idempotencyKey } : {} }
|
|
492
|
+
}));
|
|
493
|
+
}
|
|
494
|
+
function turnChoices(body) {
|
|
495
|
+
const list = (key, valid) => {
|
|
496
|
+
const value = body[key];
|
|
497
|
+
if (value === void 0 || value === null) return void 0;
|
|
498
|
+
if (!Array.isArray(value) || !value.every(valid)) throw new BffInputError(400, "INVALID_REQUEST", `${key} is invalid.`);
|
|
499
|
+
return value;
|
|
500
|
+
};
|
|
501
|
+
const record = (key) => {
|
|
502
|
+
const value = body[key];
|
|
503
|
+
if (value === void 0 || value === null) return void 0;
|
|
504
|
+
if (typeof value !== "object" || Array.isArray(value)) throw new BffInputError(400, "INVALID_REQUEST", `${key} is invalid.`);
|
|
505
|
+
return objectValue(value);
|
|
506
|
+
};
|
|
507
|
+
const skills = list("personalSkills", (item) => Boolean(stringValue(objectValue(item).skill_id)));
|
|
508
|
+
const apps = list("selectedAppIds", (item) => Boolean(stringValue(item)));
|
|
509
|
+
const restrictions = record("callerRestrictions");
|
|
510
|
+
const limits = record("executionLimits");
|
|
511
|
+
return {
|
|
512
|
+
...skills?.length ? { personal_skills: skills } : {},
|
|
513
|
+
...apps ? { selected_app_ids: apps } : {},
|
|
514
|
+
...restrictions ? { caller_restrictions: restrictions } : {},
|
|
515
|
+
...limits ? { execution_limits: limits } : {}
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
|
|
288
519
|
// src/bff-conversation-submission.ts
|
|
289
520
|
async function submitConversationStream(input) {
|
|
290
521
|
const { request, body, resolution } = input;
|
|
@@ -298,6 +529,8 @@ async function submitConversationStream(input) {
|
|
|
298
529
|
input: value.input,
|
|
299
530
|
attachment_ids: value.attachmentIds,
|
|
300
531
|
client_submission_id: value.clientSubmissionId,
|
|
532
|
+
...turnChoices(body),
|
|
533
|
+
...body.relayClientId === null ? { relay_client_id: null } : stringValue(body.relayClientId) ? { relay_client_id: stringValue(body.relayClientId) } : {},
|
|
301
534
|
...stringValue(body.dictationSessionId) ? { dictation_session_id: stringValue(body.dictationSessionId) } : {},
|
|
302
535
|
...input.requestedAgentId ? { requested_agent_id: input.requestedAgentId } : {},
|
|
303
536
|
...value.requestedModelId ? { requested_model_id: value.requestedModelId } : {},
|
|
@@ -330,9 +563,9 @@ async function dispatchDelegations(request, path, embed, agentId, scope) {
|
|
|
330
563
|
const match = delegationRoute(path);
|
|
331
564
|
const threadId = decodeURIComponent(match[1]);
|
|
332
565
|
const handle = match[2] ? decodeURIComponent(match[2]) : void 0;
|
|
333
|
-
const
|
|
566
|
+
const query2 = new URL(request.url).searchParams;
|
|
334
567
|
const paging = (key, max) => {
|
|
335
|
-
const raw =
|
|
568
|
+
const raw = query2.get(key), rawLimit = query2.get("limit");
|
|
336
569
|
const cursor = raw === null ? void 0 : Number(raw);
|
|
337
570
|
const limit = rawLimit === null ? void 0 : Number(rawLimit);
|
|
338
571
|
if (cursor !== void 0 && (!Number.isInteger(cursor) || cursor < 0) || limit !== void 0 && (!Number.isInteger(limit) || limit < 1 || limit > max)) {
|
|
@@ -512,8 +745,8 @@ function emitDiagnostic(callback, diagnostic) {
|
|
|
512
745
|
}
|
|
513
746
|
function reportFailureResponse(callback, request, operation, response) {
|
|
514
747
|
if (!callback || response.status < 400) return response;
|
|
515
|
-
void response.clone().json().then((
|
|
516
|
-
const row =
|
|
748
|
+
void response.clone().json().then((payload2) => {
|
|
749
|
+
const row = payload2 && typeof payload2 === "object" && !Array.isArray(payload2) ? payload2 : {};
|
|
517
750
|
const clean2 = (value, pattern) => typeof value === "string" && pattern.test(value) ? value : void 0;
|
|
518
751
|
emitDiagnostic(callback, {
|
|
519
752
|
operation,
|
|
@@ -1256,6 +1489,32 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1256
1489
|
});
|
|
1257
1490
|
return (await requestedAgent(detail.runtime_selection?.agent_id)).agentId;
|
|
1258
1491
|
};
|
|
1492
|
+
const operation = customerOperation(request.method, path);
|
|
1493
|
+
if (operation) {
|
|
1494
|
+
const agent = await requestedAgent(url.searchParams.get("agent_id"));
|
|
1495
|
+
assertWritableAgent(agent.agentId, historical);
|
|
1496
|
+
return mergeHeaders(await dispatchCustomerOperation(operation, {
|
|
1497
|
+
request,
|
|
1498
|
+
path,
|
|
1499
|
+
embed: options.client.embed,
|
|
1500
|
+
agent,
|
|
1501
|
+
resolution,
|
|
1502
|
+
externalUserId,
|
|
1503
|
+
integrationId,
|
|
1504
|
+
runtimeTarget,
|
|
1505
|
+
capabilities: options.capabilities ?? []
|
|
1506
|
+
}), resolution.responseHeaders);
|
|
1507
|
+
}
|
|
1508
|
+
if (request.method === "GET" && /^\/runs\/[^/]+$/.test(path)) {
|
|
1509
|
+
const runId = routeId(path, /^\/runs\/([^/]+)$/, "runId");
|
|
1510
|
+
return mergeHeaders(json(await options.client.embed.getAgentRun(await resolveRunAgent(runId), runId, {
|
|
1511
|
+
externalUserId,
|
|
1512
|
+
integrationId,
|
|
1513
|
+
runtimeTarget,
|
|
1514
|
+
externalSessionId: resolution.principal.externalSessionId,
|
|
1515
|
+
chatScope: resolution.chatScope
|
|
1516
|
+
})), resolution.responseHeaders);
|
|
1517
|
+
}
|
|
1259
1518
|
if (request.method === "GET" && /^\/runs\/[^/]+\/outputs(?:\/[^/]+)?$/.test(path)) {
|
|
1260
1519
|
const runId = routeId(path, /^\/runs\/([^/]+)\/outputs/, "runId");
|
|
1261
1520
|
return dispatchToAgent(await resolveRunAgent(runId));
|
|
@@ -1270,7 +1529,7 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1270
1529
|
const body = await requestJson(request);
|
|
1271
1530
|
const threadId = stringValue(body.threadId);
|
|
1272
1531
|
if (threadId && body.requestedAgentId) assertWritableAgent((await requestedAgent(body.requestedAgentId)).agentId, historical);
|
|
1273
|
-
if (threadId) return submitConversationStream({
|
|
1532
|
+
if (threadId) return await submitConversationStream({
|
|
1274
1533
|
options,
|
|
1275
1534
|
request,
|
|
1276
1535
|
body,
|
|
@@ -1298,6 +1557,7 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1298
1557
|
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
1299
1558
|
...input ? { input } : {},
|
|
1300
1559
|
client_submission_id: stringValue(body.clientSubmissionId),
|
|
1560
|
+
...turnChoices(body),
|
|
1301
1561
|
...body.relayClientId === null ? { relay_client_id: null } : stringValue(body.relayClientId) ? { relay_client_id: stringValue(body.relayClientId) } : {},
|
|
1302
1562
|
attachment_ids: attachmentIds,
|
|
1303
1563
|
...stringValue(body.dictationSessionId) ? { dictation_session_id: stringValue(body.dictationSessionId) } : {},
|
|
@@ -1583,7 +1843,8 @@ async function runtimeBootstrap(options, request, identityResolver) {
|
|
|
1583
1843
|
});
|
|
1584
1844
|
identityResolver.remember(resolution.principal, result.customer_principal_ref);
|
|
1585
1845
|
await options.onPrincipalResolved?.(request, resolution, result.customer_principal_ref);
|
|
1586
|
-
|
|
1846
|
+
const bootstrap = options.capabilities?.length ? { ...result.bootstrap, capabilities: [.../* @__PURE__ */ new Set([...result.bootstrap.capabilities ?? [], ...options.capabilities])] } : result.bootstrap;
|
|
1847
|
+
return { response: mergeHeaders(json(bootstrap), resolution.responseHeaders), result };
|
|
1587
1848
|
}
|
|
1588
1849
|
|
|
1589
1850
|
// src/bff.ts
|