@byok-sdk/bot-collaboration 0.44.1 → 0.45.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/persona.d.ts CHANGED
@@ -1,2 +1,36 @@
1
- /** Install on the daemon. SDK supplies the canonical home, writer lease and atomic file write. */
2
- export declare function createBotPersonaProjection(): import("@byok-sdk/client").AgentHomeProjection;
1
+ import { type AgentHomeProjectionApplyInput } from '@byok-sdk/client';
2
+ /** Validated persona and SDK projection metadata, supplied while the writer lease is held. */
3
+ export interface BotPersonaProjectionContext {
4
+ readonly agentRef: AgentHomeProjectionApplyInput['agentRef'];
5
+ readonly canonicalHome: string;
6
+ readonly requestId: string;
7
+ readonly projectionHash: string;
8
+ readonly projection: {
9
+ readonly schemaVersion: 'bot-profile.v1';
10
+ readonly persona: string;
11
+ };
12
+ }
13
+ export interface BotPersonaProjectionOptions {
14
+ /**
15
+ * Additional root files, atomically written through the SDK. `AGENTS.md` is reserved for the persona.
16
+ * Files omitted on a later projection remain in the home; the SDK does not delete them.
17
+ */
18
+ readonly renderAdditionalFiles?: (input: BotPersonaProjectionContext) => readonly {
19
+ name: string;
20
+ body: string | Uint8Array;
21
+ }[] | Promise<readonly {
22
+ name: string;
23
+ body: string | Uint8Array;
24
+ }[]>;
25
+ /**
26
+ * Runs after all file writes under the same lease, for side effects outside the home only.
27
+ * Do not write to canonicalHome here; home files must go through renderAdditionalFiles and writeHomeFile.
28
+ * Exact revision/hash replays call this again, so it must be idempotent.
29
+ */
30
+ readonly afterWrite?: (input: BotPersonaProjectionContext) => void | Promise<void>;
31
+ }
32
+ /**
33
+ * Install on the daemon. The SDK supplies the canonical home, writer lease and atomic file writes.
34
+ * Each file is atomic individually; the files and afterWrite do not form a transaction. Both callbacks run again on exact replays.
35
+ */
36
+ export declare function createBotPersonaProjection(options?: BotPersonaProjectionOptions): import("@byok-sdk/client").AgentHomeProjection;
@@ -1,3 +1,4 @@
1
+ import type { VectorTestApi } from './vector-test-api.js';
1
2
  import { type Json } from '@byok-sdk/server/execution-core';
2
3
  import type { CollaborationState } from './model.js';
3
4
  import { type RetentionInput, type RetentionLimits, type RetentionResult } from './retention.js';
@@ -14,4 +15,4 @@ export interface RetentionSubject extends CommitSubject {
14
15
  archived(namespace: string, id: string): Json | undefined | Promise<Json | undefined>;
15
16
  }
16
17
  export declare const RETENTION_NOW = 10000;
17
- export declare function retentionVectors(name: string, open: () => RetentionSubject | Promise<RetentionSubject>): void;
18
+ export declare function retentionVectors({ describe, it, expect }: VectorTestApi, name: string, open: () => RetentionSubject | Promise<RetentionSubject>): void;
@@ -1,3 +1,4 @@
1
+ import type { VectorTestApi } from './vector-test-api.js';
1
2
  import { type RoutineScheduleFields, type UpdateRoutineAction } from '@byok-sdk/protocol';
2
3
  import { type Conclusion, type Intent, type Json, type Occurrence, type Routine } from '@byok-sdk/server/execution-core';
3
4
  import { type CollaborationState } from './model.js';
@@ -78,4 +79,4 @@ export interface RoutineIntentRow {
78
79
  export declare function routineView(routine: Readonly<Routine>): RoutineRow;
79
80
  /** The H view of a K4 occurrence. A promoted occurrence takes its conclusion from its intent (DDL D5). */
80
81
  export declare function occurrenceView(occurrence: Readonly<Occurrence>, intent?: Readonly<Pick<Intent, 'conclusion'>>): OccurrenceRow;
81
- export declare function routineVectors(name: string, open: () => RoutineSubject | Promise<RoutineSubject>): void;
82
+ export declare function routineVectors({ describe, it, expect }: VectorTestApi, name: string, open: () => RoutineSubject | Promise<RoutineSubject>): void;
@@ -1,3 +1,4 @@
1
+ import { type InputImageBlobRef } from '@byok-sdk/protocol';
1
2
  /**
2
3
  * Input coalescing as pure rules (#606 R2). Each function changes only the input rows that the caller
3
4
  * gives, does no I/O and takes `now` from the caller. The Host gives the facts of each Bot. It adds one
@@ -5,21 +6,15 @@
5
6
  */
6
7
  export type Authority = 'owner' | 'bot';
7
8
  /** One durable record per user input while input coalescing is in use. `key` is the caller's input key. */
8
- export interface UserInput {
9
- id: string;
10
- key: string;
11
- botId: string;
12
- request: string;
9
+ export interface UserInput extends InputFields {
13
10
  bytes: number;
14
- sender: string;
15
- authority: Authority;
16
11
  receivedAt: number;
17
12
  batchId: string;
18
13
  }
19
- export type SealReason = 'idle' | 'window' | 'items' | 'bytes' | 'boundary' | 'key_changed' | 'cancel' | 'policy_off' | 'archived';
14
+ export type SealReason = 'idle' | 'window' | 'items' | 'bytes' | 'images' | 'boundary' | 'key_changed' | 'cancel' | 'policy_off' | 'archived';
20
15
  /**
21
16
  * `id` is the first input's id and the batch Turn id. `key` is the coalescing key.
22
- * `request` is the rendered Request while the batch is open; sealing moves it into the batch Turn.
17
+ * `request` and `images` hold the rendered input while the batch is open; sealing moves them into the batch Turn.
23
18
  * `bytes` is its UTF-8 size, framing included. `revision` is the last projected revision: 1 is open, 2 is sealed.
24
19
  */
25
20
  export interface InputBatch {
@@ -33,6 +28,7 @@ export interface InputBatch {
33
28
  state: 'open' | 'sealed';
34
29
  sealReason?: SealReason;
35
30
  request?: string;
31
+ images?: readonly InputImageBlobRef[];
36
32
  revision?: 1 | 2;
37
33
  }
38
34
  /** Values that apply when `BotOptions.coalesce` is present (owner ruling on #551). */
@@ -51,9 +47,12 @@ export interface InputFields {
51
47
  key: string;
52
48
  botId: string;
53
49
  request: string;
50
+ images?: readonly InputImageBlobRef[];
54
51
  sender: string;
55
52
  authority: Authority;
56
53
  }
54
+ /** Validate image refs at K8 ingress and pass the parsed value into the rules. */
55
+ export declare function validateInputImages<T extends Pick<InputFields, 'images'>>(input: T): T;
57
56
  /** The input rows that the rules read and change. Both maps appear at the first coalesced input. */
58
57
  export interface CoalesceState {
59
58
  inputs?: Record<string, UserInput>;
@@ -74,6 +73,7 @@ export interface BatchTurn {
74
73
  id: string;
75
74
  botId: string;
76
75
  request: string;
76
+ images?: readonly InputImageBlobRef[];
77
77
  authority: Authority;
78
78
  inputIds: string[];
79
79
  }
@@ -100,9 +100,7 @@ export declare function sealDueBatches(state: CoalesceState, bots: Readonly<Reco
100
100
  */
101
101
  export declare function admitUserInput(state: CoalesceState, input: InputFields, facts: {
102
102
  bot?: BotFacts;
103
- turn?: {
104
- request: string;
105
- };
103
+ turn?: Pick<InputFields, 'request' | 'images'>;
106
104
  }, policy: CoalescePolicy | undefined, now: number): Admission;
107
105
  /** `id` is a batch id or a member input id. An open batch seals first, so the whole batch cancels. */
108
106
  export declare function sealBatchForCancel(state: CoalesceState, id: string): {
@@ -1,4 +1,4 @@
1
- import type { RoomFields } from '@byok-sdk/protocol';
1
+ import { type RoomFields } from '@byok-sdk/protocol';
2
2
  import { type Json, type Turn } from './turn.js';
3
3
  import { type ExternalTeam, type TeamSnapshot, type TeamSnapshotBot } from './team.js';
4
4
  import { type MemberMentions, type Mentions } from './rooms.js';
@@ -17,13 +17,9 @@ export { cardCallDue, CONNECTOR_OUTCOME_UNKNOWN, expireCards, reportCardDecision
17
17
  /** Commands with a caller key or a K4 key. The store records them, so a retry replays the first result. */
18
18
  export type KeyedCommand =
19
19
  /** Owner input to a Bot. The Turn id comes from the Bot and the caller key. */
20
- {
20
+ ({
21
21
  kind: 'input';
22
- botId: string;
23
- key: string;
24
- request: string;
25
- sender: string;
26
- }
22
+ } & Pick<InputFields, 'botId' | 'key' | 'request' | 'images' | 'sender'>)
27
23
  /** A received IM message that the Host classified (docs/host-im-adapter.md §3). `key` is its inbound key. */
28
24
  | {
29
25
  kind: 'receive';
@@ -1,3 +1,3 @@
1
- export { COALESCE_DEFAULTS, CONNECTOR_OUTCOME_UNKNOWN, DEVICE_NOT_BOUND, DEVICE_SWITCHING, OFFER_WAIT_MS, addTurn, admitBotToolsets, admitDeviceSlot, advanceRoomSeats, autonomousIntentIds, cardCallDue, checkReply, coalescePolicy, collaborationDue, commandBots, commitCommand, compactVeto, delegationCancelAnswer, hostIntentCancelAnswer, hostMessageDisposition, inactive, observeDevices, replyCheckDue, reportCardDecisions, requireMain, seatTurn, settleCardCall, settleDelegations, syncTurn, turnCancelAnswer, userFirst } from '../chunk-BGGEZHPC.js';
1
+ export { COALESCE_DEFAULTS, CONNECTOR_OUTCOME_UNKNOWN, DEVICE_NOT_BOUND, DEVICE_SWITCHING, OFFER_WAIT_MS, addTurn, admitBotToolsets, admitDeviceSlot, advanceRoomSeats, autonomousIntentIds, cardCallDue, checkReply, coalescePolicy, collaborationDue, commandBots, commitCommand, compactVeto, delegationCancelAnswer, hostIntentCancelAnswer, hostMessageDisposition, inactive, observeDevices, replyCheckDue, reportCardDecisions, requireMain, seatTurn, settleCardCall, settleDelegations, syncTurn, turnCancelAnswer, userFirst } from '../chunk-4HLCBNWV.js';
2
2
  //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,7 @@
1
1
  import { type ResultSchema } from '@byok-sdk/protocol';
2
2
  import type { Turn } from './turn.js';
3
3
  import type { RoomsState } from './rooms.js';
4
+ import type { Autonomy } from './autonomy.js';
4
5
  import { type DelegationView } from './delegation.js';
5
6
  /**
6
7
  * The frozen Bot Turn prompts and result schema as pure rules (#739 D1). The functions read only the
@@ -17,6 +18,7 @@ export interface ContextBot {
17
18
  readonly archived: boolean;
18
19
  readonly participation?: 'suspended';
19
20
  readonly readyRevision: string | null;
21
+ readonly autonomy?: Autonomy;
20
22
  }
21
23
  /** Team, delegation and reply rows. No Turn rows: the ContextPack takes its history as an argument. */
22
24
  export interface ContextState extends DelegationView {
@@ -90,6 +90,8 @@ export interface SyncFacts extends Pick<IntentFacts, 'intent'> {
90
90
  * The store writes the execution row with the intent, so an intent always has one.
91
91
  */
92
92
  executionStarted(turnId: string): boolean;
93
+ /** Preparation error from the K4 intent, when the store exposes it. */
94
+ preparationError?(turnId: string): string | undefined;
93
95
  /**
94
96
  * The Turn's identity can never run again. `result_retired`: the store compacted the intent before this sync saw its result,
95
97
  * or the occurrence of a routine Turn. `turn_retired`: retention retired the Turn id.
@@ -1,4 +1,4 @@
1
- import type { AskUserAction, ConfirmableAction } from '@byok-sdk/protocol';
1
+ import type { AskUserAction, ConfirmableAction, InputImageBlobRef } from '@byok-sdk/protocol';
2
2
  import { type Authority, type BatchTurn, type CoalesceState } from './coalesce.js';
3
3
  /**
4
4
  * Turn rows and the rows that a Turn makes, as pure rules (#739 D1). The functions change only the rows
@@ -15,6 +15,7 @@ export interface Turn {
15
15
  botId: string;
16
16
  source: 'user' | 'continuation' | 'answer' | 'action_result' | 'routine' | 'room_slot' | 'bot_request' | 'bot_reply';
17
17
  request: string;
18
+ images?: readonly InputImageBlobRef[];
18
19
  hop: number;
19
20
  status: 'queued' | 'processing' | 'succeeded' | 'failed' | 'blocked' | 'delivered';
20
21
  /** Set at insert and never changed. Absent counts as `bot`: only `owner` turns can manage the team. */
@@ -39,10 +40,9 @@ export interface Turn {
39
40
  /** Set while the sync holds this Turn because its Bot's device has no active binding (#956) or is frozen for an owner switch (#957). */
40
41
  held?: 'device_not_bound' | 'device_switching';
41
42
  /**
42
- * The refusal code of the K4 terminal when the owner's `failStuckIntent` settled this Turn's intent (#1405). Set in the
43
- * settle transaction, so a reader need not match the audit row, which keeps the message.
43
+ * The code of a refused image submission or a terminal that the owner settled with `failStuckIntent` (#1405).
44
44
  */
45
- settleCode?: 'outcome_failed';
45
+ settleCode?: 'outcome_failed' | 'coordination_input_invalid';
46
46
  blockedReason?: string;
47
47
  profileFailure?: {
48
48
  sequence: number;
@@ -110,6 +110,7 @@ export interface TurnFields {
110
110
  root: string;
111
111
  source: Turn['source'];
112
112
  request: string;
113
+ images?: readonly InputImageBlobRef[];
113
114
  botId: string;
114
115
  hop: number;
115
116
  authority: Authority;
package/dist/testing.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export type { VectorTestApi, VectorMatchers } from './vector-test-api.js';
1
2
  export { cardCallVectors, cardVectors, coalesceVectors, commitVectors, deviceVectors, homeVectors, replyVectors, roomVectors, seedCollaboration, seedRoom, settlementVectors, SYNC_OPTIONS, syncVectors, VECTOR_NOW, type CardCallSubject, type CardSubject, type CoalesceSubject, type CommitSubject, type DeviceSubject, type HomeCalls, type HomeSubject, type ReplySubject, type RoomSubject, type SeedTeam, type SettlementSubject, type SyncIntentRecord, type SyncSubject } from './commit-vectors.test-support.js';
2
3
  export { deliveryVectors, FINAL_BODY, replyToken, type DeliverySubject } from './delivery-vectors.test-support.js';
3
4
  export { policy, template } from './k4-fixtures.test-support.js';