@byok-sdk/cloud 0.22.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 +1 -1
- package/dist/activity.d.ts +12 -0
- package/dist/capabilities.d.ts +1 -1
- package/dist/cloud.d.ts +49 -2
- package/dist/handlers/shared.d.ts +13 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +82 -12
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ if (result === undefined) {
|
|
|
68
68
|
stored body is not a terminal envelope throws `ByokCloudError` rather than
|
|
69
69
|
returning a best-effort shape.
|
|
70
70
|
|
|
71
|
-
MIT licensed. Node.js
|
|
71
|
+
MIT licensed. Node.js 24.15.0 or newer.
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
## Immutable offer readback
|
package/dist/activity.d.ts
CHANGED
|
@@ -73,6 +73,12 @@ export declare const ActivityAppendRequestSchema: z.ZodObject<{
|
|
|
73
73
|
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
74
74
|
reasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
75
75
|
totalTokens: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
contextTokens: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
contextSource: z.ZodOptional<z.ZodEnum<{
|
|
79
|
+
estimate: "estimate";
|
|
80
|
+
provider: "provider";
|
|
81
|
+
}>>;
|
|
76
82
|
}, z.core.$strip>], "type">, z.ZodObject<{
|
|
77
83
|
type: z.ZodString;
|
|
78
84
|
}, z.core.$loose>]>>;
|
|
@@ -152,6 +158,12 @@ export declare const TimelineEventSchema: z.ZodObject<{
|
|
|
152
158
|
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
153
159
|
reasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
154
160
|
totalTokens: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
contextTokens: z.ZodOptional<z.ZodNumber>;
|
|
162
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
163
|
+
contextSource: z.ZodOptional<z.ZodEnum<{
|
|
164
|
+
estimate: "estimate";
|
|
165
|
+
provider: "provider";
|
|
166
|
+
}>>;
|
|
155
167
|
}, z.core.$strip>], "type">, z.ZodObject<{
|
|
156
168
|
type: z.ZodString;
|
|
157
169
|
}, z.core.$loose>]>;
|
package/dist/capabilities.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ export declare const CLOUD_CAPABILITIES: {
|
|
|
73
73
|
* DEVICE's only way to discharge a mailbox row this same deployment handed
|
|
74
74
|
* it — withholding it would strand the device's redelivery cursor rather
|
|
75
75
|
* than degrade a feature. For the same reason the completion route asserts
|
|
76
|
-
* no DEVICE capability either: the device-level `agent-input-preparation-
|
|
76
|
+
* no DEVICE capability either: the device-level `agent-input-preparation-v8`
|
|
77
77
|
* flag gates ADMISSION (`enqueueInputPreparation`) and nothing else, so an
|
|
78
78
|
* unconfigured device is refused a row instead of being handed one whose
|
|
79
79
|
* only honest answer — `input_preparation_unconfigured` — it could not then
|
package/dist/cloud.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { type RecurringExecutionInput } from './recurring';
|
|
|
19
19
|
import { type BoardItem, type BoardItemInput, type BoardListQuery, type BoardPage, type CapabilityDeclaration, type Clock, type CoreStores, type PresenceHint, type SkillPackStore, type TenantId, type TenantReadiness } from '@byok-sdk/core';
|
|
20
20
|
import type { ActivityTail } from './activity';
|
|
21
21
|
import type { ApprovalTimelineTail } from './approval-timeline';
|
|
22
|
-
import { type Envelope, type TaskOfferType, type AgentRef, type AgentContentReadPayload, type AgentMessageDispositionPayload, type AgentMessagePublishPayload, type AgentMessageServerContext, type AgentHomeProjectionCompletionRequest, type AgentHomeProjectionPayload, type AgentHomeProjectionReadback, type AgentInputPreparationPayload, type InputPreparationCompletionRequest, type InputPreparationReadback, type AgentMemoryProjectionEraseResult, type TaskOfferPayload, type TaskSteerPayload, type TaskOfferForAgentPayload, type TaskOfferPreparedPayload, type TaskOfferForAgentWithEgressPayload, type TaskOfferForAgentWithEgressFreshPayload, type TaskOfferWithToolsetsPayload } from '@byok-sdk/protocol';
|
|
22
|
+
import { type Envelope, type TaskOfferType, type AgentRef, type AgentContentReadPayload, type AgentMessageDispositionPayload, type AgentMessagePublishPayload, type AgentMessageServerContext, type AgentHomeProjectionCompletionRequest, type AgentHomeProjectionPayload, type AgentHomeProjectionReadback, type AgentInputPreparationPayload, type ProviderProvisioningAvailablePayload, type AgentMemoryIntentAvailablePayload, type InputPreparationCompletionRequest, type InputPreparationReadback, type AgentMemoryProjectionEraseResult, type TaskOfferPayload, type TaskSteerPayload, type TaskOfferForAgentPayload, type TaskOfferPreparedPayload, type TaskOfferForAgentWithEgressPayload, type TaskOfferForAgentWithEgressFreshPayload, type TaskOfferWithToolsetsPayload } from '@byok-sdk/protocol';
|
|
23
23
|
import type { TokenSigner } from './auth/tokens';
|
|
24
24
|
import type { CloudCrypto } from './crypto/port';
|
|
25
25
|
import { type RouteDescriptor } from './router/registry';
|
|
@@ -197,6 +197,19 @@ export interface AgentContentReadInput {
|
|
|
197
197
|
}
|
|
198
198
|
/** Task-free exact-device projection desired state, intentionally unrelated to TaskAttempt. */
|
|
199
199
|
export type AgentHomeProjectionInput = AgentHomeProjectionPayload;
|
|
200
|
+
/**
|
|
201
|
+
* Task-free sealed provider provisioning notice: exactly `{ requestId }`. The
|
|
202
|
+
* sealed request itself stays in the Host's own store and is fetched by the
|
|
203
|
+
* device over Host routes; nothing else can be carried by this input.
|
|
204
|
+
*/
|
|
205
|
+
export type ProviderProvisioningNoticeInput = ProviderProvisioningAvailablePayload;
|
|
206
|
+
/**
|
|
207
|
+
* Task-free Host-approved Agent memory intent notice: exactly
|
|
208
|
+
* `{ intentId, agentRef }`. The immutable intent, and any memory content it
|
|
209
|
+
* carries, stays in the Host's own store and is fetched by the device over
|
|
210
|
+
* Host routes; nothing else can be carried by this input.
|
|
211
|
+
*/
|
|
212
|
+
export type AgentMemoryIntentNoticeInput = AgentMemoryIntentAvailablePayload;
|
|
200
213
|
/** Exact request identity a host must echo to read back durable projection status. */
|
|
201
214
|
export type AgentHomeProjectionStatusInput = AgentHomeProjectionReceiptInput;
|
|
202
215
|
/** Task-free exact-device remote preparation request, intentionally unrelated to TaskAttempt. */
|
|
@@ -285,7 +298,7 @@ export interface ByokCloud {
|
|
|
285
298
|
* Host control plane: enqueue an offer for an already-counted preparation.
|
|
286
299
|
*
|
|
287
300
|
* Admission requires the device to durably advertise both the Agent-home
|
|
288
|
-
* contract and `agent-input-preparation-
|
|
301
|
+
* contract and `agent-input-preparation-v8` — the second because only a device
|
|
289
302
|
* that can prepare holds the durable record this offer names. A device that
|
|
290
303
|
* advertises neither never receives the message, and a device whose protocol
|
|
291
304
|
* build predates the type skips it whole rather than running it as an
|
|
@@ -320,6 +333,40 @@ export interface ByokCloud {
|
|
|
320
333
|
* and NO delivery row behind.
|
|
321
334
|
*/
|
|
322
335
|
enqueueInputPreparation(tenant: TenantId, deviceId: string, input: InputPreparationInput): Promise<EnqueuedInputPreparation>;
|
|
336
|
+
/**
|
|
337
|
+
* Durable, task-free `provider.provisioning.available` notice for precisely
|
|
338
|
+
* one device that durably advertised `provider-provisioning.v1`. The payload
|
|
339
|
+
* is validated strictly before admission, and admission happens before the
|
|
340
|
+
* mailbox append, so a refused call leaves no delivery row behind.
|
|
341
|
+
*
|
|
342
|
+
* Idempotent per (tenant, device, requestId): the mailbox message id is
|
|
343
|
+
* derived from that identity, so a retried enqueue returns the existing row
|
|
344
|
+
* and its seq instead of appending a second notice. The completion and its
|
|
345
|
+
* durable readback are Host authority on Host routes; this plane records no
|
|
346
|
+
* provisioning receipt of its own.
|
|
347
|
+
*/
|
|
348
|
+
enqueueProviderProvisioningNotice(tenant: TenantId, deviceId: string, input: ProviderProvisioningNoticeInput): Promise<EnqueuedAgentControl>;
|
|
349
|
+
/**
|
|
350
|
+
* Durable, task-free `agent.memory.intent.available` notice for precisely
|
|
351
|
+
* one device that durably advertised `agent-memory-intent.v1`. The payload
|
|
352
|
+
* is validated strictly before admission, and admission happens before the
|
|
353
|
+
* mailbox append, so a refused call leaves no delivery row behind.
|
|
354
|
+
*
|
|
355
|
+
* Idempotent per (tenant, device, intentId) while the original mailbox row
|
|
356
|
+
* is retained: the mailbox message id is derived from that identity, so a
|
|
357
|
+
* retried enqueue returns the existing row and its seq instead of appending
|
|
358
|
+
* a second notice, and a retry naming a different `agentRef` for the same
|
|
359
|
+
* intent fails `mailbox_receipt_mismatch`. After acked-row retention cleanup
|
|
360
|
+
* a retry appends a new row with a new seq and `agentRef` is no longer
|
|
361
|
+
* compared, so the Host must keep `agentRef` fixed per `intentId`. The
|
|
362
|
+
* device fails closed (`fetch_invalid`/`readback_invalid`) on a mismatched
|
|
363
|
+
* `agentId`, or on a mismatched `profileRevision` once its ledger row is
|
|
364
|
+
* pruned; while the row is live it replays its stored completion without
|
|
365
|
+
* comparing the notice's `profileRevision` (no memory write, no second CAS).
|
|
366
|
+
* Approval, release, completion and readback are Host authority on Host
|
|
367
|
+
* routes; this plane records no intent receipt of its own.
|
|
368
|
+
*/
|
|
369
|
+
enqueueAgentMemoryIntentNotice(tenant: TenantId, deviceId: string, input: AgentMemoryIntentNoticeInput): Promise<EnqueuedAgentControl>;
|
|
323
370
|
/** Tenant/device/request-bound durable desired-state and terminal-outcome readback. */
|
|
324
371
|
getInputPreparationStatus(tenant: TenantId, deviceId: string, input: InputPreparationStatusInput): Promise<InputPreparationReadback | undefined>;
|
|
325
372
|
/** Direct device completion endpoint authority; first exact terminal receipt wins. */
|
|
@@ -26,6 +26,19 @@ export interface BoundedJsonBodyResult {
|
|
|
26
26
|
* existing validation status.
|
|
27
27
|
*/
|
|
28
28
|
export declare function readBoundedJsonBody(c: Context, maximum: number): Promise<BoundedJsonBodyResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Count actual request bytes before retaining each chunk. Keep the bytes intact
|
|
31
|
+
* for consumers that authenticate a raw-body hash before decoding JSON.
|
|
32
|
+
* Content-Length policy belongs to the caller; it never replaces this ceiling.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readBoundedRawBody(stream: ReadableStream<Uint8Array> | null, maximum: number): Promise<Uint8Array | 'too_large' | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* Cancellation is a resource-release best effort that is never awaited before
|
|
37
|
+
* rejecting an already oversized request. `ReadableStream.cancel()` is used
|
|
38
|
+
* before a reader exists; `ReadableStreamDefaultReader.cancel()` owns the
|
|
39
|
+
* same underlying request stream after an overflow has been observed.
|
|
40
|
+
*/
|
|
41
|
+
export declare function cancelBody(body: ReadableStream<Uint8Array> | ReadableStreamDefaultReader<Uint8Array> | null): void;
|
|
29
42
|
export interface DeviceRouteDeps {
|
|
30
43
|
readonly bearer: BearerAuthDeps;
|
|
31
44
|
readonly root: CloudRootStores;
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export { isTenantId, tenantId } from '@byok-sdk/core';
|
|
|
16
16
|
export type { TenantId } from '@byok-sdk/core';
|
|
17
17
|
export { createByokCloud } from './cloud';
|
|
18
18
|
export type { TaskAgentMessage } from './task-agent-message';
|
|
19
|
-
export type { ByokCloud, ByokCloudOptions, AgentDispatchInput, AgentEgressDispatchInput, AgentEgressFreshSessionDispatchInput, AgentContentReadInput, AgentHomeProjectionInput, AgentHomeProjectionStatusInput, InputPreparationInput, InputPreparationStatusInput, ApproveTaskOptions, EnqueueOfferInput, EnqueueToolsetOfferInput, RejectTaskOptions, EnqueuedAgentControl, EnqueuedAgentHomeProjection, EnqueuedInputPreparation, EnqueuedOffer, TaskOfferReadback, } from './cloud';
|
|
19
|
+
export type { ByokCloud, ByokCloudOptions, AgentDispatchInput, AgentEgressDispatchInput, AgentEgressFreshSessionDispatchInput, AgentContentReadInput, AgentHomeProjectionInput, ProviderProvisioningNoticeInput, AgentMemoryIntentNoticeInput, AgentHomeProjectionStatusInput, InputPreparationInput, InputPreparationStatusInput, ApproveTaskOptions, EnqueueOfferInput, EnqueueToolsetOfferInput, RejectTaskOptions, EnqueuedAgentControl, EnqueuedAgentHomeProjection, EnqueuedInputPreparation, EnqueuedOffer, TaskOfferReadback, } from './cloud';
|
|
20
20
|
export { agentHomeProjectionCompletionKey, agentHomeProjectionRequestKey, readAgentHomeProjectionStatus, recordAgentHomeProjectionCompletion, } from './agent-home-projections';
|
|
21
21
|
export type { AgentHomeProjectionReceiptInput } from './agent-home-projections';
|
|
22
22
|
export { inputPreparationCompletionKey, inputPreparationRequestKey, readInputPreparationStatus, recordInputPreparationCompletion, sameInputPreparationRequest, } from './input-preparations';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BOARD_STATUSES, CapabilityDeclarationSchema, NONCE_SIGNING_DOMAIN, hasCapability, isTenantId, tenantId, principalTenant, parseDeviceProofEnvelope, deviceProofSigningInput, contentHash, parseCapabilityDeclaration, ByokCoreError, tenantKey, PRESENCE_LEVELS, createInMemoryCoreStores, authenticateDeviceAssertion, authenticateTaskAssertion, assertCapability, isCoreConflictError, isCoreError, DEVICE_PROOF_HEADER, TRUTH_RECORD_KINDS, STORAGE_ERROR_CODES, STORAGE_ERROR_HTTP_STATUS } from '@byok-sdk/core';
|
|
2
2
|
export { DEVICE_PROOF_HEADER, NONCE_SIGNING_DOMAIN, isTenantId, tenantId } from '@byok-sdk/core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { AgentEventOrUnknownSchema, AgentMessageServerContextSchema, AgentMessageEgressRequirementSchema, AgentRefSchema, TaskOfferForAgentWithEgressFreshPayloadSchema, PROTOCOL_VERSION, DAEMON_TO_SERVER_TYPES, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, encodeEnvelope, decodeEnvelope, AgentHomeProjectionCompletionRequestSchema, AgentInputPreparationPayloadSchema, InputPreparationCompletionRequestSchema, BYOK_PAIR_PATH, BYOK_CHALLENGE_PATH, BYOK_TOKEN_PATH, BYOK_CAPABILITIES_PATH, BYOK_AGENT_MEMORY_PROJECTIONS_PATH, BYOK_EVENTS_PATH, BYOK_MESSAGES_PATH, BYOK_AGENT_HOME_PROJECTION_COMPLETION_ROUTE, BYOK_INPUT_PREPARATION_COMPLETION_ROUTE, BYOK_INPUT_PREPARATION_STATUS_ROUTE, BYOK_BOARD_PATH, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_BOARD_STATUS_ROUTE, BYOK_BOARD_STREAM_PATH, BYOK_PRESENCE_PATH, BYOK_ACTIVITY_PATH, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, BYOK_BLOBS_PATH, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BLOB_CONTENT_ROUTE, AgentMessagePublishPayloadSchema, isTaskOfferType, MESSAGE_PAYLOAD_SCHEMAS, createEnvelope, AgentHomeProjectionPayloadSchema, AgentContentReadPayloadSchema, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_MESSAGE_EGRESS_CAPABILITY, TERMINAL_PROJECTION_SELECTION_CAPABILITY, TaskOfferForAgentWithEgressPayloadSchema, AGENT_INPUT_PREPARATION_CAPABILITY, AGENT_EGRESS_FRESH_SESSION_CAPABILITY, TaskOfferPreparedPayloadSchema, TaskOfferForAgentPayloadSchema, AgentMemoryProjectionMutationSchema, AgentMemoryProjectionReceiptSchema, AGENT_MEMORY_PROJECTION_MAX_ORDERING_VALUE, AgentMemoryProjectionEraseResultSchema, HarnessIdSchema, STRICT_AGENT_ONLY_CAPABILITY, AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, AGENT_HOME_PROJECTION_CAPABILITY, PairRequestSchema, PairResponseSchema, ChallengeRequestSchema, TokenRequestSchema, AgentMemoryProjectionCommitRequestSchema, agentMemoryProjectionBase64UrlByteLength, MAILBOX_READ_AHEAD_MAX_SEQS, MAILBOX_READ_AHEAD_CAPABILITY, MessagesSendRequestSchema, InputPreparationStatusQuerySchema, PresencePublishRequestSchema, CreateBlobRequestSchema, byokBlobContentPath, AgentMessageDispositionPayloadSchema, AgentEgressAckPayloadSchema, AgentContentReceiptPayloadSchema } from '@byok-sdk/protocol';
|
|
4
|
+
import { AgentEventOrUnknownSchema, AgentMessageServerContextSchema, AgentMessageEgressRequirementSchema, AgentRefSchema, TaskOfferForAgentWithEgressFreshPayloadSchema, PROTOCOL_VERSION, DAEMON_TO_SERVER_TYPES, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, encodeEnvelope, decodeEnvelope, AgentHomeProjectionCompletionRequestSchema, AgentInputPreparationPayloadSchema, InputPreparationCompletionRequestSchema, BYOK_PAIR_PATH, BYOK_CHALLENGE_PATH, BYOK_TOKEN_PATH, BYOK_CAPABILITIES_PATH, BYOK_AGENT_MEMORY_PROJECTIONS_PATH, BYOK_EVENTS_PATH, BYOK_MESSAGES_PATH, BYOK_AGENT_HOME_PROJECTION_COMPLETION_ROUTE, BYOK_INPUT_PREPARATION_COMPLETION_ROUTE, BYOK_INPUT_PREPARATION_STATUS_ROUTE, BYOK_BOARD_PATH, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_BOARD_STATUS_ROUTE, BYOK_BOARD_STREAM_PATH, BYOK_PRESENCE_PATH, BYOK_ACTIVITY_PATH, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, BYOK_BLOBS_PATH, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BLOB_CONTENT_ROUTE, AgentMessagePublishPayloadSchema, isTaskOfferType, MESSAGE_PAYLOAD_SCHEMAS, createEnvelope, AgentMemoryIntentAvailablePayloadSchema, ProviderProvisioningAvailablePayloadSchema, AgentHomeProjectionPayloadSchema, AgentContentReadPayloadSchema, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_MESSAGE_EGRESS_CAPABILITY, TERMINAL_PROJECTION_SELECTION_CAPABILITY, TaskOfferForAgentWithEgressPayloadSchema, AGENT_INPUT_PREPARATION_CAPABILITY, AGENT_EGRESS_FRESH_SESSION_CAPABILITY, TaskOfferPreparedPayloadSchema, TaskOfferForAgentPayloadSchema, AgentMemoryProjectionMutationSchema, AgentMemoryProjectionReceiptSchema, AGENT_MEMORY_PROJECTION_MAX_ORDERING_VALUE, AgentMemoryProjectionEraseResultSchema, HarnessIdSchema, STRICT_AGENT_ONLY_CAPABILITY, AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, AGENT_HOME_PROJECTION_CAPABILITY, AGENT_MEMORY_INTENT_CAPABILITY, PROVIDER_PROVISIONING_CAPABILITY, PairRequestSchema, PairResponseSchema, ChallengeRequestSchema, TokenRequestSchema, AgentMemoryProjectionCommitRequestSchema, agentMemoryProjectionBase64UrlByteLength, MAILBOX_READ_AHEAD_MAX_SEQS, MAILBOX_READ_AHEAD_CAPABILITY, MessagesSendRequestSchema, InputPreparationStatusQuerySchema, PresencePublishRequestSchema, CreateBlobRequestSchema, byokBlobContentPath, AgentMessageDispositionPayloadSchema, AgentEgressAckPayloadSchema, AgentContentReceiptPayloadSchema } from '@byok-sdk/protocol';
|
|
5
5
|
import { Hono } from 'hono';
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
@@ -1217,7 +1217,7 @@ var CLOUD_CAPABILITIES = {
|
|
|
1217
1217
|
* DEVICE's only way to discharge a mailbox row this same deployment handed
|
|
1218
1218
|
* it — withholding it would strand the device's redelivery cursor rather
|
|
1219
1219
|
* than degrade a feature. For the same reason the completion route asserts
|
|
1220
|
-
* no DEVICE capability either: the device-level `agent-input-preparation-
|
|
1220
|
+
* no DEVICE capability either: the device-level `agent-input-preparation-v8`
|
|
1221
1221
|
* flag gates ADMISSION (`enqueueInputPreparation`) and nothing else, so an
|
|
1222
1222
|
* unconfigured device is refused a row instead of being handed one whose
|
|
1223
1223
|
* only honest answer — `input_preparation_unconfigured` — it could not then
|
|
@@ -1396,8 +1396,14 @@ async function readBoundedJsonBody(c, maximum) {
|
|
|
1396
1396
|
return { body: void 0, tooLarge: true };
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
|
-
const
|
|
1400
|
-
|
|
1399
|
+
const bytes = await readBoundedRawBody(c.req.raw.body, maximum);
|
|
1400
|
+
return {
|
|
1401
|
+
body: bytes === void 0 || bytes === "too_large" ? void 0 : parseJsonBytes(bytes),
|
|
1402
|
+
tooLarge: bytes === "too_large"
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
async function readBoundedRawBody(stream, maximum) {
|
|
1406
|
+
if (stream === null) return new Uint8Array();
|
|
1401
1407
|
const reader = stream.getReader();
|
|
1402
1408
|
const chunks = [];
|
|
1403
1409
|
let total = 0;
|
|
@@ -1407,14 +1413,14 @@ async function readBoundedJsonBody(c, maximum) {
|
|
|
1407
1413
|
if (done) break;
|
|
1408
1414
|
if (value.byteLength > maximum - total) {
|
|
1409
1415
|
cancelBody(reader);
|
|
1410
|
-
return
|
|
1416
|
+
return "too_large";
|
|
1411
1417
|
}
|
|
1412
1418
|
if (value.byteLength === 0) continue;
|
|
1413
1419
|
chunks.push(value);
|
|
1414
1420
|
total += value.byteLength;
|
|
1415
1421
|
}
|
|
1416
1422
|
} catch {
|
|
1417
|
-
return
|
|
1423
|
+
return void 0;
|
|
1418
1424
|
} finally {
|
|
1419
1425
|
reader.releaseLock();
|
|
1420
1426
|
}
|
|
@@ -1424,7 +1430,7 @@ async function readBoundedJsonBody(c, maximum) {
|
|
|
1424
1430
|
bytes.set(chunk, offset);
|
|
1425
1431
|
offset += chunk.byteLength;
|
|
1426
1432
|
}
|
|
1427
|
-
return
|
|
1433
|
+
return bytes;
|
|
1428
1434
|
}
|
|
1429
1435
|
function cancelBody(body) {
|
|
1430
1436
|
if (body === null) return;
|
|
@@ -2103,8 +2109,12 @@ function boardStreamHandler(deps) {
|
|
|
2103
2109
|
stopped = true;
|
|
2104
2110
|
stopController.abort();
|
|
2105
2111
|
signal.removeEventListener("abort", onAbort);
|
|
2106
|
-
|
|
2107
|
-
|
|
2112
|
+
}).then(
|
|
2113
|
+
() => closeController(controller),
|
|
2114
|
+
(error) => {
|
|
2115
|
+
controller.error(error);
|
|
2116
|
+
}
|
|
2117
|
+
);
|
|
2108
2118
|
},
|
|
2109
2119
|
cancel() {
|
|
2110
2120
|
stopped = true;
|
|
@@ -2630,11 +2640,13 @@ async function readBoundedBody2(c, maximum) {
|
|
|
2630
2640
|
if (length !== void 0) {
|
|
2631
2641
|
const parsed = Number(length);
|
|
2632
2642
|
if (!Number.isSafeInteger(parsed) || parsed < 0) return void 0;
|
|
2633
|
-
if (parsed > maximum)
|
|
2643
|
+
if (parsed > maximum) {
|
|
2644
|
+
cancelBody(c.req.raw.body);
|
|
2645
|
+
return "too_large";
|
|
2646
|
+
}
|
|
2634
2647
|
}
|
|
2635
2648
|
try {
|
|
2636
|
-
|
|
2637
|
-
return bytes.byteLength > maximum ? "too_large" : bytes;
|
|
2649
|
+
return await readBoundedRawBody(c.req.raw.body, maximum);
|
|
2638
2650
|
} catch {
|
|
2639
2651
|
return void 0;
|
|
2640
2652
|
}
|
|
@@ -4060,6 +4072,64 @@ function createByokCloud(options) {
|
|
|
4060
4072
|
return { ...control, status };
|
|
4061
4073
|
},
|
|
4062
4074
|
getInputPreparationStatus,
|
|
4075
|
+
async enqueueProviderProvisioningNotice(tenant, deviceId, input) {
|
|
4076
|
+
const payload = ProviderProvisioningAvailablePayloadSchema.parse(input);
|
|
4077
|
+
await assertAgentCapabilities(tenant, deviceId, [PROVIDER_PROVISIONING_CAPABILITY]);
|
|
4078
|
+
const messageId = uuidFromSha256(
|
|
4079
|
+
await options.crypto.sha256(
|
|
4080
|
+
new TextEncoder().encode(
|
|
4081
|
+
JSON.stringify({
|
|
4082
|
+
domain: "byok:provider-provisioning-notice",
|
|
4083
|
+
tenant,
|
|
4084
|
+
deviceId,
|
|
4085
|
+
requestId: payload.requestId
|
|
4086
|
+
})
|
|
4087
|
+
)
|
|
4088
|
+
)
|
|
4089
|
+
);
|
|
4090
|
+
const control = await enqueueAgentControlEnvelope(
|
|
4091
|
+
tenant,
|
|
4092
|
+
deviceId,
|
|
4093
|
+
messageId,
|
|
4094
|
+
(seq) => createEnvelope("provider.provisioning.available", payload, { id: messageId, seq })
|
|
4095
|
+
);
|
|
4096
|
+
if (control.envelope.type !== "provider.provisioning.available" || control.envelope.payload.requestId !== payload.requestId) {
|
|
4097
|
+
throw new ByokCloudError(
|
|
4098
|
+
"mailbox_receipt_mismatch",
|
|
4099
|
+
`Mailbox message ${messageId} does not carry provider provisioning notice ${payload.requestId}.`
|
|
4100
|
+
);
|
|
4101
|
+
}
|
|
4102
|
+
return control;
|
|
4103
|
+
},
|
|
4104
|
+
async enqueueAgentMemoryIntentNotice(tenant, deviceId, input) {
|
|
4105
|
+
const payload = AgentMemoryIntentAvailablePayloadSchema.parse(input);
|
|
4106
|
+
await assertAgentCapabilities(tenant, deviceId, [AGENT_MEMORY_INTENT_CAPABILITY]);
|
|
4107
|
+
const messageId = uuidFromSha256(
|
|
4108
|
+
await options.crypto.sha256(
|
|
4109
|
+
new TextEncoder().encode(
|
|
4110
|
+
JSON.stringify({
|
|
4111
|
+
domain: "byok:agent-memory-intent-notice",
|
|
4112
|
+
tenant,
|
|
4113
|
+
deviceId,
|
|
4114
|
+
intentId: payload.intentId
|
|
4115
|
+
})
|
|
4116
|
+
)
|
|
4117
|
+
)
|
|
4118
|
+
);
|
|
4119
|
+
const control = await enqueueAgentControlEnvelope(
|
|
4120
|
+
tenant,
|
|
4121
|
+
deviceId,
|
|
4122
|
+
messageId,
|
|
4123
|
+
(seq) => createEnvelope("agent.memory.intent.available", payload, { id: messageId, seq })
|
|
4124
|
+
);
|
|
4125
|
+
if (control.envelope.type !== "agent.memory.intent.available" || control.envelope.payload.intentId !== payload.intentId || control.envelope.payload.agentRef.agentId !== payload.agentRef.agentId || control.envelope.payload.agentRef.profileRevision !== payload.agentRef.profileRevision) {
|
|
4126
|
+
throw new ByokCloudError(
|
|
4127
|
+
"mailbox_receipt_mismatch",
|
|
4128
|
+
`Mailbox message ${messageId} does not carry Agent memory intent notice ${payload.intentId} for this Agent.`
|
|
4129
|
+
);
|
|
4130
|
+
}
|
|
4131
|
+
return control;
|
|
4132
|
+
},
|
|
4063
4133
|
completeInputPreparation,
|
|
4064
4134
|
eraseAgentMemoryProjection,
|
|
4065
4135
|
approveTask(tenant, taskId, opts) {
|