@byok-sdk/cloud 0.5.0 → 0.6.1
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 +53 -8
- package/dist/errors.d.ts +12 -0
- package/dist/handlers/messages.d.ts +11 -0
- package/dist/inbound.d.ts +4 -3
- package/dist/index.d.ts +5 -5
- package/dist/index.js +779 -89
- package/dist/index.js.map +1 -1
- package/dist/stores/in-memory/agent-egress.d.ts +12 -0
- package/dist/stores/in-memory/blobs.d.ts +8 -2
- package/dist/stores/in-memory/device-directory.d.ts +6 -1
- package/dist/stores/in-memory/index.d.ts +3 -1
- package/dist/stores/in-memory/task-attempts.d.ts +27 -6
- package/dist/stores/in-memory/task-cancellations.d.ts +9 -0
- package/dist/stores/ports.d.ts +116 -5
- package/dist/tenant-stores.d.ts +31 -2
- package/dist/terminal-result.d.ts +11 -1
- package/package.json +3 -3
package/dist/cloud.d.ts
CHANGED
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
* quietly undo that — a Running/session map — is asserted absent by
|
|
15
15
|
* `src/__tests__/constraints.test.ts`.
|
|
16
16
|
*/
|
|
17
|
-
import { type BoardItem, type BoardItemInput, type BoardListQuery, type BoardPage, type CapabilityDeclaration, type Clock, type CoreStores, type PresenceHint, type SkillPackStore, type TenantId } from '@byok-sdk/core';
|
|
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 TaskOfferPayload, type TaskOfferWithToolsetsPayload } from '@byok-sdk/protocol';
|
|
20
|
+
import { type Envelope, type AgentContentReadPayload, type TaskOfferPayload, type TaskOfferForAgentPayload, type TaskOfferForAgentWithEgressPayload, 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';
|
|
24
|
-
import type { BlobContentProxy, CloudStores, DeviceRecord, PairingCodeInfo, RequestReceipt, TaskAttempt } from './stores/ports';
|
|
24
|
+
import type { BlobContentProxy, CloudStores, DeviceRecord, AgentEgressRecord, PairingCodeInfo, RequestReceipt, TaskAttempt } from './stores/ports';
|
|
25
25
|
import { type TerminalResult } from './terminal-result';
|
|
26
26
|
import type { TruthCommitter, TruthObjectDownloads } from './truth/contract';
|
|
27
27
|
/** Matches the reference server's ceiling (§7). */
|
|
@@ -32,6 +32,8 @@ export declare const DEFAULT_LONG_POLL_HOLD_MS = 50000;
|
|
|
32
32
|
export declare const DEFAULT_LONG_POLL_INTERVAL_MS = 250;
|
|
33
33
|
/** Rows per `GET /byok/events` response. */
|
|
34
34
|
export declare const DEFAULT_EVENTS_PAGE_LIMIT = 50;
|
|
35
|
+
/** Device capability required by the strict Agent offer path. */
|
|
36
|
+
export declare const AGENT_HOME_CONTRACT_CAPABILITY = "agent-home-contract";
|
|
35
37
|
export interface ByokCloudOptions {
|
|
36
38
|
readonly core: CoreStores;
|
|
37
39
|
readonly cloud: CloudStores;
|
|
@@ -95,6 +97,31 @@ export interface EnqueueToolsetOfferInput {
|
|
|
95
97
|
/** Strict control payload containing logical ids only; executable MCP definitions are not part of this type. */
|
|
96
98
|
readonly payload: TaskOfferWithToolsetsPayload;
|
|
97
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Strict Agent dispatch input. The device path is intentionally a separate
|
|
102
|
+
* argument on {@link ByokCloud.enqueueAgentOffer}; no legacy offer field is
|
|
103
|
+
* interpreted as an Agent placement hint.
|
|
104
|
+
*/
|
|
105
|
+
export interface AgentDispatchInput {
|
|
106
|
+
/** Supply one to make the enqueue addressable by the host's own id; otherwise cloud mints one. */
|
|
107
|
+
readonly taskId?: string;
|
|
108
|
+
/** Strict Agent payload carrying the exact opaque AgentRef. */
|
|
109
|
+
readonly payload: TaskOfferForAgentPayload;
|
|
110
|
+
}
|
|
111
|
+
/** Strict Agent dispatch that supplies the policy consumed by the typed egress lanes. */
|
|
112
|
+
export interface AgentEgressDispatchInput {
|
|
113
|
+
/** Supply one to make the enqueue addressable by the host's own id; otherwise cloud mints one. */
|
|
114
|
+
readonly taskId?: string;
|
|
115
|
+
readonly payload: TaskOfferForAgentWithEgressPayload;
|
|
116
|
+
}
|
|
117
|
+
/** A task-free, independently capability-gated Agent content read. */
|
|
118
|
+
export interface AgentContentReadInput {
|
|
119
|
+
readonly payload: AgentContentReadPayload;
|
|
120
|
+
}
|
|
121
|
+
export interface EnqueuedAgentControl {
|
|
122
|
+
readonly seq: number;
|
|
123
|
+
readonly envelope: Envelope;
|
|
124
|
+
}
|
|
98
125
|
export interface EnqueuedOffer {
|
|
99
126
|
readonly taskId: string;
|
|
100
127
|
/** The per-(tenant, device) delivery seq — the daemon's redelivery cursor position for this envelope. */
|
|
@@ -127,17 +154,33 @@ export interface ByokCloud {
|
|
|
127
154
|
enqueueOffer(tenant: TenantId, deviceId: string, input: EnqueueOfferInput): Promise<EnqueuedOffer>;
|
|
128
155
|
/** Host control plane: enqueue the additive fail-closed offer variant that requires local MCP toolsets. */
|
|
129
156
|
enqueueToolsetOffer(tenant: TenantId, deviceId: string, input: EnqueueToolsetOfferInput): Promise<EnqueuedOffer>;
|
|
157
|
+
/**
|
|
158
|
+
* Host control plane: enqueue a strict Agent offer to an explicit device.
|
|
159
|
+
* Capability admission is read from the durable authenticated device row
|
|
160
|
+
* before either the mailbox append or task-attempt open.
|
|
161
|
+
*/
|
|
162
|
+
enqueueAgentOffer(tenant: TenantId, deviceId: string, input: AgentDispatchInput): Promise<EnqueuedOffer>;
|
|
163
|
+
/**
|
|
164
|
+
* Host control plane: enqueue the typed egress-policy Agent offer. Missing
|
|
165
|
+
* egress/reliable-ack capabilities reject before a mailbox row is allocated.
|
|
166
|
+
*/
|
|
167
|
+
enqueueAgentEgressOffer(tenant: TenantId, deviceId: string, input: AgentEgressDispatchInput): Promise<EnqueuedOffer>;
|
|
168
|
+
/** Host control plane: request one policy-bound content read without a task fallback. */
|
|
169
|
+
enqueueAgentContentRead(tenant: TenantId, deviceId: string, input: AgentContentReadInput): Promise<EnqueuedAgentControl>;
|
|
170
|
+
/** Host control plane: durably request cancellation by tenant/task id. Idempotent. */
|
|
171
|
+
cancelTask(tenant: TenantId, taskId: string, reason?: string): Promise<TaskAttempt>;
|
|
130
172
|
readTaskAttempt(tenant: TenantId, taskId: string): Promise<TaskAttempt | undefined>;
|
|
131
173
|
/** The recorded terminal for a task — the first one, re-encoded canonically under the frozen v1 codec (see `recordTerminal`, `inbound.ts`: the stored body is `encodeEnvelope` of the zod-parsed envelope, not the device's original byte sequence). */
|
|
132
174
|
readTerminalReceipt(tenant: TenantId, taskId: string): Promise<RequestReceipt | undefined>;
|
|
175
|
+
/** Exact durable egress fact and receipt selected by (tenant, device, event id). */
|
|
176
|
+
readAgentEgress(tenant: TenantId, deviceId: string, eventId: string): Promise<AgentEgressRecord | undefined>;
|
|
133
177
|
/**
|
|
134
178
|
* Host control plane: the same first terminal, decoded into the typed read
|
|
135
179
|
* model ({@link TerminalResult}) so a host reads result fields, not envelope
|
|
136
|
-
* prose.
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* for that attempt status. An absent `document` covers both a legacy
|
|
180
|
+
* prose. An accepted host cancellation tombstone outranks a later device
|
|
181
|
+
* receipt; the raw receipt remains readable as device evidence through
|
|
182
|
+
* {@link ByokCloud.readTerminalReceipt}. `undefined` means neither fact
|
|
183
|
+
* exists. An absent `document` covers both a legacy
|
|
141
184
|
* pre-`result-document` daemon build and a daemon with no `resultDocument`
|
|
142
185
|
* extractor; a receipt whose body is not a terminal envelope throws rather
|
|
143
186
|
* than returning a best-effort shape.
|
|
@@ -151,6 +194,8 @@ export interface ByokCloud {
|
|
|
151
194
|
/** Human review authority. Device routes cannot produce `done`. */
|
|
152
195
|
acceptBoardItem(tenant: TenantId, itemId: string): Promise<BoardItem>;
|
|
153
196
|
listPresence(tenant: TenantId): Promise<readonly PresenceHint[]>;
|
|
197
|
+
/** SDK-owned observation only; never a scheduler or execution authority. */
|
|
198
|
+
readTenantReadiness(tenant: TenantId): Promise<TenantReadiness>;
|
|
154
199
|
readActivity(tenant: TenantId, taskId: string): Promise<ActivityTail | undefined>;
|
|
155
200
|
readApprovalTimeline(tenant: TenantId, taskId: string): Promise<ApprovalTimelineTail | undefined>;
|
|
156
201
|
}
|
package/dist/errors.d.ts
CHANGED
|
@@ -41,6 +41,18 @@ export declare const CLOUD_ERROR_CODES: {
|
|
|
41
41
|
readonly terminal_receipt_unreadable: 'terminal_receipt_unreadable';
|
|
42
42
|
/** A progress/activity batch exceeded the configured event or byte ceiling. */
|
|
43
43
|
readonly activity_batch_too_large: 'activity_batch_too_large';
|
|
44
|
+
/** Host control-plane task lookup is tenant-closed and found no task. */
|
|
45
|
+
readonly task_not_found: 'task_not_found';
|
|
46
|
+
/** Durable target-device capability is absent, revoked, or unavailable. */
|
|
47
|
+
readonly agent_capability_missing: 'agent_capability_missing';
|
|
48
|
+
/** Inbound Agent identity did not exactly match the offered identity. */
|
|
49
|
+
readonly agent_ref_mismatch: 'agent_ref_mismatch';
|
|
50
|
+
/** A strict Agent task id already names a durable attempt and cannot be re-enqueued. */
|
|
51
|
+
readonly agent_task_already_exists: 'agent_task_already_exists';
|
|
52
|
+
/** A first-write-wins Agent control record was replayed with a different body. */
|
|
53
|
+
readonly agent_content_request_mismatch: 'agent_content_request_mismatch';
|
|
54
|
+
/** A durable mailbox receipt id resolved to an envelope other than its exact acknowledgement. */
|
|
55
|
+
readonly mailbox_receipt_mismatch: 'mailbox_receipt_mismatch';
|
|
44
56
|
};
|
|
45
57
|
export type CloudErrorCode = (typeof CLOUD_ERROR_CODES)[keyof typeof CLOUD_ERROR_CODES];
|
|
46
58
|
export declare class ByokCloudError extends Error {
|
|
@@ -20,9 +20,20 @@
|
|
|
20
20
|
* `duplicate` for whatever already landed.
|
|
21
21
|
*/
|
|
22
22
|
import type { Context } from 'hono';
|
|
23
|
+
import { type AgentContentReceiptPayload } from '@byok-sdk/protocol';
|
|
23
24
|
import type { ActivityBounds } from '../coordination';
|
|
25
|
+
import type { AgentEgressRecord } from '../stores/ports';
|
|
26
|
+
import type { TenantStores } from '../tenant-stores';
|
|
24
27
|
import { type DeviceRouteDeps } from './shared';
|
|
25
28
|
export interface MessagesRouteDeps extends DeviceRouteDeps {
|
|
26
29
|
readonly activityBounds: ActivityBounds;
|
|
30
|
+
/**
|
|
31
|
+
* The egress fact is committed by the inbound gate first. This callback then
|
|
32
|
+
* puts the exact receipt acknowledgement in the durable core mailbox, so a
|
|
33
|
+
* transport retry cannot turn a committed reliable event into an unacked one.
|
|
34
|
+
*/
|
|
35
|
+
readonly appendReliableEgressAck: (stores: TenantStores, record: AgentEgressRecord) => Promise<void>;
|
|
36
|
+
/** Content receipt rows share the reliable spool/ack protocol but preserve their own exact payload authority. */
|
|
37
|
+
readonly appendContentReceiptAck: (stores: TenantStores, deviceId: string, payload: AgentContentReceiptPayload) => Promise<void>;
|
|
27
38
|
}
|
|
28
39
|
export declare function messagesHandler(deps: MessagesRouteDeps): (c: Context) => Promise<Response>;
|
package/dist/inbound.d.ts
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
* else, so a flood of garbage-typed envelopes costs the same budget as a
|
|
10
10
|
* flood of well-formed ones. S3a's reference limiter allows everything; the
|
|
11
11
|
* seam is what matters at this position.
|
|
12
|
-
* 1. **type-allow** — only `DAEMON_TO_SERVER_TYPES` may pass
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* 1. **type-allow** — only `DAEMON_TO_SERVER_TYPES` may pass, plus the
|
|
13
|
+
* authenticated long-poll `conn.hello` capability snapshot handled below.
|
|
14
|
+
* A server -> daemon type arriving inbound, or anything unrecognized, is
|
|
15
|
+
* rejected before it is dispatched or counted accepted.
|
|
15
16
|
* 2. **ownership** — an envelope for a task already owned by a DIFFERENT
|
|
16
17
|
* device is dropped, never force-failed: force-failing on an authz mismatch
|
|
17
18
|
* would let an attacker who merely guesses a `taskId` kill the real owner's
|
package/dist/index.d.ts
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
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, EnqueueOfferInput, EnqueueToolsetOfferInput, EnqueuedOffer, } from './cloud';
|
|
19
|
-
export { DEFAULT_EVENTS_PAGE_LIMIT, DEFAULT_LONG_POLL_HOLD_MS, DEFAULT_LONG_POLL_INTERVAL_MS, DEFAULT_MAX_BLOB_SIZE_BYTES, } from './cloud';
|
|
18
|
+
export type { ByokCloud, ByokCloudOptions, AgentDispatchInput, AgentEgressDispatchInput, AgentContentReadInput, EnqueueOfferInput, EnqueueToolsetOfferInput, EnqueuedAgentControl, EnqueuedOffer, } from './cloud';
|
|
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';
|
|
22
22
|
export { createInMemoryByokCloud } from './composition/in-memory';
|
|
@@ -59,8 +59,8 @@ export { DEFAULT_MAX_TRUTH_REQUEST_BYTES, DEVICE_PROOF_HEADER, MAX_DEVICE_PROOF_
|
|
|
59
59
|
export type { PreparedTruthWrite, TruthBodyInput, TruthCommitInput, TruthCommitResponse, TruthCommitResult, TruthCommitter, TruthObjectDownloads, TruthRecordMetadata, TruthWriteRequest, } from './truth/contract';
|
|
60
60
|
export { TruthCommitError, isTruthCommitError } from './truth/errors';
|
|
61
61
|
export type { TruthCommitErrorCode } from './truth/errors';
|
|
62
|
-
export { CLOUD_STORE_NAMES, TASK_ATTEMPT_STATUSES } from './stores/ports';
|
|
62
|
+
export { BLOB_READ_ERROR_CODES, CLOUD_STORE_NAMES, TASK_ATTEMPT_STATUSES } from './stores/ports';
|
|
63
63
|
export { CLOUD_PORT_INTERFACES, CLOUD_PORT_METHODS } from './stores/ports-contract';
|
|
64
|
-
export type { BlobContent, BlobContentProxy, BlobDeclaration, BlobObservation, BlobWriteResult, CloudBlobStore, CloudStoreName, CloudStores, DeviceDirectory, DeviceRecord, DeviceRegistration, InboundDedupStore, InboundRateLimiter, NonceStore, PairingCodeClaims, PairingCodeInfo, PairingCodeIssueInput, PairingCodeStore, ProofRequestReceipt, ProofRequestReceiptInput, ProofRequestReceiptStore, RequestReceipt, RequestReceiptStore, TaskAttempt, TaskAttemptStatus, TaskAttemptStore, } from './stores/ports';
|
|
65
|
-
export { AllowAllRateLimiter, BLOB_URL_TTL_MS, DEDUP_RING_CAPACITY, InMemoryBlobContentProxy, InMemoryCloudBlobStore, InMemoryActivityStore, InMemoryDeviceDirectory, InMemoryInboundDedupStore, InMemoryNonceStore, InMemoryPairingCodeStore, InMemoryRequestReceiptStore, InMemoryProofRequestReceiptStore, InMemoryTaskAttemptStore, NONCE_TTL_MS, createInMemoryBlobs, createInMemoryCloudStores, } from './stores/in-memory/index';
|
|
64
|
+
export type { BlobContent, BlobContentProxy, BlobDeclaration, BlobObservation, BlobReadErrorCode, BlobReadResult, BlobWriteResult, CloudBlobStore, CloudStoreName, CloudStores, DeviceDirectory, DeviceRecord, DeviceRegistration, InboundDedupStore, InboundRateLimiter, NonceStore, PairingCodeClaims, PairingCodeInfo, PairingCodeIssueInput, PairingCodeStore, ProofRequestReceipt, ProofRequestReceiptInput, ProofRequestReceiptStore, RequestReceipt, RequestReceiptStore, TaskAttempt, TaskAttemptStatus, TaskAttemptStore, AgentRef, AgentEgressRecord, AgentEgressStore, TaskCancellationMutation, TaskCancellationRequest, TaskCancellationStore, } from './stores/ports';
|
|
65
|
+
export { AllowAllRateLimiter, BLOB_URL_TTL_MS, DEDUP_RING_CAPACITY, InMemoryBlobContentProxy, InMemoryCloudBlobStore, InMemoryActivityStore, InMemoryDeviceDirectory, InMemoryInboundDedupStore, InMemoryNonceStore, InMemoryPairingCodeStore, InMemoryRequestReceiptStore, InMemoryAgentEgressStore, InMemoryProofRequestReceiptStore, InMemoryTaskAttemptStore, InMemoryTaskCancellationStore, NONCE_TTL_MS, createInMemoryBlobs, createInMemoryCloudStores, } from './stores/in-memory/index';
|
|
66
66
|
export type { InMemoryBlobStoreOptions, InMemoryBlobs, InMemoryCloudComposition, } from './stores/in-memory/index';
|