@agents24/node 0.5.41 → 0.5.43
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 +296 -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 +296 -8
- package/dist/bff.js.map +1 -1
- package/dist/{client-BfSwZnv3.d.cts → client-9eTRFxs2.d.cts} +276 -6
- package/dist/{client-BfSwZnv3.d.ts → client-9eTRFxs2.d.ts} +276 -6
- package/dist/index.cjs +193 -4
- 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 +193 -4
- 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/client.d.ts +4 -0
- package/dist/types/client.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/clientGovernance.d.ts +8 -0
- package/dist/types/generated/clientGovernance.d.ts.map +1 -0
- package/dist/types/generated/clientServiceKeys.d.ts +10 -0
- package/dist/types/generated/clientServiceKeys.d.ts.map +1 -0
- package/dist/types/generated/embed.d.ts +10 -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 +120 -0
- package/dist/types/generated/personal-skills.d.ts.map +1 -1
- package/dist/types/generated/resourcePolicies.d.ts +5 -1
- package/dist/types/generated/resourcePolicies.d.ts.map +1 -1
- package/dist/types/generated/runs.d.ts +8 -0
- package/dist/types/generated/runs.d.ts.map +1 -0
- package/dist/types/runs.d.ts +2 -2
- package/dist/types/runs.d.ts.map +1 -1
- package/dist/types/submission-and-service-key-types.d.ts +39 -0
- package/dist/types/submission-and-service-key-types.d.ts.map +1 -0
- package/dist/types/types.d.ts +81 -3
- 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": "7984306cfaaa57ef9fe9ed143715a47ed28baa9698063497645b2f9a3e70dda9",
|
|
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": "7984306cfaaa57ef9fe9ed143715a47ed28baa9698063497645b2f9a3e70dda9",
|
|
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": "7984306cfaaa57ef9fe9ed143715a47ed28baa9698063497645b2f9a3e70dda9",
|
|
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": 67,
|
|
51
|
+
"node": 286,
|
|
52
|
+
"python": 280
|
|
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,264 @@ 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
|
+
{
|
|
381
|
+
method: "GET",
|
|
382
|
+
pattern: /^\/connector-triggers$/,
|
|
383
|
+
capability: "connections.personal",
|
|
384
|
+
run: (call) => call.embed.listConnectorTriggers(call.agentId, query(call))
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
method: "POST",
|
|
388
|
+
pattern: /^\/connector-triggers$/,
|
|
389
|
+
capability: "connections.personal",
|
|
390
|
+
keyed: true,
|
|
391
|
+
fields: ["account_id", "trigger_slug", "trigger_config"],
|
|
392
|
+
run: (call) => call.embed.subscribeConnectorTrigger(call.agentId, payload(call), call.options)
|
|
393
|
+
},
|
|
394
|
+
// Removing a subscription twice finds nothing the second time, so no key is required.
|
|
395
|
+
{
|
|
396
|
+
method: "DELETE",
|
|
397
|
+
pattern: /^\/connector-triggers\/([^/]+)$/,
|
|
398
|
+
capability: "connections.personal",
|
|
399
|
+
run: (call) => call.embed.unsubscribeConnectorTrigger(call.agentId, call.ids[0], query(call))
|
|
400
|
+
},
|
|
401
|
+
{ method: "GET", pattern: /^\/connector-events$/, capability: "connections.personal", run: (call) => call.embed.readConnectorEvents(call.agentId, {
|
|
402
|
+
...query(call),
|
|
403
|
+
after: integer(call.url, "after"),
|
|
404
|
+
limit: integer(call.url, "limit"),
|
|
405
|
+
waitSeconds: integer(call.url, "wait_seconds")
|
|
406
|
+
}) },
|
|
407
|
+
// Ungated: raising a generation only ever withdraws authority.
|
|
408
|
+
{
|
|
409
|
+
method: "PUT",
|
|
410
|
+
pattern: /^\/caller-authority$/,
|
|
411
|
+
keyed: true,
|
|
412
|
+
fields: ["generation"],
|
|
413
|
+
run: (call) => call.embed.revokeCallerAuthority(call.agentId, payload(call), call.options)
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
method: "POST",
|
|
417
|
+
pattern: /^\/tool-sessions$/,
|
|
418
|
+
capability: "tools.host",
|
|
419
|
+
keyed: true,
|
|
420
|
+
fields: ["submission_id", "restrictions", "max_calls", "max_seconds", "deadline_at", "allow_cloud_computer", "personal_skills", "selected_app_ids"],
|
|
421
|
+
run: (call) => call.embed.openToolSession(call.agentId, payload(call, {
|
|
422
|
+
...call.agentVersionId ? { agent_version_id: call.agentVersionId } : {},
|
|
423
|
+
...call.resolution.knowledgeNamespaces === void 0 ? {} : { knowledge_namespaces: call.resolution.knowledgeNamespaces },
|
|
424
|
+
...call.resolution.knowledgeAccessScopes === void 0 ? {} : { knowledge_access_scopes: call.resolution.knowledgeAccessScopes }
|
|
425
|
+
}), call.options)
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
method: "POST",
|
|
429
|
+
pattern: SESSION("/discover"),
|
|
430
|
+
capability: "tools.host",
|
|
431
|
+
keyed: true,
|
|
432
|
+
fields: [],
|
|
433
|
+
run: (call) => call.embed.discoverHostTools(call.agentId, call.ids[0], call.owner, call.options)
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
method: "POST",
|
|
437
|
+
pattern: SESSION("/invoke"),
|
|
438
|
+
capability: "tools.host",
|
|
439
|
+
keyed: true,
|
|
440
|
+
fields: ["name", "arguments"],
|
|
441
|
+
run: (call) => call.embed.invokeHostTool(call.agentId, call.ids[0], payload(call), call.options)
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
method: "GET",
|
|
445
|
+
pattern: SESSION("/receipts/([^/]+)"),
|
|
446
|
+
capability: "tools.host",
|
|
447
|
+
run: (call) => call.embed.inspectHostTool(call.agentId, call.ids[0], call.ids[1], call.owner)
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
method: "POST",
|
|
451
|
+
pattern: SESSION("/receipts/([^/]+)/resume"),
|
|
452
|
+
capability: "tools.host",
|
|
453
|
+
keyed: true,
|
|
454
|
+
fields: ["decision"],
|
|
455
|
+
run: (call) => call.embed.resumeHostTool(call.agentId, call.ids[0], call.ids[1], payload(call), call.options)
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
method: "POST",
|
|
459
|
+
pattern: SESSION("/close"),
|
|
460
|
+
capability: "tools.host",
|
|
461
|
+
fields: [],
|
|
462
|
+
run: (call) => call.embed.closeToolSession(call.agentId, call.ids[0], call.owner, call.options)
|
|
463
|
+
},
|
|
464
|
+
{ method: "GET", pattern: /^\/relay$/, capability: "relay.connect", run: (call) => {
|
|
465
|
+
const owner = relayOwner(call);
|
|
466
|
+
return call.embed.getRelay(call.agentId, {
|
|
467
|
+
externalUserId: owner.external_user_id,
|
|
468
|
+
integrationId: owner.integration_id,
|
|
469
|
+
agentVersionId: call.agentVersionId
|
|
470
|
+
});
|
|
471
|
+
} },
|
|
472
|
+
{
|
|
473
|
+
method: "POST",
|
|
474
|
+
pattern: /^\/relay-clients$/,
|
|
475
|
+
capability: "relay.connect",
|
|
476
|
+
fields: ["id", "name"],
|
|
477
|
+
run: (call) => call.embed.createRelayClient(call.agentId, { ...call.body, ...relayOwner(call) })
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
method: "POST",
|
|
481
|
+
pattern: /^\/relay-clients\/([^/]+)\/tickets$/,
|
|
482
|
+
capability: "relay.connect",
|
|
483
|
+
fields: ["registrations"],
|
|
484
|
+
run: (call) => call.embed.issueRelayTicket(call.agentId, call.ids[0], { ...call.body, ...relayOwner(call) })
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
method: "POST",
|
|
488
|
+
pattern: /^\/relay-clients\/([^/]+)\/revoke$/,
|
|
489
|
+
capability: "relay.connect",
|
|
490
|
+
fields: [],
|
|
491
|
+
run: (call) => call.embed.revokeRelayClient(call.agentId, call.ids[0], relayOwner(call))
|
|
492
|
+
}
|
|
493
|
+
];
|
|
494
|
+
function customerOperation(method, path) {
|
|
495
|
+
return OPERATIONS.find((operation) => operation.method === method && operation.pattern.test(path));
|
|
496
|
+
}
|
|
497
|
+
async function dispatchCustomerOperation(operation, input) {
|
|
498
|
+
const { request } = input;
|
|
499
|
+
if (operation.capability && !input.capabilities.includes(operation.capability)) {
|
|
500
|
+
throw new BffInputError(403, "CAPABILITY_NOT_ENABLED", "This operation is not available.");
|
|
501
|
+
}
|
|
502
|
+
const idempotencyKey = stringValue(request.headers.get("idempotency-key"));
|
|
503
|
+
if (operation.keyed && !idempotencyKey) throw new BffInputError(400, "IDEMPOTENCY_REQUIRED", "An Idempotency-Key is required.");
|
|
504
|
+
const body = !operation.fields?.length ? {} : await requestJson(request, operation.bodyLimit);
|
|
505
|
+
if (Object.keys(body).some((field) => !operation.fields?.includes(field))) {
|
|
506
|
+
throw new BffInputError(400, "INVALID_REQUEST", "The request contains an unsupported field.");
|
|
507
|
+
}
|
|
508
|
+
const match = operation.pattern.exec(input.path);
|
|
509
|
+
return json(await operation.run({
|
|
510
|
+
embed: input.embed,
|
|
511
|
+
agentId: input.agent.agentId,
|
|
512
|
+
agentVersionId: input.agent.agentVersionId,
|
|
513
|
+
resolution: input.resolution,
|
|
514
|
+
owner: { external_user_id: input.externalUserId, integration_id: input.integrationId, runtime_target: input.runtimeTarget },
|
|
515
|
+
ids: match.slice(1).map((id) => routeId(`/${id}`, /^\/(.+)$/, "id")),
|
|
516
|
+
url: new URL(request.url),
|
|
517
|
+
body,
|
|
518
|
+
options: { ...idempotencyKey ? { idempotencyKey } : {} }
|
|
519
|
+
}));
|
|
520
|
+
}
|
|
521
|
+
function turnChoices(body) {
|
|
522
|
+
const list = (key, valid) => {
|
|
523
|
+
const value = body[key];
|
|
524
|
+
if (value === void 0 || value === null) return void 0;
|
|
525
|
+
if (!Array.isArray(value) || !value.every(valid)) throw new BffInputError(400, "INVALID_REQUEST", `${key} is invalid.`);
|
|
526
|
+
return value;
|
|
527
|
+
};
|
|
528
|
+
const record = (key) => {
|
|
529
|
+
const value = body[key];
|
|
530
|
+
if (value === void 0 || value === null) return void 0;
|
|
531
|
+
if (typeof value !== "object" || Array.isArray(value)) throw new BffInputError(400, "INVALID_REQUEST", `${key} is invalid.`);
|
|
532
|
+
return objectValue(value);
|
|
533
|
+
};
|
|
534
|
+
const skills = list("personalSkills", (item) => Boolean(stringValue(objectValue(item).skill_id)));
|
|
535
|
+
const apps = list("selectedAppIds", (item) => Boolean(stringValue(item)));
|
|
536
|
+
const restrictions = record("callerRestrictions");
|
|
537
|
+
const limits = record("executionLimits");
|
|
538
|
+
return {
|
|
539
|
+
...skills?.length ? { personal_skills: skills } : {},
|
|
540
|
+
...apps ? { selected_app_ids: apps } : {},
|
|
541
|
+
...restrictions ? { caller_restrictions: restrictions } : {},
|
|
542
|
+
...limits ? { execution_limits: limits } : {}
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
|
|
288
546
|
// src/bff-conversation-submission.ts
|
|
289
547
|
async function submitConversationStream(input) {
|
|
290
548
|
const { request, body, resolution } = input;
|
|
@@ -298,6 +556,8 @@ async function submitConversationStream(input) {
|
|
|
298
556
|
input: value.input,
|
|
299
557
|
attachment_ids: value.attachmentIds,
|
|
300
558
|
client_submission_id: value.clientSubmissionId,
|
|
559
|
+
...turnChoices(body),
|
|
560
|
+
...body.relayClientId === null ? { relay_client_id: null } : stringValue(body.relayClientId) ? { relay_client_id: stringValue(body.relayClientId) } : {},
|
|
301
561
|
...stringValue(body.dictationSessionId) ? { dictation_session_id: stringValue(body.dictationSessionId) } : {},
|
|
302
562
|
...input.requestedAgentId ? { requested_agent_id: input.requestedAgentId } : {},
|
|
303
563
|
...value.requestedModelId ? { requested_model_id: value.requestedModelId } : {},
|
|
@@ -330,9 +590,9 @@ async function dispatchDelegations(request, path, embed, agentId, scope) {
|
|
|
330
590
|
const match = delegationRoute(path);
|
|
331
591
|
const threadId = decodeURIComponent(match[1]);
|
|
332
592
|
const handle = match[2] ? decodeURIComponent(match[2]) : void 0;
|
|
333
|
-
const
|
|
593
|
+
const query2 = new URL(request.url).searchParams;
|
|
334
594
|
const paging = (key, max) => {
|
|
335
|
-
const raw =
|
|
595
|
+
const raw = query2.get(key), rawLimit = query2.get("limit");
|
|
336
596
|
const cursor = raw === null ? void 0 : Number(raw);
|
|
337
597
|
const limit = rawLimit === null ? void 0 : Number(rawLimit);
|
|
338
598
|
if (cursor !== void 0 && (!Number.isInteger(cursor) || cursor < 0) || limit !== void 0 && (!Number.isInteger(limit) || limit < 1 || limit > max)) {
|
|
@@ -512,8 +772,8 @@ function emitDiagnostic(callback, diagnostic) {
|
|
|
512
772
|
}
|
|
513
773
|
function reportFailureResponse(callback, request, operation, response) {
|
|
514
774
|
if (!callback || response.status < 400) return response;
|
|
515
|
-
void response.clone().json().then((
|
|
516
|
-
const row =
|
|
775
|
+
void response.clone().json().then((payload2) => {
|
|
776
|
+
const row = payload2 && typeof payload2 === "object" && !Array.isArray(payload2) ? payload2 : {};
|
|
517
777
|
const clean2 = (value, pattern) => typeof value === "string" && pattern.test(value) ? value : void 0;
|
|
518
778
|
emitDiagnostic(callback, {
|
|
519
779
|
operation,
|
|
@@ -1256,6 +1516,32 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1256
1516
|
});
|
|
1257
1517
|
return (await requestedAgent(detail.runtime_selection?.agent_id)).agentId;
|
|
1258
1518
|
};
|
|
1519
|
+
const operation = customerOperation(request.method, path);
|
|
1520
|
+
if (operation) {
|
|
1521
|
+
const agent = await requestedAgent(url.searchParams.get("agent_id"));
|
|
1522
|
+
assertWritableAgent(agent.agentId, historical);
|
|
1523
|
+
return mergeHeaders(await dispatchCustomerOperation(operation, {
|
|
1524
|
+
request,
|
|
1525
|
+
path,
|
|
1526
|
+
embed: options.client.embed,
|
|
1527
|
+
agent,
|
|
1528
|
+
resolution,
|
|
1529
|
+
externalUserId,
|
|
1530
|
+
integrationId,
|
|
1531
|
+
runtimeTarget,
|
|
1532
|
+
capabilities: options.capabilities ?? []
|
|
1533
|
+
}), resolution.responseHeaders);
|
|
1534
|
+
}
|
|
1535
|
+
if (request.method === "GET" && /^\/runs\/[^/]+$/.test(path)) {
|
|
1536
|
+
const runId = routeId(path, /^\/runs\/([^/]+)$/, "runId");
|
|
1537
|
+
return mergeHeaders(json(await options.client.embed.getAgentRun(await resolveRunAgent(runId), runId, {
|
|
1538
|
+
externalUserId,
|
|
1539
|
+
integrationId,
|
|
1540
|
+
runtimeTarget,
|
|
1541
|
+
externalSessionId: resolution.principal.externalSessionId,
|
|
1542
|
+
chatScope: resolution.chatScope
|
|
1543
|
+
})), resolution.responseHeaders);
|
|
1544
|
+
}
|
|
1259
1545
|
if (request.method === "GET" && /^\/runs\/[^/]+\/outputs(?:\/[^/]+)?$/.test(path)) {
|
|
1260
1546
|
const runId = routeId(path, /^\/runs\/([^/]+)\/outputs/, "runId");
|
|
1261
1547
|
return dispatchToAgent(await resolveRunAgent(runId));
|
|
@@ -1270,7 +1556,7 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1270
1556
|
const body = await requestJson(request);
|
|
1271
1557
|
const threadId = stringValue(body.threadId);
|
|
1272
1558
|
if (threadId && body.requestedAgentId) assertWritableAgent((await requestedAgent(body.requestedAgentId)).agentId, historical);
|
|
1273
|
-
if (threadId) return submitConversationStream({
|
|
1559
|
+
if (threadId) return await submitConversationStream({
|
|
1274
1560
|
options,
|
|
1275
1561
|
request,
|
|
1276
1562
|
body,
|
|
@@ -1298,6 +1584,7 @@ function createResolvedAgents24BffHandler(options, sharedIdentity) {
|
|
|
1298
1584
|
...resolution.chatScope === void 0 ? {} : { chat_scope: resolution.chatScope },
|
|
1299
1585
|
...input ? { input } : {},
|
|
1300
1586
|
client_submission_id: stringValue(body.clientSubmissionId),
|
|
1587
|
+
...turnChoices(body),
|
|
1301
1588
|
...body.relayClientId === null ? { relay_client_id: null } : stringValue(body.relayClientId) ? { relay_client_id: stringValue(body.relayClientId) } : {},
|
|
1302
1589
|
attachment_ids: attachmentIds,
|
|
1303
1590
|
...stringValue(body.dictationSessionId) ? { dictation_session_id: stringValue(body.dictationSessionId) } : {},
|
|
@@ -1583,7 +1870,8 @@ async function runtimeBootstrap(options, request, identityResolver) {
|
|
|
1583
1870
|
});
|
|
1584
1871
|
identityResolver.remember(resolution.principal, result.customer_principal_ref);
|
|
1585
1872
|
await options.onPrincipalResolved?.(request, resolution, result.customer_principal_ref);
|
|
1586
|
-
|
|
1873
|
+
const bootstrap = options.capabilities?.length ? { ...result.bootstrap, capabilities: [.../* @__PURE__ */ new Set([...result.bootstrap.capabilities ?? [], ...options.capabilities])] } : result.bootstrap;
|
|
1874
|
+
return { response: mergeHeaders(json(bootstrap), resolution.responseHeaders), result };
|
|
1587
1875
|
}
|
|
1588
1876
|
|
|
1589
1877
|
// src/bff.ts
|