@byok-sdk/cloud 0.16.0 → 0.17.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 +13 -0
- package/dist/cloud.d.ts +19 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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
|
@@ -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 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';
|
|
20
|
+
import { type Envelope, type TaskOfferType, 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';
|
|
21
21
|
import type { TokenSigner } from './auth/tokens';
|
|
22
22
|
import type { CloudCrypto } from './crypto/port';
|
|
23
23
|
import { type RouteDescriptor } from './router/registry';
|
|
@@ -199,6 +199,22 @@ export interface EnqueuedAgentControl {
|
|
|
199
199
|
export interface EnqueuedAgentHomeProjection extends EnqueuedAgentControl {
|
|
200
200
|
readonly status: AgentHomeProjectionReadback;
|
|
201
201
|
}
|
|
202
|
+
/** Immutable executable offer authority, independent of mailbox retention. */
|
|
203
|
+
export type TaskOfferReadback = {
|
|
204
|
+
[T in TaskOfferType]: {
|
|
205
|
+
readonly taskId: string;
|
|
206
|
+
readonly deviceId: string;
|
|
207
|
+
readonly messageId: string;
|
|
208
|
+
readonly type: T;
|
|
209
|
+
readonly payload: Extract<Envelope, {
|
|
210
|
+
type: T;
|
|
211
|
+
}>['payload'];
|
|
212
|
+
/** Receipt time, not a transport delivery timestamp. */
|
|
213
|
+
readonly recordedAt: string;
|
|
214
|
+
/** The delivered marker is durable; false is not proof append never happened. */
|
|
215
|
+
readonly delivered: boolean;
|
|
216
|
+
};
|
|
217
|
+
}[TaskOfferType];
|
|
202
218
|
export interface EnqueuedOffer {
|
|
203
219
|
readonly taskId: string;
|
|
204
220
|
/** The per-(tenant, device) delivery seq — the daemon's redelivery cursor position for this envelope. */
|
|
@@ -325,6 +341,8 @@ export interface ByokCloud {
|
|
|
325
341
|
*/
|
|
326
342
|
steerTask(tenant: TenantId, taskId: string, payload: TaskSteerPayload): Promise<EnqueuedAgentControl>;
|
|
327
343
|
readTaskAttempt(tenant: TenantId, taskId: string): Promise<TaskAttempt | undefined>;
|
|
344
|
+
/** Read the original executable offer; missing/corrupt authority never becomes a guessed payload. */
|
|
345
|
+
readTaskOffer(tenant: TenantId, taskId: string): Promise<TaskOfferReadback | undefined>;
|
|
328
346
|
/**
|
|
329
347
|
* Host control plane: one bounded page of this tenant's task attempts,
|
|
330
348
|
* keyset-paged by `taskId` — see {@link TaskAttemptListQuery} for why the key
|
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, AgentEgressFreshSessionDispatchInput, AgentContentReadInput, AgentHomeProjectionInput, AgentHomeProjectionStatusInput, ApproveTaskOptions, EnqueueOfferInput, EnqueueToolsetOfferInput, RejectTaskOptions, EnqueuedAgentControl, EnqueuedAgentHomeProjection, EnqueuedOffer, } from './cloud';
|
|
18
|
+
export type { ByokCloud, ByokCloudOptions, AgentDispatchInput, AgentEgressDispatchInput, AgentEgressFreshSessionDispatchInput, AgentContentReadInput, AgentHomeProjectionInput, AgentHomeProjectionStatusInput, ApproveTaskOptions, EnqueueOfferInput, EnqueueToolsetOfferInput, RejectTaskOptions, EnqueuedAgentControl, EnqueuedAgentHomeProjection, EnqueuedOffer, TaskOfferReadback, } from './cloud';
|
|
19
19
|
export { agentHomeProjectionCompletionKey, agentHomeProjectionRequestKey, readAgentHomeProjectionStatus, recordAgentHomeProjectionCompletion, } from './agent-home-projections';
|
|
20
20
|
export type { AgentHomeProjectionReceiptInput } from './agent-home-projections';
|
|
21
21
|
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';
|
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, AgentHomeProjectionCompletionRequestSchema, 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_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, AgentHomeProjectionPayloadSchema, AgentContentReadPayloadSchema, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_EGRESS_FRESH_SESSION_CAPABILITY, AGENT_MESSAGE_EGRESS_CAPABILITY, TERMINAL_PROJECTION_SELECTION_CAPABILITY, TaskOfferForAgentWithEgressFreshPayloadSchema, AgentMessageServerContextSchema, TaskOfferForAgentWithEgressPayloadSchema, 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, AgentRefSchema, PairRequestSchema, PairResponseSchema, ChallengeRequestSchema, TokenRequestSchema, AgentMemoryProjectionCommitRequestSchema, agentMemoryProjectionBase64UrlByteLength, MAILBOX_READ_AHEAD_MAX_SEQS, MAILBOX_READ_AHEAD_CAPABILITY, 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, AgentHomeProjectionCompletionRequestSchema, 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_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, isTaskOfferType, MESSAGE_PAYLOAD_SCHEMAS, createEnvelope, AgentHomeProjectionPayloadSchema, AgentContentReadPayloadSchema, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_EGRESS_FRESH_SESSION_CAPABILITY, AGENT_MESSAGE_EGRESS_CAPABILITY, TERMINAL_PROJECTION_SELECTION_CAPABILITY, TaskOfferForAgentWithEgressFreshPayloadSchema, AgentMessageServerContextSchema, TaskOfferForAgentWithEgressPayloadSchema, 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, AgentRefSchema, PairRequestSchema, PairResponseSchema, ChallengeRequestSchema, TokenRequestSchema, AgentMemoryProjectionCommitRequestSchema, agentMemoryProjectionBase64UrlByteLength, MAILBOX_READ_AHEAD_MAX_SEQS, MAILBOX_READ_AHEAD_CAPABILITY, MessagesSendRequestSchema, PresencePublishRequestSchema, CreateBlobRequestSchema, byokBlobContentPath, AgentEgressAckPayloadSchema, AgentContentReceiptPayloadSchema } from '@byok-sdk/protocol';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { Hono } from 'hono';
|
|
6
6
|
|
|
@@ -3712,6 +3712,37 @@ function createByokCloud(options) {
|
|
|
3712
3712
|
}
|
|
3713
3713
|
return mutation.attempt;
|
|
3714
3714
|
},
|
|
3715
|
+
async readTaskOffer(tenant, taskId) {
|
|
3716
|
+
const stores = tenantStoresFor(controlPlane(tenant), root);
|
|
3717
|
+
const attempt = await stores.tasks.get(taskId);
|
|
3718
|
+
if (attempt === void 0) return void 0;
|
|
3719
|
+
const messageId = await taskOfferMessageId(tenant, taskId, attempt.deviceId, attempt.agentRef, (bytes) => options.crypto.sha256(bytes));
|
|
3720
|
+
const receipt = await stores.receipts.get(`task-offer:${messageId}`);
|
|
3721
|
+
if (receipt === void 0) return void 0;
|
|
3722
|
+
const invalid = () => new ByokCloudError("coordination_input_invalid", `Task ${taskId} has an unreadable or mismatched immutable offer receipt.`);
|
|
3723
|
+
let stored;
|
|
3724
|
+
try {
|
|
3725
|
+
stored = JSON.parse(receipt.body);
|
|
3726
|
+
} catch {
|
|
3727
|
+
throw invalid();
|
|
3728
|
+
}
|
|
3729
|
+
if (stored === null || typeof stored !== "object" || stored.deviceId !== attempt.deviceId || typeof stored.type !== "string" || !isTaskOfferType(stored.type)) throw invalid();
|
|
3730
|
+
const parsed = MESSAGE_PAYLOAD_SCHEMAS[stored.type].safeParse(stored.payload);
|
|
3731
|
+
if (!parsed.success || JSON.stringify(parsed.data) !== JSON.stringify(stored.payload)) throw invalid();
|
|
3732
|
+
const agentRef = "agentRef" in parsed.data ? parsed.data.agentRef : void 0;
|
|
3733
|
+
if (agentRef === void 0 ? attempt.agentRef !== void 0 : attempt.agentRef === void 0 || !sameAgentRef2(agentRef, attempt.agentRef)) throw invalid();
|
|
3734
|
+
const delivered = await stores.receipts.get(`task-offer-delivered:${messageId}`);
|
|
3735
|
+
if (delivered !== void 0 && delivered.body !== messageId) throw invalid();
|
|
3736
|
+
return {
|
|
3737
|
+
taskId,
|
|
3738
|
+
deviceId: attempt.deviceId,
|
|
3739
|
+
messageId,
|
|
3740
|
+
type: stored.type,
|
|
3741
|
+
payload: parsed.data,
|
|
3742
|
+
recordedAt: receipt.recordedAt,
|
|
3743
|
+
delivered: delivered !== void 0
|
|
3744
|
+
};
|
|
3745
|
+
},
|
|
3715
3746
|
readTaskAttempt(tenant, taskId) {
|
|
3716
3747
|
return tenantStoresFor(controlPlane(tenant), root).tasks.get(taskId);
|
|
3717
3748
|
},
|