@byok-sdk/cloud 0.6.1 → 0.8.0-beta.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/cloud.d.ts +14 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/cloud.d.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
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';
|
|
18
18
|
import type { ActivityTail } from './activity';
|
|
19
19
|
import type { ApprovalTimelineTail } from './approval-timeline';
|
|
20
|
-
import { type Envelope, type AgentContentReadPayload, type TaskOfferPayload, type TaskOfferForAgentPayload, type TaskOfferForAgentWithEgressPayload, type TaskOfferWithToolsetsPayload } from '@byok-sdk/protocol';
|
|
20
|
+
import { type Envelope, type AgentContentReadPayload, type TaskOfferPayload, type TaskOfferForAgentPayload, type TaskOfferForAgentWithEgressPayload, type TaskOfferForAgentWithEgressFreshPayload, type TaskOfferWithToolsetsPayload } from '@byok-sdk/protocol';
|
|
21
21
|
import type { TokenSigner } from './auth/tokens';
|
|
22
22
|
import type { CloudCrypto } from './crypto/port';
|
|
23
23
|
import { type RouteDescriptor } from './router/registry';
|
|
@@ -114,6 +114,13 @@ export interface AgentEgressDispatchInput {
|
|
|
114
114
|
readonly taskId?: string;
|
|
115
115
|
readonly payload: TaskOfferForAgentWithEgressPayload;
|
|
116
116
|
}
|
|
117
|
+
/** Strict Agent dispatch whose selected runtime mints its session after start. */
|
|
118
|
+
export interface AgentEgressFreshSessionDispatchInput {
|
|
119
|
+
/** Supply one to make the enqueue addressable by the host's own id; otherwise cloud mints one. */
|
|
120
|
+
readonly taskId?: string;
|
|
121
|
+
/** Deliberately session-free strict payload for the fresh-runtime path. */
|
|
122
|
+
readonly payload: TaskOfferForAgentWithEgressFreshPayload;
|
|
123
|
+
}
|
|
117
124
|
/** A task-free, independently capability-gated Agent content read. */
|
|
118
125
|
export interface AgentContentReadInput {
|
|
119
126
|
readonly payload: AgentContentReadPayload;
|
|
@@ -165,6 +172,12 @@ export interface ByokCloud {
|
|
|
165
172
|
* egress/reliable-ack capabilities reject before a mailbox row is allocated.
|
|
166
173
|
*/
|
|
167
174
|
enqueueAgentEgressOffer(tenant: TenantId, deviceId: string, input: AgentEgressDispatchInput): Promise<EnqueuedOffer>;
|
|
175
|
+
/**
|
|
176
|
+
* Host control plane: enqueue the distinct fresh-session egress offer.
|
|
177
|
+
* The device must durably advertise fresh-session support before task or
|
|
178
|
+
* mailbox reservation, so older resume-only daemons never receive it.
|
|
179
|
+
*/
|
|
180
|
+
enqueueFreshAgentEgressOffer(tenant: TenantId, deviceId: string, input: AgentEgressFreshSessionDispatchInput): Promise<EnqueuedOffer>;
|
|
168
181
|
/** Host control plane: request one policy-bound content read without a task fallback. */
|
|
169
182
|
enqueueAgentContentRead(tenant: TenantId, deviceId: string, input: AgentContentReadInput): Promise<EnqueuedAgentControl>;
|
|
170
183
|
/** Host control plane: durably request cancellation by tenant/task id. Idempotent. */
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
export { isTenantId, tenantId } from '@byok-sdk/core';
|
|
16
16
|
export type { TenantId } from '@byok-sdk/core';
|
|
17
17
|
export { createByokCloud } from './cloud';
|
|
18
|
-
export type { ByokCloud, ByokCloudOptions, AgentDispatchInput, AgentEgressDispatchInput, AgentContentReadInput, EnqueueOfferInput, EnqueueToolsetOfferInput, EnqueuedAgentControl, EnqueuedOffer, } from './cloud';
|
|
18
|
+
export type { ByokCloud, ByokCloudOptions, AgentDispatchInput, AgentEgressDispatchInput, AgentEgressFreshSessionDispatchInput, AgentContentReadInput, EnqueueOfferInput, EnqueueToolsetOfferInput, EnqueuedAgentControl, EnqueuedOffer, } from './cloud';
|
|
19
19
|
export { AGENT_HOME_CONTRACT_CAPABILITY, DEFAULT_EVENTS_PAGE_LIMIT, DEFAULT_LONG_POLL_HOLD_MS, DEFAULT_LONG_POLL_INTERVAL_MS, DEFAULT_MAX_BLOB_SIZE_BYTES, } from './cloud';
|
|
20
20
|
export { DEFAULT_BOARD_PAGE_LIMIT, DEFAULT_BOARD_STREAM_HEARTBEAT_INTERVAL_MS, DEFAULT_BOARD_STREAM_QUERY_INTERVAL_MS, DEFAULT_BOARD_STREAM_RECONCILIATION_INTERVAL_MS, } from './handlers/board';
|
|
21
21
|
export { DEFAULT_SKILL_PACK_PAGE_LIMIT } from './handlers/skill-packs';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BOARD_STATUSES, CapabilityDeclarationSchema, NONCE_SIGNING_DOMAIN, hasCapability, isTenantId, tenantId, principalTenant, parseDeviceProofEnvelope, deviceProofSigningInput, contentHash, parseCapabilityDeclaration, ByokCoreError, tenantKey, PRESENCE_LEVELS, createInMemoryCoreStores, authenticateDeviceAssertion, 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
|
-
import { AgentEventOrUnknownSchema, PROTOCOL_VERSION, DAEMON_TO_SERVER_TYPES, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, encodeEnvelope, decodeEnvelope, BYOK_PAIR_PATH, BYOK_CHALLENGE_PATH, BYOK_TOKEN_PATH, BYOK_CAPABILITIES_PATH, BYOK_EVENTS_PATH, BYOK_MESSAGES_PATH, 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, createEnvelope, AgentContentReadPayloadSchema, AGENT_EGRESS_POLICY_CAPABILITY, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferForAgentPayloadSchema, AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, PairRequestSchema, ChallengeRequestSchema, TokenRequestSchema, MessagesSendRequestSchema, PresencePublishRequestSchema, CreateBlobRequestSchema, byokBlobContentPath, AgentEgressAckPayloadSchema, AgentContentReceiptPayloadSchema } from '@byok-sdk/protocol';
|
|
3
|
+
import { AgentEventOrUnknownSchema, PROTOCOL_VERSION, DAEMON_TO_SERVER_TYPES, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, encodeEnvelope, decodeEnvelope, BYOK_PAIR_PATH, BYOK_CHALLENGE_PATH, BYOK_TOKEN_PATH, BYOK_CAPABILITIES_PATH, BYOK_EVENTS_PATH, BYOK_MESSAGES_PATH, 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, createEnvelope, AgentContentReadPayloadSchema, AGENT_EGRESS_POLICY_CAPABILITY, TaskOfferForAgentWithEgressFreshPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferForAgentPayloadSchema, AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, AGENT_EGRESS_FRESH_SESSION_CAPABILITY, PairRequestSchema, PairResponseSchema, ChallengeRequestSchema, TokenRequestSchema, MessagesSendRequestSchema, PresencePublishRequestSchema, CreateBlobRequestSchema, byokBlobContentPath, AgentEgressAckPayloadSchema, AgentContentReceiptPayloadSchema } from '@byok-sdk/protocol';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { Hono } from 'hono';
|
|
6
6
|
|
|
@@ -750,7 +750,12 @@ function pairHandler(deps) {
|
|
|
750
750
|
const device = await deps.auth.redeemAndRegister(parsed.data);
|
|
751
751
|
if (device === void 0) return c.json({ error: "invalid pairing code" }, 401);
|
|
752
752
|
const { accessToken, expiresAt } = await deps.auth.mintAccessToken(device);
|
|
753
|
-
const response = {
|
|
753
|
+
const response = PairResponseSchema.parse({
|
|
754
|
+
deviceId: device.deviceId,
|
|
755
|
+
accessToken,
|
|
756
|
+
refreshHint: expiresAt,
|
|
757
|
+
tenantId: device.tenantId
|
|
758
|
+
});
|
|
754
759
|
return c.json(response, 200);
|
|
755
760
|
};
|
|
756
761
|
}
|
|
@@ -788,6 +793,7 @@ var CLOUD_PROTOCOL_CAPABILITIES = [
|
|
|
788
793
|
"agent-home-contract",
|
|
789
794
|
"agent-egress-policy",
|
|
790
795
|
"agent-egress-reliable-ack",
|
|
796
|
+
"agent-egress-fresh-session",
|
|
791
797
|
"agent-content-workspace-read",
|
|
792
798
|
"agent-content-transcript-read",
|
|
793
799
|
"agent-content-artifact-read"
|
|
@@ -823,13 +829,13 @@ function eventsHandler(deps) {
|
|
|
823
829
|
if (page.messages.length === 0) break;
|
|
824
830
|
const decoded = page.messages.map((message) => decodeEnvelope(message.body));
|
|
825
831
|
const offeredTaskIds = decoded.flatMap(
|
|
826
|
-
(event) => (event.type === "task.offer" || event.type === "task.offer_with_toolsets" || event.type === "task.offer_for_agent" || event.type === "task.offer_for_agent_with_egress") && event.task_id !== void 0 ? [event.task_id] : []
|
|
832
|
+
(event) => (event.type === "task.offer" || event.type === "task.offer_with_toolsets" || event.type === "task.offer_for_agent" || event.type === "task.offer_for_agent_with_egress" || event.type === "task.offer_for_agent_with_egress_fresh") && event.task_id !== void 0 ? [event.task_id] : []
|
|
827
833
|
);
|
|
828
834
|
const attemptsByTaskId = Object.fromEntries(
|
|
829
835
|
(await stores.tasks.getMany(offeredTaskIds)).map((attempt2) => [attempt2.taskId, attempt2])
|
|
830
836
|
);
|
|
831
837
|
const events = decoded.filter((event) => {
|
|
832
|
-
if (event.type !== "task.offer" && event.type !== "task.offer_with_toolsets" && event.type !== "task.offer_for_agent" && event.type !== "task.offer_for_agent_with_egress") {
|
|
838
|
+
if (event.type !== "task.offer" && event.type !== "task.offer_with_toolsets" && event.type !== "task.offer_for_agent" && event.type !== "task.offer_for_agent_with_egress" && event.type !== "task.offer_for_agent_with_egress_fresh") {
|
|
833
839
|
return true;
|
|
834
840
|
}
|
|
835
841
|
return event.task_id === void 0 || attemptsByTaskId[event.task_id]?.cancellation === void 0;
|
|
@@ -2423,6 +2429,22 @@ function createByokCloud(options) {
|
|
|
2423
2429
|
(taskId, seq, messageId) => createEnvelope("task.offer_for_agent_with_egress", payload, { id: messageId, taskId, seq })
|
|
2424
2430
|
);
|
|
2425
2431
|
},
|
|
2432
|
+
async enqueueFreshAgentEgressOffer(tenant, deviceId, input) {
|
|
2433
|
+
await assertAgentCapabilities(tenant, deviceId, [
|
|
2434
|
+
AGENT_HOME_CONTRACT_CAPABILITY,
|
|
2435
|
+
AGENT_EGRESS_POLICY_CAPABILITY,
|
|
2436
|
+
AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,
|
|
2437
|
+
AGENT_EGRESS_FRESH_SESSION_CAPABILITY
|
|
2438
|
+
]);
|
|
2439
|
+
const payload = TaskOfferForAgentWithEgressFreshPayloadSchema.parse(input.payload);
|
|
2440
|
+
return enqueueTaskEnvelope(
|
|
2441
|
+
tenant,
|
|
2442
|
+
deviceId,
|
|
2443
|
+
input.taskId,
|
|
2444
|
+
payload.agentRef,
|
|
2445
|
+
(taskId, seq, messageId) => createEnvelope("task.offer_for_agent_with_egress_fresh", payload, { id: messageId, taskId, seq })
|
|
2446
|
+
);
|
|
2447
|
+
},
|
|
2426
2448
|
async enqueueAgentContentRead(tenant, deviceId, input) {
|
|
2427
2449
|
const payload = AgentContentReadPayloadSchema.parse(input.payload);
|
|
2428
2450
|
await assertAgentCapabilities(tenant, deviceId, [
|