@byok-sdk/bot-collaboration 0.0.0-stage → 0.42.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/LICENSE +21 -0
- package/README.md +2058 -2
- package/dist/adapter-steps.d.ts +49 -0
- package/dist/channel.d.ts +111 -0
- package/dist/chunk-33YA66U7.js +7 -0
- package/dist/chunk-33YA66U7.js.map +1 -0
- package/dist/chunk-5J5SOWWI.js +12 -0
- package/dist/chunk-5J5SOWWI.js.map +1 -0
- package/dist/chunk-XTZUCECQ.js +12 -0
- package/dist/chunk-XTZUCECQ.js.map +1 -0
- package/dist/chunk-ZUFZCROA.js +27 -0
- package/dist/chunk-ZUFZCROA.js.map +1 -0
- package/dist/coalesce.d.ts +18 -0
- package/dist/commit-vectors.test-support.d.ts +173 -0
- package/dist/commit.d.ts +52 -0
- package/dist/compaction.d.ts +13 -0
- package/dist/delegation.d.ts +12 -0
- package/dist/delivery-routing.d.ts +63 -0
- package/dist/delivery-vectors.test-support.d.ts +78 -0
- package/dist/delivery.d.ts +20 -0
- package/dist/dream.d.ts +88 -0
- package/dist/home-projections.d.ts +5 -0
- package/dist/host-kit.d.ts +40 -0
- package/dist/host-kit.js +6 -0
- package/dist/host-kit.js.map +1 -0
- package/dist/host.d.ts +433 -0
- package/dist/inbound.d.ts +17 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/k4-fixtures.test-support.d.ts +10 -0
- package/dist/l-test-host.test-support.d.ts +72 -0
- package/dist/migration.d.ts +251 -0
- package/dist/model.d.ts +83 -0
- package/dist/persona.d.ts +2 -0
- package/dist/retention-vectors.test-support.d.ts +17 -0
- package/dist/retention.d.ts +61 -0
- package/dist/rooms.d.ts +22 -0
- package/dist/routine-vectors.test-support.d.ts +81 -0
- package/dist/routines.d.ts +110 -0
- package/dist/rules/autonomy.d.ts +67 -0
- package/dist/rules/cards.d.ts +31 -0
- package/dist/rules/coalesce.d.ts +111 -0
- package/dist/rules/commands.d.ts +306 -0
- package/dist/rules/commit.d.ts +82 -0
- package/dist/rules/compaction.d.ts +33 -0
- package/dist/rules/context.d.ts +484 -0
- package/dist/rules/delegation.d.ts +353 -0
- package/dist/rules/due.d.ts +15 -0
- package/dist/rules/frame.d.ts +4 -0
- package/dist/rules/history.d.ts +34 -0
- package/dist/rules/inbound.d.ts +53 -0
- package/dist/rules/index.d.ts +13 -0
- package/dist/rules/index.js +4 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/message.d.ts +31 -0
- package/dist/rules/outcome.d.ts +45 -0
- package/dist/rules/priority.d.ts +52 -0
- package/dist/rules/rooms.d.ts +187 -0
- package/dist/rules/schema.d.ts +110 -0
- package/dist/rules/sync.d.ts +157 -0
- package/dist/rules/team.d.ts +119 -0
- package/dist/rules/turn.d.ts +129 -0
- package/dist/schema.d.ts +154 -0
- package/dist/switch.d.ts +53 -0
- package/dist/team-model.d.ts +54 -0
- package/dist/team.d.ts +56 -0
- package/dist/testing.d.ts +6 -0
- package/dist/testing.js +20 -0
- package/dist/testing.js.map +1 -0
- package/dist/toolset-policy.d.ts +2 -0
- package/dist/topology.d.ts +49 -0
- package/package.json +80 -4
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Json } from '@byok-sdk/server/execution-core';
|
|
2
|
+
import { type CollaborationState } from './model.js';
|
|
3
|
+
import * as rules from './rules/coalesce.js';
|
|
4
|
+
export { COALESCE_DEFAULTS, batchRequest, coalescePolicy, type CoalescePolicy, type InputFields } from './rules/coalesce.js';
|
|
5
|
+
/** Runs first in each Host sync. The window counts from the first input; later inputs never extend it. */
|
|
6
|
+
export declare function sealDueBatches(state: CollaborationState, policy: rules.CoalescePolicy | undefined, now: number): void;
|
|
7
|
+
/**
|
|
8
|
+
* Runs last in each Host sync, so it sees every seal of that pass and of earlier transactions.
|
|
9
|
+
* Revision 1 shows the batch at its first projection while open. A batch that seals before then projects only revision 2.
|
|
10
|
+
*/
|
|
11
|
+
export declare function projectInputBatches(state: CollaborationState, emit: (key: string, value: Json) => void): void;
|
|
12
|
+
/**
|
|
13
|
+
* Admit one user input before K4 enqueue. Returns the id of the Turn that answers it: the batch id.
|
|
14
|
+
* Without a policy, each input keeps its own Turn, as before coalescing.
|
|
15
|
+
*/
|
|
16
|
+
export declare function admitUserInput(state: CollaborationState, input: rules.InputFields, policy: rules.CoalescePolicy | undefined, now: number): string;
|
|
17
|
+
/** `cancelTurn` accepts a batch id or a member input id. An open batch seals first, so the whole batch cancels. */
|
|
18
|
+
export declare function sealBatchForCancel(state: CollaborationState, id: string): string;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { type ExecutionTemplate } from '@byok-sdk/server/execution-core';
|
|
2
|
+
import type { CollaborationState } from './model.js';
|
|
3
|
+
import { type CommitRequest, type CommitResult } from './rules/commit.js';
|
|
4
|
+
import type { Command } from './rules/commands.js';
|
|
5
|
+
import { type SyncOptions, type SyncStep } from './rules/sync.js';
|
|
6
|
+
import type { Conclusion, DelegationTimers, ReplyReadback } from './rules/delegation.js';
|
|
7
|
+
import type { Json } from './rules/turn.js';
|
|
8
|
+
import type { CoalescePolicy } from './rules/coalesce.js';
|
|
9
|
+
import { ROOM_GRACE_MS } from './rules/rooms.js';
|
|
10
|
+
import { type HomeReadback } from './team.js';
|
|
11
|
+
import type { HomeOperation } from './team-model.js';
|
|
12
|
+
/**
|
|
13
|
+
* #739 D1 commit contract vectors. Each store runs the same cases: the K8 L ledger now, and the H adapter in D2.
|
|
14
|
+
* A subject may be async: the H adapter commits through Postgres. A sync throw and a rejection are the same failure.
|
|
15
|
+
* A subject starts from `seedCollaboration` and decides at time 1000.
|
|
16
|
+
*/
|
|
17
|
+
export interface CommitSubject {
|
|
18
|
+
readonly scope: string;
|
|
19
|
+
commit(request: CommitRequest<Command>): CommitResult | Promise<CommitResult>;
|
|
20
|
+
/** All stored bytes of the store, for the checks that a refused commit changed nothing. */
|
|
21
|
+
stored(): string | Promise<string>;
|
|
22
|
+
/** A copy of the stored collaboration state. */
|
|
23
|
+
state(): CollaborationState | Promise<CollaborationState>;
|
|
24
|
+
}
|
|
25
|
+
export declare const VECTOR_NOW = 1000;
|
|
26
|
+
/**
|
|
27
|
+
* One active Main Bot `main`, its processing Turn `t1` with a frozen schema, an open question `q1` and an expired card `c1`.
|
|
28
|
+
* `external`: the team authority owns the Bots, and its team revision 1 holds `main`. `rooms`: it also owns the rooms (#1321).
|
|
29
|
+
*/
|
|
30
|
+
export type SeedTeam = 'local' | 'external' | 'rooms';
|
|
31
|
+
export declare function seedCollaboration(state: CollaborationState, team?: SeedTeam): void;
|
|
32
|
+
export declare function commitVectors(name: string, open: (team?: SeedTeam) => CommitSubject | Promise<CommitSubject>): void;
|
|
33
|
+
/**
|
|
34
|
+
* #793 D2b: the sync step as a store operation. The store runs `syncTurn` for each stored Turn, in insertion order, in one
|
|
35
|
+
* transaction under the same scope lock as `commit`, with the options below. It writes each returned step: a `freeze` stores
|
|
36
|
+
* its intent input as it is. The projections that the step publishes reach the store's outbox in the same transaction.
|
|
37
|
+
* A projection with the same id and the same body adds nothing; another body for that id throws `Projection identity conflict`.
|
|
38
|
+
* It writes no command record and keeps the revision. A sync is the Host's own work, so a client's expected revision must
|
|
39
|
+
* not go stale because of it. The store reads the facts inside the sync transaction. A Host sync can run other steps in the
|
|
40
|
+
* same transaction before and after the per-Turn steps, as L does; this contract defines only the per-Turn step.
|
|
41
|
+
*/
|
|
42
|
+
export interface SyncSubject extends CommitSubject {
|
|
43
|
+
/** A test edit of the stored state, outside the contract. */
|
|
44
|
+
change(edit: (state: CollaborationState) => void): void | Promise<void>;
|
|
45
|
+
sync(): void | Promise<void>;
|
|
46
|
+
/** The stored intent input of a Turn. */
|
|
47
|
+
intent(turnId: string): SyncIntentRecord | undefined | Promise<SyncIntentRecord | undefined>;
|
|
48
|
+
/** A test edit: the store settles the intent of a Turn with this conclusion, outside the contract. */
|
|
49
|
+
concludeIntent(turnId: string, conclusion: Conclusion): void | Promise<void>;
|
|
50
|
+
/** The values of the stored outbox rows with this projection id. */
|
|
51
|
+
projection(id: string): Json[] | Promise<Json[]>;
|
|
52
|
+
}
|
|
53
|
+
export type SyncIntentRecord = Extract<SyncStep<unknown>, {
|
|
54
|
+
kind: 'freeze';
|
|
55
|
+
}>['input'];
|
|
56
|
+
/** The sync options of the vectors. A Bot with an undeclared connector toolset cannot freeze. */
|
|
57
|
+
export declare const SYNC_OPTIONS: SyncOptions<never>;
|
|
58
|
+
export declare function syncVectors(name: string, open: () => SyncSubject | Promise<SyncSubject>): void;
|
|
59
|
+
/**
|
|
60
|
+
* The sync vector of a stored template that differs from the Host's (#1358): only L keeps such a template at freeze time,
|
|
61
|
+
* since H re-projects the scope config's templates at each sync.
|
|
62
|
+
*/
|
|
63
|
+
export declare function staleTemplateSyncVectors(name: string, open: () => SyncSubject | Promise<SyncSubject>): void;
|
|
64
|
+
/**
|
|
65
|
+
* #793 D2f-5: the delegation settlement of the Host sync. `settle` is one Host sync: the per-Turn steps of the sync contract,
|
|
66
|
+
* then K8 `settleDelegations` on the store's own intent facts, as L's sync runs it after the Turn steps. A store may run more
|
|
67
|
+
* rounds in one sync, and it may deliver a cancel fact to K4 in it; these vectors sync until nothing changes, and they end a
|
|
68
|
+
* cancelled target with `conclude`, as the K4 drain or the reconciliation would. The fact edits are outside the contract:
|
|
69
|
+
* each one writes the K4 evidence in the store's own shape, and the store's adapter reads the facts from it.
|
|
70
|
+
*/
|
|
71
|
+
export interface SettlementSubject extends SyncSubject {
|
|
72
|
+
settle(now: number, timers?: DelegationTimers): void | Promise<void>;
|
|
73
|
+
/** A test edit: the first attempt of the Turn's intent was submitted, with no claim. */
|
|
74
|
+
submit(turnId: string): void | Promise<void>;
|
|
75
|
+
/** A test edit: a device claimed the first attempt (K4 `Execution.started`). */
|
|
76
|
+
claim(turnId: string): void | Promise<void>;
|
|
77
|
+
/** A test edit: the device terminal of the first attempt. */
|
|
78
|
+
terminal(turnId: string, type: string, payload: Json): void | Promise<void>;
|
|
79
|
+
/** A test edit: the intent concludes, with the K4 cancel reason when one is given. */
|
|
80
|
+
conclude(turnId: string, conclusion: Conclusion, cancelReason?: 'cancelled' | 'expired'): void | Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
export declare function settlementVectors(name: string, open: () => SettlementSubject | Promise<SettlementSubject>): void;
|
|
83
|
+
/** A reply readback through the SDK `tasks.agentMessage`, as the Host binds it. */
|
|
84
|
+
export type ReplyRead = (taskId: string, deviceId: string, agentRef: ExecutionTemplate['payload']['agentRef']) => Promise<ReplyReadback>;
|
|
85
|
+
/**
|
|
86
|
+
* #793 S7 reply checks. `checkReplies(now, read, timers)` is the Host's reply check at `now`, as L's `flushReplies` runs it:
|
|
87
|
+
* for each delegation that K8 `replyCheckDue` selects, the chain end's readback through `read`, outside any transaction,
|
|
88
|
+
* then the K8 `checkReply` decision. It runs no sync. `timers` gives `uncertainAfterMs`.
|
|
89
|
+
*/
|
|
90
|
+
export interface ReplySubject extends SettlementSubject {
|
|
91
|
+
checkReplies(now: number, read: ReplyRead, timers?: DelegationTimers): void | Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
export declare function replyVectors(name: string, open: () => ReplySubject | Promise<ReplySubject>): void;
|
|
94
|
+
/**
|
|
95
|
+
* #793 H batch seal: input coalescing in the Host sync. `open(policy)` opens a store whose input admission uses `policy`, or
|
|
96
|
+
* no coalescing without one. `sync(now)` is one Host sync at `now`: K8 `sealDueBatches` first, then the Turn steps, then
|
|
97
|
+
* `projectInputBatches` last, as L's sync runs them. A store may run more rounds in one sync.
|
|
98
|
+
*/
|
|
99
|
+
export interface CoalesceSubject extends Omit<SyncSubject, 'sync'> {
|
|
100
|
+
sync(now: number): void | Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
export declare function coalesceVectors(name: string, open: (policy?: CoalescePolicy) => CoalesceSubject | Promise<CoalesceSubject>): void;
|
|
103
|
+
/**
|
|
104
|
+
* #793 S5: the card steps of the Host sync. `sync(now)` is one Host sync at `now`, in L's order: K8 `expireCards`, the Turn
|
|
105
|
+
* steps of the sync contract, then K8 `reportCardDecisions`. A store may run more rounds in one sync.
|
|
106
|
+
*/
|
|
107
|
+
export interface CardSubject extends Omit<SyncSubject, 'sync'> {
|
|
108
|
+
sync(now: number): void | Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
export declare function cardVectors(name: string, open: () => CardSubject | Promise<CardSubject>): void;
|
|
111
|
+
/**
|
|
112
|
+
* #793 S6: the room step of the Host sync. `sync(now)` is one Host sync at `now`, in L's order: the room step (K8
|
|
113
|
+
* `advanceRoomSeats` on the seat facts of the K4 intents), then the Turn steps of the sync contract. When a Turn step releases
|
|
114
|
+
* a seat, the sync runs the room step and the Turn steps again. A store may run more rounds in one sync. `claim` is a test edit: a device claimed the first attempt of the Turn's intent (K4 `Execution.started`).
|
|
115
|
+
* `cancelReason` reads the K4 cancel reason of the Turn's intent.
|
|
116
|
+
*/
|
|
117
|
+
export interface RoomSubject extends Omit<SyncSubject, 'sync'> {
|
|
118
|
+
sync(now: number): void | Promise<void>;
|
|
119
|
+
claim(turnId: string): void | Promise<void>;
|
|
120
|
+
cancelReason(turnId: string): string | undefined | Promise<string | undefined>;
|
|
121
|
+
}
|
|
122
|
+
export { ROOM_GRACE_MS };
|
|
123
|
+
/**
|
|
124
|
+
* The room vectors' seed edit: `t1` concluded, the card `c1` kept pending, Bot `b` beside `main` on the same device, and room
|
|
125
|
+
* `r` with both. An owner message mentions `b`, then `main`, so its round has `b`'s seat first.
|
|
126
|
+
*/
|
|
127
|
+
export declare function seedRoom(state: CollaborationState): void;
|
|
128
|
+
export declare function roomVectors(name: string, open: () => RoomSubject | Promise<RoomSubject>): void;
|
|
129
|
+
/**
|
|
130
|
+
* #793 S11 device observation. `observeDevices(devices)` is the Host's device step, as L's `refreshDevices` runs it after its
|
|
131
|
+
* discovery read: K8 `observeDevices` on the store's intent facts, in one transaction. `devices` maps a device id to its
|
|
132
|
+
* `connected` fact; a device that the map lacks gives no fact. Presence is display only: the step changes a delegation's
|
|
133
|
+
* status between `queued` and `waiting_device`, and nothing else.
|
|
134
|
+
*/
|
|
135
|
+
export interface DeviceSubject extends SettlementSubject {
|
|
136
|
+
observeDevices(devices: ReadonlyMap<string, boolean>): void | Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* A test edit: the first attempt of the Turn's intent was delivered, and the SDK attempt of that delivery has `status`
|
|
139
|
+
* (`offered` until a device claims it). With no `status`, the Host has read no attempt yet.
|
|
140
|
+
*/
|
|
141
|
+
deliver(turnId: string, status?: 'offered' | 'running'): void | Promise<void>;
|
|
142
|
+
}
|
|
143
|
+
export declare function deviceVectors(name: string, open: () => DeviceSubject | Promise<DeviceSubject>): void;
|
|
144
|
+
/** The Host connector of a confirmed card, as L's `HostOptions.connector`. */
|
|
145
|
+
export type CardConnector = (id: string, action: string, draft: Json, signal: AbortSignal) => Promise<unknown>;
|
|
146
|
+
/**
|
|
147
|
+
* #793 S12 card calls. `callCards(connector)` is the Host's card call step, as L's `flushCards` runs it: for each card that K8
|
|
148
|
+
* `cardCallDue` selects, the Host claims the call, runs one call of `connector` outside any transaction, then K8
|
|
149
|
+
* `settleCardCall` with its result or its error, which drops the claim (#958). A claim found with no settle ends the card
|
|
150
|
+
* with `CONNECTOR_OUTCOME_UNKNOWN` and no call. It runs no sync: the next `sync` reports the card and adds its
|
|
151
|
+
* `action_result` Turn.
|
|
152
|
+
*/
|
|
153
|
+
export interface CardCallSubject extends CardSubject {
|
|
154
|
+
callCards(connector: CardConnector): void | Promise<void>;
|
|
155
|
+
}
|
|
156
|
+
export declare function cardCallVectors(name: string, open: () => CardCallSubject | Promise<CardCallSubject>): void;
|
|
157
|
+
/** The SDK Agent home calls of a Host flush, as L binds `readAgentHomeProjection` and `enqueueAgentHomeProjection`. */
|
|
158
|
+
export interface HomeCalls {
|
|
159
|
+
read(request: HomeOperation['request']): Promise<HomeReadback | undefined>;
|
|
160
|
+
enqueue(request: HomeOperation['request']): Promise<unknown>;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* #793 S13 Agent home flush. `flushHomes(now, calls)` is the Host's home flush at `now`, as L's `flushHomes` runs it: for
|
|
164
|
+
* each Bot's oldest pending operation, while that Bot has no intent with no conclusion, the readback of each request in
|
|
165
|
+
* order through `calls.read` (K8 `checkHomeReadback`), then K8 `applyHomeTerminal`, or `planHomeRetry`, the enqueue of the
|
|
166
|
+
* latest request through `calls.enqueue` and `homeEnqueued`; a step that throws runs `failHomeFlush`. A Host may skip an
|
|
167
|
+
* idempotent enqueue before `retryAt` (L enqueues at each pass), and may wait before it looks at a Bot that was busy, so
|
|
168
|
+
* these vectors flush an hour later after such a wait.
|
|
169
|
+
*/
|
|
170
|
+
export interface HomeSubject extends SyncSubject {
|
|
171
|
+
flushHomes(now: number, calls: HomeCalls): void | Promise<void>;
|
|
172
|
+
}
|
|
173
|
+
export declare function homeVectors(name: string, open: () => HomeSubject | Promise<HomeSubject>): void;
|
package/dist/commit.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type ApplicationRows, type HostLedger, type LedgerState } from '@byok-sdk/server/execution-core';
|
|
2
|
+
import { type Card, type CollaborationState, type Turn } from './model.js';
|
|
3
|
+
import { type BotRoutine } from './routines.js';
|
|
4
|
+
import { type SyncOptions } from './rules/sync.js';
|
|
5
|
+
import { type Command, type CommandPorts } from './rules/commands.js';
|
|
6
|
+
import type { CommitRequest, CommitResult } from './rules/commit.js';
|
|
7
|
+
import { type RetentionInput, type RetentionLimits, type RetentionResult } from './retention.js';
|
|
8
|
+
export { CommitConflict, revisionOf, type CommitRequest, type CommitResult, type Disposition, type OutboxIntent } from './rules/commit.js';
|
|
9
|
+
export type { Command, CommandPorts } from './rules/commands.js';
|
|
10
|
+
/**
|
|
11
|
+
* One K8 write to an L ledger in one ledger transaction (#975). It refuses a ledger that holds an uncommitted switch import
|
|
12
|
+
* before the work runs. It refuses while the domain is exported after the work, so a new command on a frozen or H-owned
|
|
13
|
+
* device still gets its device refusal. A refusal the work raises first (a replayed command id, an id conflict,
|
|
14
|
+
* `stale_revision`, `RetentionRefused`) also comes before the export's; each refusal rolls the transaction back.
|
|
15
|
+
*/
|
|
16
|
+
export declare function writeLedger<T>(ledger: Pick<HostLedger, 'transaction'>, apply: (state: LedgerState, rows: ApplicationRows) => T): T;
|
|
17
|
+
/**
|
|
18
|
+
* The scope of an L ledger is its tenant. `ports` gets the transaction state, so outbox writes join the commit.
|
|
19
|
+
* Moved command records and tombstones come from K4 application rows of the same transaction (#798).
|
|
20
|
+
*/
|
|
21
|
+
export declare function commitInLedger(ledger: HostLedger, request: CommitRequest<Command>, ports: (s: LedgerState) => CommandPorts): CommitResult;
|
|
22
|
+
/**
|
|
23
|
+
* One command in a K4 transaction of the ledger with tenant `scope`, which holds `rows`: an owner command, or a K4 outcome,
|
|
24
|
+
* message or occurrence callback.
|
|
25
|
+
*/
|
|
26
|
+
export declare function commitInRows(state: CollaborationState, scope: string, request: CommitRequest<Command>, rows: ApplicationRows, ports: CommandPorts): CommitResult;
|
|
27
|
+
/** One retention call in one ledger transaction. K4 facts come from the same state. */
|
|
28
|
+
export declare function retainInLedger(ledger: HostLedger, input: RetentionInput, limits: RetentionLimits): RetentionResult;
|
|
29
|
+
/** The result of `migrateWouldDo`: rows that got their `turnId`, and rows archived because no live Turn owns them. */
|
|
30
|
+
export interface WouldDoMigration {
|
|
31
|
+
backfilled: number;
|
|
32
|
+
archived: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The one-shot migration of would-do rows written before #1756, which have no `turnId`. The operator runs it once before
|
|
36
|
+
* the new code serves. Each Turn intent of K4 has the task id `taskId(turnId, generation)` for each of its generations, so
|
|
37
|
+
* the row's task id names its Turn exactly. A row whose intent was compacted, or whose Turn left the state, has no live
|
|
38
|
+
* owner: it moves to the `wouldDo` application rows, as retention would move it, and is counted.
|
|
39
|
+
*/
|
|
40
|
+
export declare function migrateWouldDo(ledger: HostLedger): WouldDoMigration;
|
|
41
|
+
/**
|
|
42
|
+
* One sync step of one Turn in the L ledger, inside the caller's transaction. The Host sync loop calls it for each Turn.
|
|
43
|
+
* The K4 writes stay here: `enqueue`, `promoteOccurrence`, the intent cancel and the occurrence conclusion.
|
|
44
|
+
* Returns true when the step queued work or concluded an occurrence, so that K4 drains again.
|
|
45
|
+
*/
|
|
46
|
+
export declare function syncTurnInLedger(ledger: HostLedger, s: LedgerState, rows: ApplicationRows, turn: Turn, options: SyncOptions<BotRoutine>): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* L's card call step (#958): at most one connector call per card, as H. For each due card, one transaction claims the call
|
|
49
|
+
* before it runs, and one transaction settles it and drops the claim. A claim that a later pass finds with no settle (a crash
|
|
50
|
+
* or a failed settle after the call) ends the card with `CONNECTOR_OUTCOME_UNKNOWN`, with no second call.
|
|
51
|
+
*/
|
|
52
|
+
export declare function callCardsInLedger(ledger: HostLedger, call: (card: Card) => Promise<unknown>): Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CompactVeto, type HostLedger, type LedgerState } from '@byok-sdk/server/execution-core';
|
|
2
|
+
import type { Turn } from './model.js';
|
|
3
|
+
/**
|
|
4
|
+
* K4 compacted the intent of this Turn, so its identity can never run again (#816). The intent tombstone proves it.
|
|
5
|
+
* A routine Turn's tombstone expires with its slot, but K4 removes its occurrence with the intent, and a routine Turn is
|
|
6
|
+
* written with its occurrence. So a routine Turn without its occurrence was compacted too.
|
|
7
|
+
*/
|
|
8
|
+
export declare function turnIntentRetired(ledger: HostLedger, s: Pick<LedgerState, 'occurrences'>, turn: Turn, now: number): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The K8 compact veto (#816). Open every Bot ledger with it: `new HostLedger(file, tenant, { compactVeto: botCompactVeto })`.
|
|
11
|
+
* It runs the K8 rule `compactVeto` (rules/compaction.ts) on the ledger's K4 intents and execution receipts.
|
|
12
|
+
*/
|
|
13
|
+
export declare const botCompactVeto: CompactVeto;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type LedgerState } from '@byok-sdk/server/execution-core';
|
|
2
|
+
import type { CollaborationState, Delegation, DelegationCancel } from './model.js';
|
|
3
|
+
import * as rules from './rules/delegation.js';
|
|
4
|
+
export { BOT_REPLY_MAX_BYTES, BOT_REQUEST_MAX_BYTES, CONTEXT_FIXED_MAX_BYTES, DEFAULT_CANCEL_GRACE_MS, DEFAULT_INSTRUCTION_MAX_BYTES, FRAME_MAX_BYTES, HOP_LIMIT, OPEN_DELEGATION_ENTRY_MAX_BYTES, OPEN_DELEGATIONS_MAX_BYTES, OPEN_DELEGATIONS_MAX_ITEMS, REPLY_REQUEST_MAX_BYTES, REPLY_RETRY_MAX_MS, REPLY_UNCERTAIN_AFTER_MS, ROOT_BOT_BUDGET, ROSTER_ENTRY_MAX_BYTES, applyDelegate, cancellable, claimUnit, crossBotRequest, delegationBlock, delegationDue, endChain, instructionOverhead, isCrossBot, minimumInstructionBytes, observeStart, openDelegations, openDelegationsContext, reconcileReply, releaseUnit, reserveUnits, resolveDelegation, retryReply, type DelegationTimers } from './rules/delegation.js';
|
|
5
|
+
/** The K4 facts of each Turn, read by Turn id when a rule asks for them. */
|
|
6
|
+
export declare function intentFacts(s: Pick<LedgerState, 'intents' | 'executions'>): rules.IntentFacts;
|
|
7
|
+
/** Only the intent rows: cancel arbitration reads no execution. */
|
|
8
|
+
export declare function intentRows(s: Pick<LedgerState, 'intents'>): Pick<rules.IntentFacts, 'intent'>;
|
|
9
|
+
export declare function observeDevices(s: LedgerState, state: CollaborationState, devices: ReadonlyMap<string, boolean>, emit: rules.Publish): void;
|
|
10
|
+
export declare function arbitrateCancel(s: Pick<LedgerState, 'intents'>, state: CollaborationState, d: Delegation, now: number, emit: rules.Publish, reason?: DelegationCancel['reason']): boolean;
|
|
11
|
+
export declare function settleDelegations(s: LedgerState, state: CollaborationState, now: number, emit: rules.Publish, timers?: rules.DelegationTimers): void;
|
|
12
|
+
export declare function abandonDelegation(s: LedgerState, state: CollaborationState, d: Delegation, now: number, emit: rules.Publish): boolean;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type Conclusion } from '@byok-sdk/server/execution-core';
|
|
2
|
+
import type { CollaborationState, Turn } from './model.js';
|
|
3
|
+
import { type Conversation, type Delivery, type InboundMessage, type PushRoute, type ReplyRoute } from './channel.js';
|
|
4
|
+
/** The intent conclusions a delivery rule reads. A K4 `LedgerState` fits; H passes its intent rows. */
|
|
5
|
+
export interface IntentConclusions {
|
|
6
|
+
readonly intents: Readonly<Record<string, {
|
|
7
|
+
readonly conclusion?: Conclusion;
|
|
8
|
+
}>>;
|
|
9
|
+
}
|
|
10
|
+
interface StoredInbound {
|
|
11
|
+
id: string;
|
|
12
|
+
conversation: Conversation;
|
|
13
|
+
channel: string;
|
|
14
|
+
sequence: number;
|
|
15
|
+
/** The Turn or open input batch that answers the message. Absent on a filtered message. */
|
|
16
|
+
root?: string;
|
|
17
|
+
/** The classification that refused the message before any Turn (#1229 item 3). */
|
|
18
|
+
filtered?: string;
|
|
19
|
+
reply?: Omit<ReplyRoute, 'token'> & {
|
|
20
|
+
token?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface ChannelState {
|
|
24
|
+
inbounds: Record<string, StoredInbound>;
|
|
25
|
+
pushRoutes: Record<string, PushRoute>;
|
|
26
|
+
deliveries: Record<string, Delivery>;
|
|
27
|
+
}
|
|
28
|
+
export declare function channelState(state: CollaborationState): ChannelState;
|
|
29
|
+
export declare function turnConversation(state: CollaborationState, turn: Turn): Conversation;
|
|
30
|
+
/** Save with input admission, before any process pass can accept its reply. Redelivery never refreshes a token. */
|
|
31
|
+
export declare function rememberInbound(state: CollaborationState, message: InboundMessage, root: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Records a message that the Host refused before any Turn (#1229 item 3), so its disposition is visible in the Host UI.
|
|
34
|
+
* An adapter identity that cannot name the message records nothing: the audit row is still the authority for it.
|
|
35
|
+
*/
|
|
36
|
+
export declare function rememberFilteredInbound(state: CollaborationState, message: InboundMessage, code: string): void;
|
|
37
|
+
export declare function enablePush(state: CollaborationState, conversation: Conversation, channel: string, target: string, owner: string, now: number): PushRoute;
|
|
38
|
+
export declare function revokePush(state: CollaborationState, id: string, now: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* Called in the content acceptance transaction. No external call or projection contains the token. A `staged` delivery
|
|
41
|
+
* waits for `promoteStaged` in its Turn's outcome transaction (#1762).
|
|
42
|
+
*/
|
|
43
|
+
export declare function queueDelivery(ledger: IntentConclusions, state: CollaborationState, turn: Turn, taskId: string, messageId: string, body: string, now: number, staged?: boolean): Delivery | undefined;
|
|
44
|
+
/** The outcome transaction of task `taskId` makes its staged deliveries sendable. The only promotion (#1762). */
|
|
45
|
+
export declare function promoteStaged(state: CollaborationState, taskId: string): string[];
|
|
46
|
+
/**
|
|
47
|
+
* A staged delivery whose intent concluded was not promoted by that conclusion's outcome: the Turn failed, or another task
|
|
48
|
+
* generation concluded it. Its reply is withheld and stays only as an audit fact (#1762).
|
|
49
|
+
*/
|
|
50
|
+
export declare function withholdStaged(ledger: IntentConclusions, state: CollaborationState): void;
|
|
51
|
+
/** A pending delivery already owns its reply slot, including across terminal settlement. */
|
|
52
|
+
export declare function deliveryRoute(state: CollaborationState, row: Delivery, now: number): ReplyRoute | PushRoute | undefined;
|
|
53
|
+
/** Route expiry is certain non-delivery for a pending row. Any fallback gets its own route-bound id. */
|
|
54
|
+
export declare function refuseRoute(state: CollaborationState, row: Delivery): void;
|
|
55
|
+
/**
|
|
56
|
+
* A reply is sent after its Turn concluded (#1762), so an open delivery keeps its token until expiry: a staged row waits for
|
|
57
|
+
* promotion, and an unknown row can return to pending after a readback.
|
|
58
|
+
*/
|
|
59
|
+
export declare function cleanReplyTokens(ledger: IntentConclusions, state: CollaborationState, now: number): void;
|
|
60
|
+
/** A manual resend is an explicit owner action, not an automatic retry of the unknown row. */
|
|
61
|
+
export declare function resendUnknown(state: CollaborationState, id: string, now: number): Delivery;
|
|
62
|
+
export declare function echoCandidates(state: CollaborationState, message: InboundMessage): Delivery[];
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Json } from '@byok-sdk/server/execution-core';
|
|
2
|
+
import { type ChannelPort, type Delivery } from './channel.js';
|
|
3
|
+
import type { CollaborationState } from './model.js';
|
|
4
|
+
/**
|
|
5
|
+
* #793 D2b-out delivery vectors. Each Host runs the same cases: the K8 L ledger now, and the H outbox sender in D2b-out-2.
|
|
6
|
+
* Each vector scripts its own `ChannelPort` and keeps its own call log. A subject sees only Host verbs and the K8 delivery
|
|
7
|
+
* entities, not its row layout, and every read may be async.
|
|
8
|
+
*
|
|
9
|
+
* The subject's Bot `main` takes owner messages on channel `fake` in its direct conversation, and the configured self bot of
|
|
10
|
+
* that channel is `own-bot`. Its business send deadline outlasts the steps of a case, so a held send is still in flight while
|
|
11
|
+
* later verbs run, and a send that never settles times out within the case.
|
|
12
|
+
* `drain`, `advance`, `publish`, `echo`, `resend`, `enablePush` and `revokePush` each end by running the Host, with
|
|
13
|
+
* one sender pass: a due row is sent inside the verb.
|
|
14
|
+
*/
|
|
15
|
+
export interface DeliverySubject {
|
|
16
|
+
/** The Host clock. */
|
|
17
|
+
now(): number;
|
|
18
|
+
/** Runs the Host. */
|
|
19
|
+
drain(): Promise<void>;
|
|
20
|
+
/** Moves the clock by `ms`, then runs the Host. */
|
|
21
|
+
advance(ms: number): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* The owner message `key` (`platformMessageId = key`) reaches Bot `main`. Its reply route is valid for `replyMs` and holds
|
|
24
|
+
* the token `replyToken(key)`; `replyMs: null` sends no route. Its Turn runs, its final Agent message `FINAL_BODY` is
|
|
25
|
+
* accepted, which stages the delivery, and the Turn concludes `succeeded`, which promotes it (#1762). Then the Host runs.
|
|
26
|
+
*/
|
|
27
|
+
publish(key: string, options?: {
|
|
28
|
+
replyMs?: number | null;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Holds the next send call: its claim commits and the send starts, but the call does not return until `release`. The verb
|
|
32
|
+
* that makes the claim returns once the send has started. While the send is held, the Host that holds it is busy, and each
|
|
33
|
+
* verb runs another Host from the stored state, which takes the claim over after `recoveryMs`. `release` lets the send
|
|
34
|
+
* return its scripted result, and waits until the holding Host has handled it. A second hold may start while the first is
|
|
35
|
+
* held; each one holds its own Host.
|
|
36
|
+
*/
|
|
37
|
+
holdNextSend(): {
|
|
38
|
+
release(): Promise<void>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Holds the next readback call in the same way: the port is called at once, so its result is the one at that time, and
|
|
42
|
+
* the result returns to the Host at `release`.
|
|
43
|
+
*/
|
|
44
|
+
holdNextReadback(): {
|
|
45
|
+
release(): Promise<void>;
|
|
46
|
+
};
|
|
47
|
+
/** The owner opts the direct conversation of Bot `main` into push on channel `fake`. Returns the route id. */
|
|
48
|
+
enablePush(target: string): Promise<string>;
|
|
49
|
+
revokePush(routeId: string): Promise<void>;
|
|
50
|
+
/** A verified echo of `own-bot` on channel `fake` for delivery `deliveryId`, with this platform message id. */
|
|
51
|
+
echo(deliveryId: string, platformMessageId: string): Promise<void>;
|
|
52
|
+
/** The owner's manual resend of an `unknown` delivery. Returns the new delivery id. */
|
|
53
|
+
resend(deliveryId: string): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* The next send claim commits, and the Host that made it never settles it: a Host that starts again from the stored
|
|
56
|
+
* state takes over. The subject applies it inside the verb that makes the claim.
|
|
57
|
+
*/
|
|
58
|
+
crashOnNextSend(): void;
|
|
59
|
+
/** How long after `crashOnNextSend` or a held send another Host recovers the claim. L recovers at startup; H after its lease. */
|
|
60
|
+
readonly recoveryMs: number;
|
|
61
|
+
/** The K8 delivery entities, in insertion order. */
|
|
62
|
+
deliveries(): Delivery[] | Promise<Delivery[]>;
|
|
63
|
+
/** Every projection that the Host published, sent or not. */
|
|
64
|
+
projections(): Array<{
|
|
65
|
+
id: string;
|
|
66
|
+
value: Json;
|
|
67
|
+
}> | Promise<Array<{
|
|
68
|
+
id: string;
|
|
69
|
+
value: Json;
|
|
70
|
+
}>>;
|
|
71
|
+
state(): CollaborationState | Promise<CollaborationState>;
|
|
72
|
+
/** Every stored row of the Host, as text. */
|
|
73
|
+
stored(): string | Promise<string>;
|
|
74
|
+
}
|
|
75
|
+
export declare const FINAL_BODY = "Final answer";
|
|
76
|
+
/** The reply route token of owner message `key`. */
|
|
77
|
+
export declare const replyToken: (key: string) => string;
|
|
78
|
+
export declare function deliveryVectors(name: string, open: (port: ChannelPort) => Promise<DeliverySubject>): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ChannelPort, Delivery } from './channel.js';
|
|
2
|
+
type SendResult = Awaited<ReturnType<ChannelPort['send']>>;
|
|
3
|
+
type ReadbackResult = Awaited<ReturnType<NonNullable<ChannelPort['readback']>>>;
|
|
4
|
+
/** Manual resend supplies a nonce. The original delivery keeps its audit identity. */
|
|
5
|
+
export declare function deliveryId(taskId: string, messageId: string, route: Delivery['route'], nonce?: string): string;
|
|
6
|
+
/** The caller persists this claim before it calls the channel. */
|
|
7
|
+
export declare function startDelivery(row: Delivery, now: number): boolean;
|
|
8
|
+
/** A stale completion cannot replace an echo or a later attempt's outcome. */
|
|
9
|
+
export declare function settleDelivery(row: Delivery, attempt: number, result: SendResult, now: number): void;
|
|
10
|
+
export declare function unknownDelivery(row: Delivery, attempt: number, code: string): void;
|
|
11
|
+
/** A persisted send claim does not prove that the platform received the message. */
|
|
12
|
+
export declare function recoverDelivery(row: Delivery): void;
|
|
13
|
+
/**
|
|
14
|
+
* Only authoritative absence permits a new attempt after uncertain I/O. `attempt` is the attempt that the readback observed:
|
|
15
|
+
* a result that comes after a later attempt changes nothing, as `settleDelivery` is fenced by its attempt.
|
|
16
|
+
*/
|
|
17
|
+
export declare function readbackDelivery(row: Delivery, attempt: number, result: ReadbackResult, now: number): void;
|
|
18
|
+
/** The caller has already checked the verified self principal and exact identity. */
|
|
19
|
+
export declare function acceptDeliveryEcho(row: Delivery, platformMessageId: string): boolean;
|
|
20
|
+
export {};
|
package/dist/dream.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type ExecutionTemplate, type HostOccurrenceRun, type LedgerState } from '@byok-sdk/server/execution-core';
|
|
2
|
+
import { type CollaborationState } from './model.js';
|
|
3
|
+
import { type ContextTurn } from './rules/context.js';
|
|
4
|
+
/** The time limit of a dream task. A user Turn behind a running dream waits at most this long. */
|
|
5
|
+
export declare const DEFAULT_DREAM_MAX_DURATION_MS = 900000;
|
|
6
|
+
/** A dream can sit behind a night of Bot work, so it waits longer than a routine Turn. */
|
|
7
|
+
export declare const DREAM_WAIT_MS = 3600000;
|
|
8
|
+
/** `dreaming` of `BotOptions`. Absent means on with these defaults; `false` turns dreaming off for the whole Host. */
|
|
9
|
+
export interface DreamingOptions {
|
|
10
|
+
/** IANA time zone of the daily 03:00 slot. Absent: this process's local zone when the routine is created, stored in its definition. */
|
|
11
|
+
timeZone?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Host model template names, preferred first. A dream takes the first that exists now and is on the Bot's device, else
|
|
14
|
+
* the Bot's own template. Only this list decides what is cheap: K8 infers nothing from a runtime or vendor name.
|
|
15
|
+
*/
|
|
16
|
+
models?: readonly string[];
|
|
17
|
+
/** Default `DEFAULT_DREAM_MAX_DURATION_MS`. */
|
|
18
|
+
maxDurationMs?: number;
|
|
19
|
+
/** Request native session input when the device advertises it. Default true. This applies only to runtime templates: a harness template, like a device that does not advertise native sessions, receives no request and the dream runs without that input. */
|
|
20
|
+
nativeSessions?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface DreamPolicy {
|
|
23
|
+
timeZone?: string;
|
|
24
|
+
models: readonly string[];
|
|
25
|
+
maxDurationMs: number;
|
|
26
|
+
nativeSessions: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Checks the option once, at construction. `undefined`: dreaming is off. */
|
|
29
|
+
export declare function dreamPolicy(options: DreamingOptions | false | undefined): DreamPolicy | undefined;
|
|
30
|
+
export type DreamSkip = 'superseded' | 'dreaming_off' | 'bot_archived' | 'bot_suspended' | 'device_unavailable' | 'bot_not_ready' | 'no_new_turns' | 'model_unavailable' | 'history_unavailable';
|
|
31
|
+
/** How one occurrence ended. `template` and `fallback` are set once a dream was offered. */
|
|
32
|
+
export interface DreamRecord {
|
|
33
|
+
occurrenceKey: string;
|
|
34
|
+
at: number;
|
|
35
|
+
outcome: 'skipped' | 'succeeded' | 'failed' | 'declined' | 'cancelled' | 'expired' | 'superseded';
|
|
36
|
+
reason?: string;
|
|
37
|
+
template?: string;
|
|
38
|
+
fallback?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** `since` starts the next window. `throughTurn` is the last Turn of the settled run of Turns that the last successful dream covered. */
|
|
41
|
+
export interface DreamBot {
|
|
42
|
+
since: number;
|
|
43
|
+
throughTurn?: string;
|
|
44
|
+
last?: DreamRecord;
|
|
45
|
+
}
|
|
46
|
+
/** An occurrence that K8 has not closed. `template` is set when it joined the FIFO. */
|
|
47
|
+
export interface OpenDream {
|
|
48
|
+
botId: string;
|
|
49
|
+
windowEnd: number;
|
|
50
|
+
template?: string;
|
|
51
|
+
fallback?: boolean;
|
|
52
|
+
throughTurn?: string;
|
|
53
|
+
}
|
|
54
|
+
/** The dream table. It owns each dream intent, as `hostIntents` owns a Host intent, and the Host intent API never reads it. */
|
|
55
|
+
export interface DreamState {
|
|
56
|
+
bots: Record<string, DreamBot>;
|
|
57
|
+
open: Record<string, OpenDream>;
|
|
58
|
+
}
|
|
59
|
+
/** The occurrence of a dream intent, or `undefined` for any other key. */
|
|
60
|
+
export declare function dreamOf(state: CollaborationState, intentKey: string): OpenDream | undefined;
|
|
61
|
+
/** The intent ids of open dreams: background work that user input goes ahead of. */
|
|
62
|
+
export declare function dreamIntentIds(state: CollaborationState): string[];
|
|
63
|
+
/** The `bot-dream` occurrence hook. A hook gets no K4 state, so the sync decides and promotes, as for a routine Turn. */
|
|
64
|
+
export declare function recordDream(state: CollaborationState, run: HostOccurrenceRun, now: number): void;
|
|
65
|
+
/** One dream routine for each unarchived Bot with a usable template, and no other. It runs in every sync, so it covers each way a Bot starts or ends. */
|
|
66
|
+
export declare function reconcileDreamRoutines(s: LedgerState, policy: DreamPolicy | undefined, models: Readonly<Record<string, ExecutionTemplate>>, now: number): void;
|
|
67
|
+
/** Refuses an `instructionMaxBytes` that leaves a dream no room for history. */
|
|
68
|
+
export declare function checkDreamInstruction(instructionMaxBytes: number): void;
|
|
69
|
+
export interface DreamSync {
|
|
70
|
+
tenant: string;
|
|
71
|
+
policy: DreamPolicy | undefined;
|
|
72
|
+
models: Readonly<Record<string, ExecutionTemplate>>;
|
|
73
|
+
instructionMaxBytes: number;
|
|
74
|
+
now: number;
|
|
75
|
+
/** The device of a Bot refuses new work. */
|
|
76
|
+
refused(botId: string): boolean;
|
|
77
|
+
/** Absent: the ledger's Turns are the history. Present: the rows an external history read returned by occurrence key, `null` for a failed read. */
|
|
78
|
+
history?: ReadonlyMap<string, readonly ContextTurn[] | null> | undefined;
|
|
79
|
+
historyMode: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** Decides each new occurrence and closes each settled dream. Returns true when a dream joined the FIFO or an occurrence concluded. */
|
|
82
|
+
export declare function syncDreams(s: LedgerState, sync: DreamSync): boolean;
|
|
83
|
+
/** The dreams that wait for an external history read, by occurrence key, with the Bot and the intent key of the read. */
|
|
84
|
+
export declare function dreamReads(state: CollaborationState): {
|
|
85
|
+
key: string;
|
|
86
|
+
botId: string;
|
|
87
|
+
turnId: string;
|
|
88
|
+
}[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ByokServer } from '@byok-sdk/server';
|
|
2
|
+
import { HostLedger } from '@byok-sdk/server/execution-core';
|
|
3
|
+
export type HomeServer = Partial<Pick<ByokServer, 'enqueueAgentHomeProjection' | 'readAgentHomeProjection'>>;
|
|
4
|
+
/** Called only from the Host serial consumer. All delivery ids are durable. */
|
|
5
|
+
export declare function flushHomes(server: HomeServer, ledger: HostLedger, now: () => number): Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export { DelegationError, HostIntentError } from './rules/delegation.js';
|
|
2
|
+
export { IntentOutcomeError } from './adapter-steps.js';
|
|
3
|
+
export { RetentionRefused, retainRoots } from './retention.js';
|
|
4
|
+
export type { RetentionFacts, RetentionInput, RetentionRefusedCode, RetentionLimits, RetentionResult, RetentionStore } from './retention.js';
|
|
5
|
+
export { refuseRetired, retiredIdentity, RetiredIdentityError, type AdmittedIds, type RetiredNamespace } from './rules/commands.js';
|
|
6
|
+
export type { DelegationCancelResult, TurnCancelResult } from './rules/delegation.js';
|
|
7
|
+
export type { MessageDisposition } from './rules/message.js';
|
|
8
|
+
export { contextTurns, historyRowFromTurn, type ContextTurn } from './rules/context.js';
|
|
9
|
+
export { classifyInbound, inboundKey } from './channel.js';
|
|
10
|
+
export type { ChannelOptions, ChannelPort, Conversation, Delivery, DeliveryState, InboundClass, InboundMessage, Principal, PushRoute, ReplyRoute } from './channel.js';
|
|
11
|
+
export { BOT_REPLY_MAX_BYTES, DEFAULT_INSTRUCTION_MAX_BYTES, minimumInstructionBytes } from './delegation.js';
|
|
12
|
+
export { SYSTEM_PROMPT, contextPack, outcomeOffer, outcomeSchema, DEFAULT_CONTEXT_MAX_BYTES, DEFAULT_CONTEXT_TURN_LIMIT, DEFAULT_HANDOFF_BUDGETS } from './schema.js';
|
|
13
|
+
export type { CheckedOffer, ConfirmableSpec, MainAction, OutcomeOffer, TurnAction } from './schema.js';
|
|
14
|
+
export type { Card, CollaborationState, Delegation, InputBatch, ReplyEntry, SealReason, Turn, UserInput } from './model.js';
|
|
15
|
+
export { BOT_DREAM, BOT_ROUTINE, botRoutines } from './routines.js';
|
|
16
|
+
export { DEFAULT_DREAM_MAX_DURATION_MS, DREAM_WAIT_MS, type DreamBot, type DreamingOptions, type DreamRecord, type DreamSkip, type DreamState, type OpenDream } from './dream.js';
|
|
17
|
+
export { CommitConflict, commitInLedger, migrateWouldDo, retainInLedger, revisionOf } from './commit.js';
|
|
18
|
+
export type { Command, CommandPorts, CommitRequest, CommitResult, Disposition, OutboxIntent, WouldDoMigration } from './commit.js';
|
|
19
|
+
export type { BotRoutine, BotRoutineInput } from './routines.js';
|
|
20
|
+
export type { BotProfile, Room, Round, Seat, TeamState } from './team-model.js';
|
|
21
|
+
export { DEFAULT_MEMBER_MENTIONS, ROOM_GRACE_MS, ROOM_CONTEXT_BYTES, ROOM_CONTEXT_MESSAGES, memberMentions, type MemberMentions, type RoomMessage } from './rooms.js';
|
|
22
|
+
export { TEAM_NOTE_LIMIT } from './team.js';
|
|
23
|
+
export { DEFAULT_AUTONOMY, autonomyOf, wouldDoRows, type Autonomy, type WouldDo, type WouldDoAction } from './rules/autonomy.js';
|
|
24
|
+
export { inboundDisposition, inboundDispositions, type InboundDisposition, type InboundRow, type InboundState } from './rules/inbound.js';
|
|
25
|
+
export { DEVICE_CONCURRENCY } from './rules/priority.js';
|
|
26
|
+
export { DeviceModeError, type DeviceTopology, type SwitchWork } from './topology.js';
|
|
27
|
+
export { SWITCH_EXPORT_VERSION, SWITCH_SECTIONS, SwitchExportError, sealSwitchExport, switchAttempts, verifySwitchExport, type ArchivedRecord, type ExecutionRecord, type IntentRecord, type MessageReceipt, type OccurrenceRecord, type OutboxRecord, type RoutineRecord, type SwitchContent, type SwitchDevice, type SwitchExport, type SwitchExportRefusal, type SwitchManifest, type SwitchSection, type TombstoneRecord } from './migration.js';
|
|
28
|
+
export { commitImport, discardImport, importForSwitch } from './switch.js';
|
|
29
|
+
export { DeviceSwitchingError, SwitchExportedError, SwitchImportedError, type SwitchReceipt } from './migration.js';
|
|
30
|
+
export { botOutcomePorts, outcomeFailure, routeTerminal, runHostIntentHandler, syncHead, syncTail } from './adapter-steps.js';
|
|
31
|
+
export { isOwner, verified } from './channel.js';
|
|
32
|
+
export { admitUserInput } from './coalesce.js';
|
|
33
|
+
export { acceptDeliveryEcho, readbackDelivery, recoverDelivery, settleDelivery, startDelivery, unknownDelivery } from './delivery.js';
|
|
34
|
+
export { cleanReplyTokens, deliveryRoute, echoCandidates, enablePush, promoteStaged, queueDelivery, refuseRoute, rememberInbound, resendUnknown, revokePush, type IntentConclusions } from './delivery-routing.js';
|
|
35
|
+
export { checkDreamInstruction, dreamIntentIds, dreamPolicy, reconcileDreamRoutines, recordDream, syncDreams, type DreamSync } from './dream.js';
|
|
36
|
+
export { exportMarkOf, type SwitchExportMark, type SwitchHeader } from './migration.js';
|
|
37
|
+
export { stateOf } from './model.js';
|
|
38
|
+
export { concludeRoutineTurn, createDefinition, endable, owned, resealDefinition, ROUTINE_LATE_AFTER_MS, ROUTINE_WAIT_MS, routineCalendar, routineOccurrence, routineTurn, sealedDefinition, sealedRoutineInstruction, sealedTemplate, SealedRoutineVersionError, updateDefinition, type SealedRoutineAction } from './routines.js';
|
|
39
|
+
export { sealLedger } from './switch.js';
|
|
40
|
+
export { applyHomeTerminal, applyManagement, applyModels, checkHomeReadback, failHomeFlush, homeEnqueued, homeHead, homeRequests, planHomeRetry, updateBot, writeSnapshotBot, type HomeReadback } from './team.js';
|
package/dist/host-kit.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DEFAULT_DREAM_MAX_DURATION_MS, DREAM_WAIT_MS, DeviceModeError, DeviceSwitchingError, IntentOutcomeError, SWITCH_EXPORT_VERSION, SWITCH_SECTIONS, SwitchExportError, SwitchExportedError, SwitchImportedError, acceptDeliveryEcho, admitUserInput, botOutcomePorts, checkDreamInstruction, cleanReplyTokens, commitImport, commitInLedger, deliveryRoute, discardImport, dreamIntentIds, dreamPolicy, echoCandidates, enablePush, exportMarkOf, importForSwitch, inboundDisposition, inboundDispositions, migrateWouldDo, outcomeFailure, promoteStaged, queueDelivery, readbackDelivery, reconcileDreamRoutines, recordDream, recoverDelivery, refuseRoute, rememberInbound, resendUnknown, retainInLedger, revokePush, routeTerminal, runHostIntentHandler, sealLedger, sealSwitchExport, settleDelivery, startDelivery, switchAttempts, syncDreams, syncHead, syncTail, unknownDelivery, verifySwitchExport } from './chunk-5J5SOWWI.js';
|
|
2
|
+
export { BOT_DREAM, BOT_ROUTINE, ROUTINE_LATE_AFTER_MS, ROUTINE_WAIT_MS, RetentionRefused, SealedRoutineVersionError, TEAM_NOTE_LIMIT, applyHomeTerminal, applyManagement, applyModels, botRoutines, checkHomeReadback, classifyInbound, concludeRoutineTurn, contextPack, createDefinition, endable, failHomeFlush, homeEnqueued, homeHead, homeRequests, inboundKey, isOwner, owned, planHomeRetry, resealDefinition, retainRoots, routineCalendar, routineOccurrence, routineTurn, sealedDefinition, sealedRoutineInstruction, sealedTemplate, stateOf, updateBot, updateDefinition, verified, writeSnapshotBot } from './chunk-XTZUCECQ.js';
|
|
3
|
+
export { DEVICE_CONCURRENCY } from './chunk-33YA66U7.js';
|
|
4
|
+
export { BOT_REPLY_MAX_BYTES, CommitConflict, DEFAULT_AUTONOMY, DEFAULT_CONTEXT_MAX_BYTES, DEFAULT_CONTEXT_TURN_LIMIT, DEFAULT_HANDOFF_BUDGETS, DEFAULT_INSTRUCTION_MAX_BYTES, DEFAULT_MEMBER_MENTIONS, DelegationError, HostIntentError, ROOM_CONTEXT_BYTES, ROOM_CONTEXT_MESSAGES, ROOM_GRACE_MS, RetiredIdentityError, SYSTEM_PROMPT, autonomyOf, contextTurns, historyRowFromTurn, memberMentions, minimumInstructionBytes, outcomeOffer, outcomeSchema, refuseRetired, retiredIdentity, revisionOf, wouldDoRows } from './chunk-ZUFZCROA.js';
|
|
5
|
+
//# sourceMappingURL=host-kit.js.map
|
|
6
|
+
//# sourceMappingURL=host-kit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"host-kit.js"}
|