@byok-sdk/cloud 0.20.0 → 0.22.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/dist/capabilities.d.ts +1 -1
- package/dist/cloud.d.ts +3 -1
- package/dist/index.js +29 -25
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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-v7`
|
|
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
|
@@ -171,6 +171,8 @@ export interface PreparedDispatchInput {
|
|
|
171
171
|
readonly taskId?: string;
|
|
172
172
|
/** Instruction-free strict payload naming the preparation this Execution consumes. */
|
|
173
173
|
readonly payload: TaskOfferPreparedPayload;
|
|
174
|
+
/** Host-only destination/freshness authority; never serialized to the daemon. */
|
|
175
|
+
readonly agentMessageContext?: AgentMessageServerContext;
|
|
174
176
|
}
|
|
175
177
|
/** Strict Agent dispatch that supplies the policy consumed by the typed egress lanes. */
|
|
176
178
|
export interface AgentEgressDispatchInput {
|
|
@@ -283,7 +285,7 @@ export interface ByokCloud {
|
|
|
283
285
|
* Host control plane: enqueue an offer for an already-counted preparation.
|
|
284
286
|
*
|
|
285
287
|
* Admission requires the device to durably advertise both the Agent-home
|
|
286
|
-
* contract and `agent-input-preparation-
|
|
288
|
+
* contract and `agent-input-preparation-v7` — the second because only a device
|
|
287
289
|
* that can prepare holds the durable record this offer names. A device that
|
|
288
290
|
* advertises neither never receives the message, and a device whose protocol
|
|
289
291
|
* build predates the type skips it whole rather than running it as an
|
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, 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,
|
|
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';
|
|
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-v7`
|
|
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
|
|
@@ -3790,6 +3790,25 @@ function createByokCloud(options) {
|
|
|
3790
3790
|
throw new ByokCloudError("mailbox_receipt_mismatch", "Agent message disposition mailbox readback mismatched.");
|
|
3791
3791
|
}
|
|
3792
3792
|
}
|
|
3793
|
+
function agentMessageOfferWriter(deviceId, payload, context) {
|
|
3794
|
+
if (payload.messageEgress === void 0) {
|
|
3795
|
+
if (context !== void 0) throw new Error("agentMessageContext requires messageEgress");
|
|
3796
|
+
return void 0;
|
|
3797
|
+
}
|
|
3798
|
+
const messageContext = AgentMessageServerContextSchema.parse(context);
|
|
3799
|
+
const body = JSON.stringify({
|
|
3800
|
+
agentRef: payload.agentRef,
|
|
3801
|
+
...payload.sessionRef === void 0 ? {} : { sessionRef: payload.sessionRef },
|
|
3802
|
+
requirement: payload.messageEgress,
|
|
3803
|
+
context: messageContext
|
|
3804
|
+
});
|
|
3805
|
+
return async (stores, taskId) => {
|
|
3806
|
+
const recorded = await stores.receipts.record({ key: `agent-message-offer:${deviceId}:${taskId}`, body });
|
|
3807
|
+
if (!recorded.created && recorded.receipt.body !== body) {
|
|
3808
|
+
throw new ByokCloudError("agent_content_request_mismatch", `Task ${taskId} already has a different Agent message context.`);
|
|
3809
|
+
}
|
|
3810
|
+
};
|
|
3811
|
+
}
|
|
3793
3812
|
async function enqueueFreshAgentEgressOffer(tenant, deviceId, input) {
|
|
3794
3813
|
await assertAgentCapabilities(tenant, deviceId, [
|
|
3795
3814
|
AGENT_HOME_CONTRACT_CAPABILITY,
|
|
@@ -3800,23 +3819,13 @@ function createByokCloud(options) {
|
|
|
3800
3819
|
...input.payload.terminalProjection === void 0 ? [] : [TERMINAL_PROJECTION_SELECTION_CAPABILITY]
|
|
3801
3820
|
]);
|
|
3802
3821
|
const payload = TaskOfferForAgentWithEgressFreshPayloadSchema.parse(input.payload);
|
|
3803
|
-
if (payload.messageEgress === void 0 && input.agentMessageContext !== void 0) {
|
|
3804
|
-
throw new Error("agentMessageContext requires messageEgress");
|
|
3805
|
-
}
|
|
3806
|
-
const messageContext = payload.messageEgress === void 0 ? void 0 : AgentMessageServerContextSchema.parse(input.agentMessageContext);
|
|
3807
3822
|
const enqueued = await enqueueTaskEnvelope(
|
|
3808
3823
|
tenant,
|
|
3809
3824
|
deviceId,
|
|
3810
3825
|
input.taskId,
|
|
3811
3826
|
payload.agentRef,
|
|
3812
3827
|
(taskId, seq, messageId) => createEnvelope("task.offer_for_agent_with_egress_fresh", payload, { id: messageId, taskId, seq }),
|
|
3813
|
-
|
|
3814
|
-
const body = JSON.stringify({ agentRef: payload.agentRef, requirement: payload.messageEgress, context: messageContext });
|
|
3815
|
-
const recorded = await stores.receipts.record({ key: `agent-message-offer:${deviceId}:${taskId}`, body });
|
|
3816
|
-
if (!recorded.created && recorded.receipt.body !== body) {
|
|
3817
|
-
throw new ByokCloudError("agent_content_request_mismatch", `Task ${taskId} already has a different Agent message context.`);
|
|
3818
|
-
}
|
|
3819
|
-
}
|
|
3828
|
+
agentMessageOfferWriter(deviceId, payload, input.agentMessageContext)
|
|
3820
3829
|
);
|
|
3821
3830
|
return enqueued;
|
|
3822
3831
|
}
|
|
@@ -3866,6 +3875,10 @@ function createByokCloud(options) {
|
|
|
3866
3875
|
await assertAgentCapabilities(tenant, deviceId, [
|
|
3867
3876
|
AGENT_HOME_CONTRACT_CAPABILITY,
|
|
3868
3877
|
AGENT_INPUT_PREPARATION_CAPABILITY,
|
|
3878
|
+
AGENT_EGRESS_POLICY_CAPABILITY,
|
|
3879
|
+
AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,
|
|
3880
|
+
AGENT_EGRESS_FRESH_SESSION_CAPABILITY,
|
|
3881
|
+
...input.payload.messageEgress === void 0 ? [] : [AGENT_MESSAGE_EGRESS_CAPABILITY],
|
|
3869
3882
|
...input.payload.terminalProjection === void 0 ? [] : [TERMINAL_PROJECTION_SELECTION_CAPABILITY]
|
|
3870
3883
|
]);
|
|
3871
3884
|
const payload = TaskOfferPreparedPayloadSchema.parse(input.payload);
|
|
@@ -3874,7 +3887,8 @@ function createByokCloud(options) {
|
|
|
3874
3887
|
deviceId,
|
|
3875
3888
|
input.taskId,
|
|
3876
3889
|
payload.agentRef,
|
|
3877
|
-
(taskId, seq, messageId) => createEnvelope("task.offer_prepared", payload, { id: messageId, taskId, seq })
|
|
3890
|
+
(taskId, seq, messageId) => createEnvelope("task.offer_prepared", payload, { id: messageId, taskId, seq }),
|
|
3891
|
+
agentMessageOfferWriter(deviceId, payload, input.agentMessageContext)
|
|
3878
3892
|
);
|
|
3879
3893
|
},
|
|
3880
3894
|
async enqueueAgentEgressOffer(tenant, deviceId, input) {
|
|
@@ -3886,23 +3900,13 @@ function createByokCloud(options) {
|
|
|
3886
3900
|
...input.payload.terminalProjection === void 0 ? [] : [TERMINAL_PROJECTION_SELECTION_CAPABILITY]
|
|
3887
3901
|
]);
|
|
3888
3902
|
const payload = TaskOfferForAgentWithEgressPayloadSchema.parse(input.payload);
|
|
3889
|
-
if (payload.messageEgress === void 0 && input.agentMessageContext !== void 0) {
|
|
3890
|
-
throw new Error("agentMessageContext requires messageEgress");
|
|
3891
|
-
}
|
|
3892
|
-
const messageContext = payload.messageEgress === void 0 ? void 0 : AgentMessageServerContextSchema.parse(input.agentMessageContext);
|
|
3893
3903
|
const enqueued = await enqueueTaskEnvelope(
|
|
3894
3904
|
tenant,
|
|
3895
3905
|
deviceId,
|
|
3896
3906
|
input.taskId,
|
|
3897
3907
|
payload.agentRef,
|
|
3898
3908
|
(taskId, seq, messageId) => createEnvelope("task.offer_for_agent_with_egress", payload, { id: messageId, taskId, seq }),
|
|
3899
|
-
|
|
3900
|
-
const body = JSON.stringify({ agentRef: payload.agentRef, sessionRef: payload.sessionRef, requirement: payload.messageEgress, context: messageContext });
|
|
3901
|
-
const recorded = await stores.receipts.record({ key: `agent-message-offer:${deviceId}:${taskId}`, body });
|
|
3902
|
-
if (!recorded.created && recorded.receipt.body !== body) {
|
|
3903
|
-
throw new ByokCloudError("agent_content_request_mismatch", `Task ${taskId} already has a different Agent message context.`);
|
|
3904
|
-
}
|
|
3905
|
-
}
|
|
3909
|
+
agentMessageOfferWriter(deviceId, payload, input.agentMessageContext)
|
|
3906
3910
|
);
|
|
3907
3911
|
return enqueued;
|
|
3908
3912
|
},
|