@byok-sdk/cloud 0.4.1 → 0.4.2

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.
@@ -0,0 +1,122 @@
1
+ import { type TenantId } from '@byok-sdk/core';
2
+ import { type AgentEventOrUnknown } from '@byok-sdk/protocol';
3
+ import { z } from 'zod';
4
+ export declare const DEFAULT_ACTIVITY_CAPACITY = 50;
5
+ export declare const ActivityAppendRequestSchema: z.ZodObject<{
6
+ taskId: z.ZodString;
7
+ sourceEnvelopeId: z.ZodString;
8
+ batchSeq: z.ZodNumber;
9
+ events: z.ZodArray<z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
10
+ type: z.ZodLiteral<"progress">;
11
+ text: z.ZodString;
12
+ }, z.core.$strip>, z.ZodObject<{
13
+ type: z.ZodLiteral<"tool_use">;
14
+ tool: z.ZodString;
15
+ input: z.ZodOptional<z.ZodUnknown>;
16
+ toolCallId: z.ZodOptional<z.ZodString>;
17
+ }, z.core.$strip>, z.ZodObject<{
18
+ type: z.ZodLiteral<"tool_result">;
19
+ tool: z.ZodString;
20
+ output: z.ZodOptional<z.ZodUnknown>;
21
+ toolCallId: z.ZodOptional<z.ZodString>;
22
+ isError: z.ZodOptional<z.ZodBoolean>;
23
+ }, z.core.$strip>, z.ZodObject<{
24
+ type: z.ZodLiteral<"artifact">;
25
+ name: z.ZodString;
26
+ contentType: z.ZodString;
27
+ }, z.core.$strip>, z.ZodObject<{
28
+ type: z.ZodLiteral<"needs_approval">;
29
+ summary: z.ZodString;
30
+ }, z.core.$strip>, z.ZodObject<{
31
+ type: z.ZodLiteral<"turn_end">;
32
+ }, z.core.$strip>, z.ZodObject<{
33
+ type: z.ZodLiteral<"error">;
34
+ message: z.ZodString;
35
+ }, z.core.$strip>, z.ZodObject<{
36
+ type: z.ZodLiteral<"usage">;
37
+ inputTokens: z.ZodOptional<z.ZodNumber>;
38
+ cachedInputTokens: z.ZodOptional<z.ZodNumber>;
39
+ outputTokens: z.ZodOptional<z.ZodNumber>;
40
+ reasoningTokens: z.ZodOptional<z.ZodNumber>;
41
+ totalTokens: z.ZodOptional<z.ZodNumber>;
42
+ }, z.core.$strip>], "type">, z.ZodObject<{
43
+ type: z.ZodString;
44
+ }, z.core.$loose>]>>;
45
+ dropped: z.ZodNumber;
46
+ }, z.core.$strip>;
47
+ export declare const TimelineEventSchema: z.ZodObject<{
48
+ taskId: z.ZodString;
49
+ sourceEnvelopeId: z.ZodString;
50
+ batchSeq: z.ZodNumber;
51
+ eventIndex: z.ZodNumber;
52
+ receivedAt: z.ZodISODateTime;
53
+ event: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
54
+ type: z.ZodLiteral<"progress">;
55
+ text: z.ZodString;
56
+ }, z.core.$strip>, z.ZodObject<{
57
+ type: z.ZodLiteral<"tool_use">;
58
+ tool: z.ZodString;
59
+ input: z.ZodOptional<z.ZodUnknown>;
60
+ toolCallId: z.ZodOptional<z.ZodString>;
61
+ }, z.core.$strip>, z.ZodObject<{
62
+ type: z.ZodLiteral<"tool_result">;
63
+ tool: z.ZodString;
64
+ output: z.ZodOptional<z.ZodUnknown>;
65
+ toolCallId: z.ZodOptional<z.ZodString>;
66
+ isError: z.ZodOptional<z.ZodBoolean>;
67
+ }, z.core.$strip>, z.ZodObject<{
68
+ type: z.ZodLiteral<"artifact">;
69
+ name: z.ZodString;
70
+ contentType: z.ZodString;
71
+ }, z.core.$strip>, z.ZodObject<{
72
+ type: z.ZodLiteral<"needs_approval">;
73
+ summary: z.ZodString;
74
+ }, z.core.$strip>, z.ZodObject<{
75
+ type: z.ZodLiteral<"turn_end">;
76
+ }, z.core.$strip>, z.ZodObject<{
77
+ type: z.ZodLiteral<"error">;
78
+ message: z.ZodString;
79
+ }, z.core.$strip>, z.ZodObject<{
80
+ type: z.ZodLiteral<"usage">;
81
+ inputTokens: z.ZodOptional<z.ZodNumber>;
82
+ cachedInputTokens: z.ZodOptional<z.ZodNumber>;
83
+ outputTokens: z.ZodOptional<z.ZodNumber>;
84
+ reasoningTokens: z.ZodOptional<z.ZodNumber>;
85
+ totalTokens: z.ZodOptional<z.ZodNumber>;
86
+ }, z.core.$strip>], "type">, z.ZodObject<{
87
+ type: z.ZodString;
88
+ }, z.core.$loose>]>;
89
+ }, z.core.$strip>;
90
+ export type TimelineEvent = Readonly<z.infer<typeof TimelineEventSchema>>;
91
+ export interface ActivityCursor {
92
+ readonly batchSeq: number;
93
+ readonly eventIndex: number;
94
+ }
95
+ export interface ActivityTail {
96
+ readonly tenantId: TenantId;
97
+ readonly taskId: string;
98
+ readonly entries: readonly TimelineEvent[];
99
+ readonly cursor?: ActivityCursor;
100
+ readonly dropped: number;
101
+ readonly capacity: number;
102
+ readonly expiresAt: string;
103
+ }
104
+ export interface ActivityAppendInput {
105
+ readonly taskId: string;
106
+ readonly sourceEnvelopeId: string;
107
+ readonly batchSeq: number;
108
+ readonly events: readonly AgentEventOrUnknown[];
109
+ readonly dropped: number;
110
+ readonly ttlMs: number;
111
+ readonly capacity?: number;
112
+ }
113
+ export interface ActivityStore {
114
+ append(tenant: TenantId, input: ActivityAppendInput): Promise<ActivityTail>;
115
+ read(tenant: TenantId, taskId: string): Promise<ActivityTail | undefined>;
116
+ }
117
+ export declare function validateActivityAppend(input: ActivityAppendInput): number;
118
+ export declare function projectTimelineEvents(input: ActivityAppendInput, receivedAt: string): readonly TimelineEvent[];
119
+ export declare function parseTimelineEvents(value: unknown): readonly TimelineEvent[];
120
+ export declare function compareTimelineEvents(left: TimelineEvent, right: TimelineEvent): number;
121
+ export declare function activityCursor(entries: readonly TimelineEvent[]): ActivityCursor | undefined;
122
+ export declare function activityTailKey(tenant: TenantId, taskId: string): string;
@@ -0,0 +1,74 @@
1
+ import { type TenantId } from '@byok-sdk/core';
2
+ import { z } from 'zod';
3
+ export declare const DEFAULT_APPROVAL_TIMELINE_CAPACITY = 50;
4
+ export declare const DEFAULT_APPROVAL_TIMELINE_TTL_MS: number;
5
+ export declare const APPROVAL_SUMMARY_MAX_BYTES: number;
6
+ export declare const ApprovalTimelineEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7
+ type: z.ZodLiteral<"approval_requested">;
8
+ summary: z.ZodString;
9
+ approvalId: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strip>, z.ZodObject<{
11
+ type: z.ZodLiteral<"approval_resolved">;
12
+ approvalId: z.ZodString;
13
+ decision: z.ZodEnum<{
14
+ approve: "approve";
15
+ reject: "reject";
16
+ }>;
17
+ resolvedBy: z.ZodEnum<{
18
+ local: "local";
19
+ }>;
20
+ at: z.ZodISODateTime;
21
+ }, z.core.$strip>], "type">;
22
+ export type ApprovalTimelineEvent = Readonly<z.infer<typeof ApprovalTimelineEventSchema>>;
23
+ export declare const ApprovalObservationSchema: z.ZodObject<{
24
+ taskId: z.ZodString;
25
+ sourceEnvelopeId: z.ZodString;
26
+ revision: z.ZodNumber;
27
+ receivedAt: z.ZodISODateTime;
28
+ event: z.ZodDiscriminatedUnion<[z.ZodObject<{
29
+ type: z.ZodLiteral<"approval_requested">;
30
+ summary: z.ZodString;
31
+ approvalId: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strip>, z.ZodObject<{
33
+ type: z.ZodLiteral<"approval_resolved">;
34
+ approvalId: z.ZodString;
35
+ decision: z.ZodEnum<{
36
+ approve: "approve";
37
+ reject: "reject";
38
+ }>;
39
+ resolvedBy: z.ZodEnum<{
40
+ local: "local";
41
+ }>;
42
+ at: z.ZodISODateTime;
43
+ }, z.core.$strip>], "type">;
44
+ }, z.core.$strip>;
45
+ export type ApprovalObservation = Readonly<z.infer<typeof ApprovalObservationSchema>>;
46
+ export interface ApprovalTimelineTail {
47
+ readonly tenantId: TenantId;
48
+ readonly taskId: string;
49
+ readonly entries: readonly ApprovalObservation[];
50
+ readonly cursor?: number;
51
+ readonly dropped: number;
52
+ readonly capacity: number;
53
+ readonly expiresAt: string;
54
+ }
55
+ export interface ApprovalTimelineAppendInput {
56
+ readonly taskId: string;
57
+ readonly sourceEnvelopeId: string;
58
+ readonly event: ApprovalTimelineEvent;
59
+ readonly ttlMs?: number;
60
+ readonly capacity?: number;
61
+ }
62
+ export interface ApprovalTimelineStore {
63
+ append(tenant: TenantId, input: ApprovalTimelineAppendInput): Promise<ApprovalTimelineTail>;
64
+ read(tenant: TenantId, taskId: string): Promise<ApprovalTimelineTail | undefined>;
65
+ }
66
+ export interface ValidatedApprovalTimelineAppend {
67
+ readonly capacity: number;
68
+ readonly ttlMs: number;
69
+ readonly event: ApprovalTimelineEvent;
70
+ }
71
+ export declare function validateApprovalTimelineAppend(input: ApprovalTimelineAppendInput): ValidatedApprovalTimelineAppend;
72
+ export declare function approvalTimelineKey(tenant: TenantId, taskId: string): string;
73
+ export declare function parseApprovalObservations(value: unknown): readonly ApprovalObservation[];
74
+ export declare function approvalTimelineCursor(entries: readonly ApprovalObservation[]): number | undefined;
package/dist/cloud.d.ts CHANGED
@@ -14,7 +14,9 @@
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 ActivityTail, 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 } from '@byok-sdk/core';
18
+ import type { ActivityTail } from './activity';
19
+ import type { ApprovalTimelineTail } from './approval-timeline';
18
20
  import { type Envelope, type TaskOfferPayload, type TaskOfferWithToolsetsPayload } from '@byok-sdk/protocol';
19
21
  import type { TokenSigner } from './auth/tokens';
20
22
  import type { CloudCrypto } from './crypto/port';
@@ -150,5 +152,6 @@ export interface ByokCloud {
150
152
  acceptBoardItem(tenant: TenantId, itemId: string): Promise<BoardItem>;
151
153
  listPresence(tenant: TenantId): Promise<readonly PresenceHint[]>;
152
154
  readActivity(tenant: TenantId, taskId: string): Promise<ActivityTail | undefined>;
155
+ readApprovalTimeline(tenant: TenantId, taskId: string): Promise<ApprovalTimelineTail | undefined>;
153
156
  }
154
157
  export declare function createByokCloud(options: ByokCloudOptions): ByokCloud;
@@ -1,11 +1,11 @@
1
- import type { ActivityTail } from '@byok-sdk/core';
2
1
  import type { AgentEventOrUnknown } from '@byok-sdk/protocol';
2
+ import { type ActivityAppendInput, type ActivityTail } from './activity';
3
3
  import type { TenantBoundActivity } from './tenant-stores';
4
4
  export declare const DEFAULT_BOARD_CHANNEL_MAX_BYTES = 128;
5
5
  export declare const DEFAULT_BOARD_TITLE_MAX_BYTES = 512;
6
6
  export declare const DEFAULT_ACTIVITY_MAX_EVENTS = 50;
7
7
  export declare const DEFAULT_ACTIVITY_MAX_BYTES: number;
8
- export declare const DEFAULT_ACTIVITY_CAPACITY = 50;
8
+ export { DEFAULT_ACTIVITY_CAPACITY } from './activity';
9
9
  export declare const DEFAULT_ACTIVITY_TTL_MS: number;
10
10
  export declare const DEFAULT_PRESENCE_TTL_MS = 90000;
11
11
  export declare const DEFAULT_PRESENCE_MINIMUM_INTERVAL_MS = 5000;
@@ -21,9 +21,12 @@ export declare function assertBoardLabels(channel: string, title: string, limits
21
21
  readonly channelMaxBytes: number;
22
22
  readonly titleMaxBytes: number;
23
23
  }): void;
24
- export declare function activityDetails(events: readonly AgentEventOrUnknown[], dropped: number, bounds: ActivityBounds): readonly string[];
24
+ export declare function validateActivityEvents(events: readonly AgentEventOrUnknown[], dropped: number, bounds: ActivityBounds): void;
25
+ export declare function validateActivityBatch(input: Omit<ActivityAppendInput, 'ttlMs' | 'capacity'>, bounds: ActivityBounds): void;
25
26
  export declare function appendActivityEvents(activity: TenantBoundActivity, input: {
26
27
  readonly taskId: string;
28
+ readonly sourceEnvelopeId: string;
29
+ readonly batchSeq: number;
27
30
  readonly events: readonly AgentEventOrUnknown[];
28
31
  readonly dropped: number;
29
32
  }, bounds: ActivityBounds): Promise<ActivityTail>;
package/dist/index.d.ts CHANGED
@@ -43,9 +43,13 @@ export type { InboundOutcome } from './inbound';
43
43
  export { projectTerminalResult } from './terminal-result';
44
44
  export type { TerminalResult } from './terminal-result';
45
45
  export { tenantStoresFor } from './tenant-stores';
46
- export type { TenantBoundActivity, TenantBoundBoard, CloudRootStores, TenantBoundBlobs, TenantBoundDedup, TenantBoundDevices, TenantBoundMailbox, TenantBoundPresence, TenantBoundQuota, TenantBoundRateLimiter, TenantBoundReceipts, TenantBoundTaskAttempts, TenantStores, } from './tenant-stores';
46
+ export type { TenantBoundActivity, TenantBoundApprovalTimeline, TenantBoundBoard, CloudRootStores, TenantBoundBlobs, TenantBoundDedup, TenantBoundDevices, TenantBoundMailbox, TenantBoundPresence, TenantBoundQuota, TenantBoundRateLimiter, TenantBoundReceipts, TenantBoundTaskAttempts, TenantStores, } from './tenant-stores';
47
+ export { ApprovalObservationSchema, ApprovalTimelineEventSchema, APPROVAL_SUMMARY_MAX_BYTES, DEFAULT_APPROVAL_TIMELINE_CAPACITY, DEFAULT_APPROVAL_TIMELINE_TTL_MS, approvalTimelineCursor, parseApprovalObservations, validateApprovalTimelineAppend, } from './approval-timeline';
48
+ export type { ApprovalObservation, ApprovalTimelineAppendInput, ApprovalTimelineEvent, ApprovalTimelineStore, ApprovalTimelineTail, } from './approval-timeline';
47
49
  export { DEFAULT_ACTIVITY_BOUNDS, DEFAULT_ACTIVITY_CAPACITY, DEFAULT_ACTIVITY_MAX_BYTES, DEFAULT_ACTIVITY_MAX_EVENTS, DEFAULT_ACTIVITY_TTL_MS, DEFAULT_BOARD_CHANNEL_MAX_BYTES, DEFAULT_BOARD_TITLE_MAX_BYTES, DEFAULT_PRESENCE_DETAIL_MAX_BYTES, DEFAULT_PRESENCE_MINIMUM_INTERVAL_MS, DEFAULT_PRESENCE_TTL_MS, } from './coordination';
48
50
  export type { ActivityBounds } from './coordination';
51
+ export { TimelineEventSchema, ActivityAppendRequestSchema, activityCursor, parseTimelineEvents, projectTimelineEvents, validateActivityAppend, } from './activity';
52
+ export type { ActivityAppendInput, ActivityCursor, ActivityStore, ActivityTail, TimelineEvent, } from './activity';
49
53
  export { BoardFeedClient, BoardFeedRetryableError, BoardFeedStoppedError } from './coordination-client';
50
54
  export type { BoardFeedClientOptions, BoardFeedItem, BoardFeedMode, BoardFeedPage, BoardFeedRead, } from './coordination-client';
51
55
  export { TRUTH_BATCH_MAX_RECORDS, TRUTH_INLINE_CONTENT_TYPE, TRUTH_LABEL_MAX_LENGTH, TRUTH_MANIFEST_MAX_LIMIT, TRUTH_RECORD_CAPABILITY, TRUTH_RECORD_KEY_MAX_LENGTH, TRUTH_REQUEST_ID_MAX_LENGTH, TruthBodyInputSchema, TruthCommitResponseSchema, TruthRecordKeySchema, TruthRecordMetadataSchema, TruthWriteRequestSchema, truthManifestMetadata, truthRecordMetadata, } from './truth/contract';
@@ -56,5 +60,5 @@ export type { TruthCommitErrorCode } from './truth/errors';
56
60
  export { CLOUD_STORE_NAMES, TASK_ATTEMPT_STATUSES } from './stores/ports';
57
61
  export { CLOUD_PORT_INTERFACES, CLOUD_PORT_METHODS } from './stores/ports-contract';
58
62
  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';
59
- export { AllowAllRateLimiter, BLOB_URL_TTL_MS, DEDUP_RING_CAPACITY, InMemoryBlobContentProxy, InMemoryCloudBlobStore, InMemoryDeviceDirectory, InMemoryInboundDedupStore, InMemoryNonceStore, InMemoryPairingCodeStore, InMemoryRequestReceiptStore, InMemoryProofRequestReceiptStore, InMemoryTaskAttemptStore, NONCE_TTL_MS, createInMemoryBlobs, createInMemoryCloudStores, } from './stores/in-memory/index';
63
+ 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';
60
64
  export type { InMemoryBlobStoreOptions, InMemoryBlobs, InMemoryCloudComposition, } from './stores/in-memory/index';