@byok-sdk/cloud 0.16.0 → 0.18.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 CHANGED
@@ -69,3 +69,16 @@ stored body is not a terminal envelope throws `ByokCloudError` rather than
69
69
  returning a best-effort shape.
70
70
 
71
71
  MIT licensed. Node.js 22.22.0 or newer.
72
+
73
+
74
+ ## Immutable offer readback
75
+
76
+ `readTaskOffer(tenant, taskId)` reads the immutable offer receipt using the
77
+ TaskAttempt target and stable message identity. It validates the protocol
78
+ payload, target/Agent binding and delivered marker. Corrupt receipts throw;
79
+ missing attempt or missing offer receipt returns undefined. The returned
80
+ recordedAt is receipt time, not transport time; no mailbox sequence is invented.
81
+ A delivered=false read is not evidence that append never happened. Host-only
82
+ message context is a separate authority, not part of this offer projection.
83
+ The API's persistence is that of the injected receipts store: in-memory restart
84
+ and Postgres generic receipt retention are not upgraded by this read method.
package/dist/cloud.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { type TaskAgentMessage } from './task-agent-message';
2
+ import { type RecurringExecutionInput } from './recurring';
1
3
  /**
2
4
  * `createByokCloud` — the hosted device surface, assembled.
3
5
  *
@@ -17,7 +19,7 @@
17
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';
18
20
  import type { ActivityTail } from './activity';
19
21
  import type { ApprovalTimelineTail } from './approval-timeline';
20
- import { type Envelope, type AgentRef, type AgentContentReadPayload, type AgentMessagePublishPayload, type AgentMessageServerContext, type AgentHomeProjectionCompletionRequest, type AgentHomeProjectionPayload, type AgentHomeProjectionReadback, type AgentMemoryProjectionEraseResult, type TaskOfferPayload, type TaskSteerPayload, type TaskOfferForAgentPayload, 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 AgentMemoryProjectionEraseResult, type TaskOfferPayload, type TaskSteerPayload, type TaskOfferForAgentPayload, type TaskOfferForAgentWithEgressPayload, type TaskOfferForAgentWithEgressFreshPayload, type TaskOfferWithToolsetsPayload } from '@byok-sdk/protocol';
21
23
  import type { TokenSigner } from './auth/tokens';
22
24
  import type { CloudCrypto } from './crypto/port';
23
25
  import { type RouteDescriptor } from './router/registry';
@@ -25,7 +27,7 @@ import { type ByokCloudObserver } from './inbound';
25
27
  import { type AgentHomeProjectionReceiptInput } from './agent-home-projections';
26
28
  import type { AgentMemoryProjectionAuthorizer, AgentMemoryProjectionStore } from './agent-memory-projection';
27
29
  import type { BlobContentProxy, CloudStores, DeviceRecord, AgentEgressRecord, PairingCodeInfo, RequestReceipt, TaskAttempt, TaskAttemptListQuery, TaskAttemptPage } from './stores/ports';
28
- import { type TerminalResult } from './terminal-result';
30
+ import { type DeviceTerminal, type TerminalResult } from './terminal-result';
29
31
  import type { TruthCommitter, TruthObjectDownloads } from './truth/contract';
30
32
  /** Matches the reference server's ceiling (§7). */
31
33
  export declare const DEFAULT_MAX_BLOB_SIZE_BYTES: number;
@@ -199,6 +201,22 @@ export interface EnqueuedAgentControl {
199
201
  export interface EnqueuedAgentHomeProjection extends EnqueuedAgentControl {
200
202
  readonly status: AgentHomeProjectionReadback;
201
203
  }
204
+ /** Immutable executable offer authority, independent of mailbox retention. */
205
+ export type TaskOfferReadback = {
206
+ [T in TaskOfferType]: {
207
+ readonly taskId: string;
208
+ readonly deviceId: string;
209
+ readonly messageId: string;
210
+ readonly type: T;
211
+ readonly payload: Extract<Envelope, {
212
+ type: T;
213
+ }>['payload'];
214
+ /** Receipt time, not a transport delivery timestamp. */
215
+ readonly recordedAt: string;
216
+ /** The delivered marker is durable; false is not proof append never happened. */
217
+ readonly delivered: boolean;
218
+ };
219
+ }[TaskOfferType];
202
220
  export interface EnqueuedOffer {
203
221
  readonly taskId: string;
204
222
  /** The per-(tenant, device) delivery seq — the daemon's redelivery cursor position for this envelope. */
@@ -248,6 +266,8 @@ export interface ByokCloud {
248
266
  * mailbox reservation, so older resume-only daemons never receive it.
249
267
  */
250
268
  enqueueFreshAgentEgressOffer(tenant: TenantId, deviceId: string, input: AgentEgressFreshSessionDispatchInput): Promise<EnqueuedOffer>;
269
+ /** Strict recurring execution: caller persists the complete input before submission. */
270
+ submitRecurringExecution(tenant: TenantId, input: RecurringExecutionInput): Promise<EnqueuedOffer>;
251
271
  /** Host control plane: request one policy-bound content read without a task fallback. */
252
272
  enqueueAgentContentRead(tenant: TenantId, deviceId: string, input: AgentContentReadInput): Promise<EnqueuedAgentControl>;
253
273
  /** Durable, task-free projection request for precisely one admitted device. */
@@ -325,6 +345,8 @@ export interface ByokCloud {
325
345
  */
326
346
  steerTask(tenant: TenantId, taskId: string, payload: TaskSteerPayload): Promise<EnqueuedAgentControl>;
327
347
  readTaskAttempt(tenant: TenantId, taskId: string): Promise<TaskAttempt | undefined>;
348
+ /** Read the original executable offer; missing/corrupt authority never becomes a guessed payload. */
349
+ readTaskOffer(tenant: TenantId, taskId: string): Promise<TaskOfferReadback | undefined>;
328
350
  /**
329
351
  * Host control plane: one bounded page of this tenant's task attempts,
330
352
  * keyset-paged by `taskId` — see {@link TaskAttemptListQuery} for why the key
@@ -337,6 +359,16 @@ export interface ByokCloud {
337
359
  listTaskAttempts(tenant: TenantId, query: TaskAttemptListQuery): Promise<TaskAttemptPage>;
338
360
  /** 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). */
339
361
  readTerminalReceipt(tenant: TenantId, taskId: string): Promise<RequestReceipt | undefined>;
362
+ /** Actual device terminal only; cancellation intent never creates this observation. */
363
+ readDeviceTerminal(tenant: TenantId, taskId: string): Promise<DeviceTerminal | undefined>;
364
+ /** Discover first-message transmission evidence from the frozen execution binding, including pending/held without a Host body. */
365
+ readTaskAgentMessage(tenant: TenantId, deviceId: string, taskId: string, agentRef: AgentRef): Promise<TaskAgentMessage | undefined>;
366
+ /**
367
+ * Exact durable message decision, independently of task cancellation/terminal.
368
+ * Missing or pending admission returns undefined; invalid persisted evidence
369
+ * throws. The Host supplies the complete original payload, not a Turn ID.
370
+ */
371
+ readAgentMessageDisposition(tenant: TenantId, deviceId: string, taskId: string, payload: AgentMessagePublishPayload): Promise<AgentMessageDispositionPayload | undefined>;
340
372
  /** Exact durable egress fact and receipt selected by (tenant, device, AgentRef, event id). */
341
373
  readAgentEgress(tenant: TenantId, deviceId: string, agentRef: AgentRef, eventId: string): Promise<AgentEgressRecord | undefined>;
342
374
  /**
package/dist/inbound.d.ts CHANGED
@@ -83,6 +83,7 @@ export declare function handleAgentMessagePublish(stores: TenantStores, deviceId
83
83
  }>;
84
84
  /** Reads only a terminal immutable admission; pending rows have no disposition to acknowledge. */
85
85
  export declare function readAgentMessageDisposition(stores: TenantStores, deviceId: string, taskId: string, payload: AgentMessagePublishPayload): Promise<AgentMessageDispositionPayload | undefined>;
86
+ export declare function parseAgentMessageDisposition(payload: AgentMessagePublishPayload, terminalBody: string): AgentMessageDispositionPayload;
86
87
  /** Receipt key a task's terminal is recorded under — the idempotency seam S3b's journal will share. */
87
88
  export declare function terminalReceiptKey(taskId: string): string;
88
89
  export declare function handleInboundEnvelope(stores: TenantStores, deviceId: string, envelope: Envelope, activityBounds?: ActivityBounds, agentMessageConsume?: Parameters<typeof handleAgentMessagePublish>[4], observer?: ByokCloudObserver): Promise<InboundOutcome>;
package/dist/index.d.ts CHANGED
@@ -15,7 +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, AgentDispatchInput, AgentEgressDispatchInput, AgentEgressFreshSessionDispatchInput, AgentContentReadInput, AgentHomeProjectionInput, AgentHomeProjectionStatusInput, ApproveTaskOptions, EnqueueOfferInput, EnqueueToolsetOfferInput, RejectTaskOptions, EnqueuedAgentControl, EnqueuedAgentHomeProjection, EnqueuedOffer, } from './cloud';
18
+ export type { TaskAgentMessage } from './task-agent-message';
19
+ export type { ByokCloud, ByokCloudOptions, AgentDispatchInput, AgentEgressDispatchInput, AgentEgressFreshSessionDispatchInput, AgentContentReadInput, AgentHomeProjectionInput, AgentHomeProjectionStatusInput, ApproveTaskOptions, EnqueueOfferInput, EnqueueToolsetOfferInput, RejectTaskOptions, EnqueuedAgentControl, EnqueuedAgentHomeProjection, EnqueuedOffer, TaskOfferReadback, } from './cloud';
19
20
  export { agentHomeProjectionCompletionKey, agentHomeProjectionRequestKey, readAgentHomeProjectionStatus, recordAgentHomeProjectionCompletion, } from './agent-home-projections';
20
21
  export type { AgentHomeProjectionReceiptInput } from './agent-home-projections';
21
22
  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';
@@ -72,3 +73,5 @@ export { CLOUD_PORT_INTERFACES, CLOUD_PORT_METHODS } from './stores/ports-contra
72
73
  export type { BlobContent, BlobContentProxy, BlobDeclaration, BlobObservation, BlobReadErrorCode, BlobReadResult, BlobWriteResult, CloudBlobStore, CloudStoreName, CloudStores, DeviceDirectory, DeviceRecord, DeviceRegistration, InboundDedupStore, InboundRateLimiter, NonceStore, PairingCodeClaims, PairingCodeInfo, PairingCodeIssueInput, PairingCodeStore, PairingEnrollment, PairingEnrollmentInput, ProofRequestReceipt, ProofRequestReceiptInput, ProofRequestReceiptStore, RequestReceipt, RequestReceiptStore, TaskAttempt, TaskAttemptListQuery, TaskAttemptPage, TaskAttemptStatus, TaskAttemptStore, AgentRef, AgentEgressRecord, AgentEgressStore, AgentMessageAdmission, TaskCancellationMutation, TaskCancellationRequest, TaskCancellationStore, } from './stores/ports';
73
74
  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';
74
75
  export type { InMemoryBlobStoreOptions, InMemoryBlobs, InMemoryCloudComposition, } from './stores/in-memory/index';
76
+ export type { DeviceTerminal } from './terminal-result';
77
+ export { RecurringExecutionInputSchema, type RecurringExecutionInput } from './recurring';