@byok-sdk/bot-collaboration 0.0.0-stage → 0.43.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 +2075 -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-6Y2B2XCP.js +12 -0
- package/dist/chunk-6Y2B2XCP.js.map +1 -0
- package/dist/chunk-QZRWFFHM.js +12 -0
- package/dist/chunk-QZRWFFHM.js.map +1 -0
- package/dist/chunk-ZX6C5U2S.js +27 -0
- package/dist/chunk-ZX6C5U2S.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 +53 -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 +60 -0
- package/dist/host-kit.js +11 -0
- package/dist/host-kit.js.map +1 -0
- package/dist/host.d.ts +472 -0
- package/dist/inbound.d.ts +17 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +19 -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 +89 -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 +366 -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/store-compatibility.d.ts +3 -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 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/host-kit.ts"],"names":["botTurnInstruction"],"mappings":";;;;;;AAcO,SAASA,mBAAAA,CAA6C,QAAgE,CAC3H,MAAM,SAAW,OAAA,CAAQ,QAAA,EAAY,EAAC,CACtC,MAAM,MAAA,CAAS,cAAc,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAO,OAAA,CAAQ,KAAA,CAAO,OAAA,CAAQ,KAAM,OAAA,CAAQ,MAAA,CAAQ,QAAA,CAAU,OAAA,CAAQ,KAAK,CAAA,CACrH,KAAM,CAAE,WAAY,EAAI,kBAAA,CAAwB,OAAA,CAAQ,MAAO,OAAA,CAAQ,IAAA,CAAM,OAAA,CAAQ,MAAA,CAAQ,QAAA,CAAU,OAAA,CAAQ,SAAU,OAAA,CAAQ,IAAA,CAAM,aAAA,CAAc,MAAA,CAAQ,OAAA,CAAQ,KAAK,CAAC,CAAA,CAC3K,OAAO,CAAE,WAAY,CACvB","file":"host-kit.js","sourcesContent":["// The `./host-kit` entry: the L modules a Host adapter composes (model, channel, delivery, routines, team,\n// migration, retention, dreaming, adapter steps). It does not load the L Host or @byok-sdk/client, so a Worker\n// can bundle it.\nimport { botTurnInstruction as buildBotTurnInstruction, type BotHistoryState, type ContextTurn, type InstructionLimits } from './rules/context.js';\nimport { outcomeSchema, promptActions, type CheckedOffer, type ContextRoutine, type ContextState } from './rules/schema.js';\nimport type { RoomMessage } from './rules/rooms.js';\nimport type { Turn } from './rules/turn.js';\n\n/** Inputs used by sync to freeze a Bot Turn's instruction. */\nexport interface BotTurnInstructionOptions<R extends ContextRoutine = ContextRoutine> {\n state: ContextState & BotHistoryState; turn: Turn; limits: InstructionLimits; models: readonly string[];\n routines?: readonly R[]; injected?: readonly ContextTurn[]; room?: readonly RoomMessage[]; offer?: CheckedOffer;\n}\n/** Compute the instruction sync freezes, with the same history, routines and offer. */\nexport function botTurnInstruction<R extends ContextRoutine>(options: BotTurnInstructionOptions<R>): { instruction: string } {\n const routines = options.routines ?? [];\n const schema = outcomeSchema(options.turn.botId, options.state, options.turn, options.models, routines, options.offer);\n const { instruction } = buildBotTurnInstruction(options.state, options.turn, options.limits, routines, options.injected, options.room, promptActions(schema, options.offer));\n return { instruction };\n}\nexport type { InstructionLimits } from './rules/context.js';\nexport { DelegationError, HostIntentError } from './rules/delegation.js';\nexport { IntentOutcomeError } from './adapter-steps.js';\nexport { RetentionRefused, retainRoots } from './retention.js';\nexport type { RetentionFacts, RetentionInput, RetentionRefusedCode, RetentionLimits, RetentionResult, RetentionStore } from './retention.js';\nexport { refuseRetired, retiredIdentity, RetiredIdentityError, type AdmittedIds, type RetiredNamespace } from './rules/commands.js';\nexport type { DelegationCancelResult, TurnCancelResult } from './rules/delegation.js';\nexport type { MessageDisposition } from './rules/message.js';\nexport { contextTurns, historyRowFromTurn, type ContextTurn } from './rules/context.js';\nexport { classifyInbound, inboundKey } from './channel.js';\nexport type { ChannelOptions, ChannelPort, Conversation, Delivery, DeliveryState, InboundClass, InboundMessage, Principal, PushRoute, ReplyRoute } from './channel.js';\nexport { BOT_REPLY_MAX_BYTES, DEFAULT_INSTRUCTION_MAX_BYTES, minimumInstructionBytes } from './delegation.js';\nexport { SYSTEM_PROMPT, contextPack, outcomeOffer, outcomeSchema, DEFAULT_CONTEXT_MAX_BYTES, DEFAULT_CONTEXT_TURN_LIMIT, DEFAULT_HANDOFF_BUDGETS } from './schema.js';\nexport type { CheckedOffer, ConfirmableSpec, MainAction, OutcomeOffer, TurnAction } from './schema.js';\nexport type { Card, CollaborationState, Delegation, InputBatch, ReplyEntry, SealReason, Turn, UserInput } from './model.js';\nexport { BOT_DREAM, BOT_ROUTINE, botRoutines } from './routines.js';\nexport { DEFAULT_DREAM_MAX_DURATION_MS, DREAM_WAIT_MS, type DreamBot, type DreamingOptions, type DreamRecord, type DreamSkip, type DreamState, type OpenDream } from './dream.js';\nexport { CommitConflict, commitInLedger, migrateWouldDo, retainInLedger, revisionOf } from './commit.js';\nexport type { Command, CommandPorts, CommitRequest, CommitResult, Disposition, OutboxIntent, WouldDoMigration } from './commit.js';\nexport type { BotRoutine, BotRoutineInput } from './routines.js';\nexport type { BotProfile, Room, Round, Seat, TeamState } from './team-model.js';\nexport { DEFAULT_MEMBER_MENTIONS, ROOM_GRACE_MS, ROOM_CONTEXT_BYTES, ROOM_CONTEXT_MESSAGES, memberMentions, type MemberMentions, type RoomMessage } from './rooms.js';\nexport { TEAM_NOTE_LIMIT } from './team.js';\nexport { DEFAULT_AUTONOMY, autonomyOf, wouldDoRows, type Autonomy, type WouldDo, type WouldDoAction } from './rules/autonomy.js';\nexport { inboundDisposition, inboundDispositions, type InboundDisposition, type InboundRow, type InboundState } from './rules/inbound.js';\nexport { DEVICE_CONCURRENCY } from './rules/priority.js';\nexport { DeviceModeError, type DeviceTopology, type SwitchWork } from './topology.js';\nexport { SWITCH_EXPORT_VERSION, SWITCH_SECTIONS, SwitchExportError, sealSwitchExport, switchAttempts, verifySwitchExport, type ArchivedRecord, type ExecutionRecord, type IntentRecord, type MessageReceipt,\n type OccurrenceRecord, type OutboxRecord, type RoutineRecord, type SwitchContent, type SwitchDevice, type SwitchExport, type SwitchExportRefusal,\n type SwitchManifest, type SwitchSection, type TombstoneRecord } from './migration.js';\nexport { commitImport, discardImport, importForSwitch } from './switch.js';\nexport { DeviceSwitchingError, SwitchExportedError, SwitchImportedError, type SwitchReceipt } from './migration.js';\nexport { botOutcomePorts, outcomeFailure, routeTerminal, runHostIntentHandler, syncHead, syncTail } from './adapter-steps.js';\nexport { isOwner, verified } from './channel.js';\nexport { admitUserInput } from './coalesce.js';\nexport { acceptDeliveryEcho, readbackDelivery, recoverDelivery, settleDelivery, startDelivery, unknownDelivery } from './delivery.js';\nexport { cleanReplyTokens, deliveryRoute, echoCandidates, enablePush, promoteStaged, queueDelivery, refuseRoute, rememberInbound, resendUnknown,\n revokePush, type IntentConclusions } from './delivery-routing.js';\nexport { checkDreamInstruction, dreamIntentIds, dreamPolicy, reconcileDreamRoutines, recordDream, syncDreams, type DreamSync } from './dream.js';\nexport { exportMarkOf, type SwitchExportMark, type SwitchHeader } from './migration.js';\nexport { stateOf } from './model.js';\nexport { concludeRoutineTurn, createDefinition, endable, owned, resealDefinition, ROUTINE_LATE_AFTER_MS, ROUTINE_WAIT_MS, routineCalendar,\n routineOccurrence, routineTurn, sealedDefinition, sealedRoutineInstruction, sealedTemplate, SealedRoutineVersionError, updateDefinition,\n type SealedRoutineAction } from './routines.js';\nexport { sealLedger } from './switch.js';\nexport { applyHomeTerminal, applyManagement, applyModels, checkHomeReadback, failHomeFlush, homeEnqueued, homeHead, homeRequests, planHomeRetry,\n updateBot, writeSnapshotBot, type HomeReadback } from './team.js';\n"]}
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import { type HandoffPackBudgets, type UpdateRoutineAction } from '@byok-sdk/protocol';
|
|
2
|
+
import type { ByokServer, CreateByokServerOptions, DueWake } from '@byok-sdk/server';
|
|
3
|
+
import { HostExecutionCore, type ExecutionServer, type HostOptions, type Intent, type IntentInput, type OutcomeTransaction, type MessageTransaction } from '@byok-sdk/server/execution-core';
|
|
4
|
+
import type { HostJobHandler, Routine } from '@byok-sdk/server/execution-core';
|
|
5
|
+
import { HostLedger, type Conclusion } from '@byok-sdk/server/execution-core';
|
|
6
|
+
import { type ExecutionTemplate, type Json } from '@byok-sdk/server/execution-core';
|
|
7
|
+
import { type CollaborationState } from './model.js';
|
|
8
|
+
import { type ContextTurn, type OutcomeOffer } from './schema.js';
|
|
9
|
+
import { type DelegationCancelResult, type IntentCancelResult, type TurnCancelResult } from './rules/delegation.js';
|
|
10
|
+
import { type MessageDisposition } from './rules/message.js';
|
|
11
|
+
import type { RetentionInput, RetentionResult } from './retention.js';
|
|
12
|
+
import { type DreamingOptions } from './dream.js';
|
|
13
|
+
import { type Autonomy, type WouldDo } from './rules/autonomy.js';
|
|
14
|
+
import { type TeamSnapshot } from './rules/team.js';
|
|
15
|
+
import { type MemberMentions, type Mentions, type RoomMessage } from './rooms.js';
|
|
16
|
+
import type { RoomFields } from '@byok-sdk/protocol';
|
|
17
|
+
import { type HomeServer } from './home-projections.js';
|
|
18
|
+
import { type DeviceTopology, type SwitchWork } from './topology.js';
|
|
19
|
+
import { type SwitchExport } from './migration.js';
|
|
20
|
+
import { type CoalescePolicy } from './coalesce.js';
|
|
21
|
+
import { type ChannelOptions, type Conversation, type InboundClass, type InboundMessage, type PrincipalArg } from './channel.js';
|
|
22
|
+
import type { InboundDisposition } from './rules/inbound.js';
|
|
23
|
+
export interface BotOptions {
|
|
24
|
+
botId: string;
|
|
25
|
+
execution: ExecutionTemplate;
|
|
26
|
+
now?: () => number;
|
|
27
|
+
/** Owner principal id (#552 R2). Default `owner`. Only the human principal with this id passes the owner checks. */
|
|
28
|
+
owner?: string;
|
|
29
|
+
/** Optional Host IM outbox. Push stays off until an owner enables a route. */
|
|
30
|
+
channel?: ChannelOptions;
|
|
31
|
+
/**
|
|
32
|
+
* Host-owned model templates. New Bots stay on the selected template's device. Construction and `setModels` apply each
|
|
33
|
+
* template by model name to every unarchived Bot. A Bot whose model has none keeps its Turns blocked (`Unavailable model`).
|
|
34
|
+
*/
|
|
35
|
+
models?: Record<string, ExecutionTemplate>;
|
|
36
|
+
/** Host-owned read-only toolset IDs. Default empty. The Host's local tool server must enforce read-only behavior. */
|
|
37
|
+
readOnlyToolsets?: readonly string[];
|
|
38
|
+
/** Must deduplicate by id. A committed confirmation can be replayed after a crash. */
|
|
39
|
+
connector: (id: string, action: string, draft: Json, signal: AbortSignal) => Promise<Json>;
|
|
40
|
+
/** The Host also enforces this limit when a connector ignores cancellation. */
|
|
41
|
+
connectorTimeoutMs?: number;
|
|
42
|
+
contextMaxBytes?: number;
|
|
43
|
+
contextTurnLimit?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Bytes of the Bot history in a ContextPack. Default: `DEFAULT_HANDOFF_BUDGETS`. Construction checks it against an empty
|
|
46
|
+
* pack only, so a `totalBytes` that cannot hold the digits of the turn count throws `RangeError` at sync.
|
|
47
|
+
*/
|
|
48
|
+
handoff?: HandoffPackBudgets;
|
|
49
|
+
/** UTF-8 bound of a whole bot_request or bot_reply instruction. Construction refuses a value below the proven minimum. */
|
|
50
|
+
instructionMaxBytes?: number;
|
|
51
|
+
/** A cancel with no terminal after this time shows `uncertain` (§8.3). */
|
|
52
|
+
cancelGraceMs?: number;
|
|
53
|
+
/** A claimed chain Turn, or a reply check, with no verdict after this time shows `uncertain` (§8.3). */
|
|
54
|
+
uncertainAfterMs?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Merge consecutive user inputs to a busy Bot into one Turn before K4 enqueue (#551). Absent means off.
|
|
57
|
+
* Defaults: windowMs 10_000, maxItems 8, maxBytes 8192. Construction refuses a value outside
|
|
58
|
+
* windowMs 1000 to 60_000, maxItems 2 to 16, or maxBytes 1024 to contextMaxBytes / 4.
|
|
59
|
+
*/
|
|
60
|
+
coalesce?: Partial<CoalescePolicy>;
|
|
61
|
+
/**
|
|
62
|
+
* Handlers for the Host's own K4 Host job routines. They share the core with Bot routines,
|
|
63
|
+
* so their rules use the same calendar: a `RoutineSchedule` whose `tz` is the definition time zone.
|
|
64
|
+
*/
|
|
65
|
+
hostJobs?: Readonly<Record<string, HostJobHandler>>;
|
|
66
|
+
/**
|
|
67
|
+
* Handlers of the Host's own K4 intents (#882), by name. `enqueueHostIntent` stores the name with the intent.
|
|
68
|
+
* At a `task.complete` terminal, the handler runs synchronously in the terminal transaction with the result document.
|
|
69
|
+
* An intent whose execution has `messageEgress` also needs a handler of the same name in `hostIntentMessages`.
|
|
70
|
+
*/
|
|
71
|
+
hostIntents?: Readonly<Record<string, HostIntentHandler>>;
|
|
72
|
+
/**
|
|
73
|
+
* Agent message handlers of Host intents (#1356), by the `hostIntents` name. The handler runs synchronously in the K4
|
|
74
|
+
* message transaction and decides the message. K8 records an accepted message without its body and does not deliver it.
|
|
75
|
+
* A Host intent whose name has no message handler refuses its messages with `binding_mismatch`.
|
|
76
|
+
*/
|
|
77
|
+
hostIntentMessages?: Readonly<Record<string, HostIntentMessageHandler>>;
|
|
78
|
+
/**
|
|
79
|
+
* Dreaming (#1475). Absent: on, one dream per Bot per day that had a completed Turn, at 03:00 local time, on the Bot's own model.
|
|
80
|
+
* `false`: off for the whole Host, and open dream routines end. See the README for the cost.
|
|
81
|
+
*/
|
|
82
|
+
dreaming?: DreamingOptions | false;
|
|
83
|
+
/** Passed to the K4 core. Default 100. */
|
|
84
|
+
reconcileMs?: number;
|
|
85
|
+
/** Passed to the K4 core: a coalesced hint after a commit that wrote the outbox. */
|
|
86
|
+
onOutbox?: HostOptions['onOutbox'];
|
|
87
|
+
/**
|
|
88
|
+
* External history authority (#739 Q4). Absent: the ContextPack reads this ledger's Turns.
|
|
89
|
+
* Present: before a Bot Turn freezes its offer, the Host reads the Bot's earlier history here, oldest first,
|
|
90
|
+
* in the ContextPack row shape. The rows replace the stored Turns in that ContextPack and are not stored;
|
|
91
|
+
* the Turn keeps only their hash. Cards, questions and rejected actions stay Host state. Room seats read `roomHistory`.
|
|
92
|
+
* A read that throws, returns another shape or is still open after `historyTimeoutMs` leaves the Turn queued, and the timer
|
|
93
|
+
* tries again. A dream (#1475) reads here too, with `turnId` set to the dream's intent key. A failed read skips that day.
|
|
94
|
+
*/
|
|
95
|
+
history?: (input: {
|
|
96
|
+
botId: string;
|
|
97
|
+
turnId: string;
|
|
98
|
+
}) => Promise<readonly ContextTurn[]>;
|
|
99
|
+
/**
|
|
100
|
+
* External room history authority (#883). Absent: a seat ContextPack reads the room messages of this ledger.
|
|
101
|
+
* Present: before a seat Turn freezes its offer, the Host reads here the room messages that the seat's Bot can see,
|
|
102
|
+
* oldest first. The authority selects them for that Bot. The rows replace `room.messages` in that ContextPack and are
|
|
103
|
+
* not stored; the seat Turn keeps only their hash. `room.messages` is still written, for the request text and mentions.
|
|
104
|
+
* A read that throws, returns another shape or is still open after `historyTimeoutMs` or at the seat deadline leaves the seat
|
|
105
|
+
* queued, and the timer tries again until the seat deadline.
|
|
106
|
+
*/
|
|
107
|
+
roomHistory?: (input: {
|
|
108
|
+
roomId: string;
|
|
109
|
+
botId: string;
|
|
110
|
+
turnId: string;
|
|
111
|
+
}) => Promise<readonly RoomMessage[]>;
|
|
112
|
+
/**
|
|
113
|
+
* How long a `history` or `roomHistory` read may stay open before it counts as failed. The reads run one after another
|
|
114
|
+
* in the Host queue, so this bounds how long a stalled authority holds it. The read is not aborted. Default 10_000.
|
|
115
|
+
*/
|
|
116
|
+
historyTimeoutMs?: number;
|
|
117
|
+
/**
|
|
118
|
+
* External team authority (#739 Q4c). Absent: this Host creates the Main Bot and owns its local team.
|
|
119
|
+
* `external`: the constructor creates no Bot. `applyTeam` writes the authority's Bot snapshots, and
|
|
120
|
+
* `setMainBot`, `create_bot`, `update_bot` and `delete_bot` refuse with `external_team`. The mode is stored
|
|
121
|
+
* in the ledger, so a ledger cannot change its mode at a restart.
|
|
122
|
+
*/
|
|
123
|
+
team?: 'external';
|
|
124
|
+
/**
|
|
125
|
+
* Host persona mode (#879), only with `team: 'external'`. The Host projects each Bot's Agent home itself. A snapshot
|
|
126
|
+
* Bot carries the Host's `profileRevision`, which becomes its agentRef revision, and K8 queues no persona projection.
|
|
127
|
+
* The Host reports an applied revision with `personaReady`. `retryPersona` refuses with `external_persona`.
|
|
128
|
+
* The ledger stores the mode, so a restart cannot change it.
|
|
129
|
+
*/
|
|
130
|
+
persona?: 'external';
|
|
131
|
+
/**
|
|
132
|
+
* External rooms mode (#1321), only with `team: 'external'`. Each team snapshot carries the authority's whole room list,
|
|
133
|
+
* and a room that it no longer lists is archived for good. `createRoom`, `updateRoom`, `setMemberMentions` and the Main Bot's
|
|
134
|
+
* `create_room` and `update_room` refuse with `external_rooms`. The ledger stores the mode, so a restart cannot change it.
|
|
135
|
+
*/
|
|
136
|
+
rooms?: 'external';
|
|
137
|
+
/**
|
|
138
|
+
* Outcome offer (#881): allowlists of actions by Turn kind, the IANA time zones of routine actions, and the
|
|
139
|
+
* `confirmable_action` branches. Each field only narrows the default. It applies to Turns frozen after construction.
|
|
140
|
+
*/
|
|
141
|
+
outcome?: OutcomeOffer;
|
|
142
|
+
/**
|
|
143
|
+
* The concurrent task limit of each device (#1229 item 1), as the daemon's `maxConcurrentTasks`. Default 8.
|
|
144
|
+
* The Host leaves one slot free for user-source work; submitted work is never cancelled to make room.
|
|
145
|
+
*/
|
|
146
|
+
deviceConcurrency?: number;
|
|
147
|
+
}
|
|
148
|
+
/** Synchronous. A throw or a thenable leaves the intent open, and `drain()` rejects. */
|
|
149
|
+
export type HostIntentHandler = (document: unknown, transaction: OutcomeTransaction) => void;
|
|
150
|
+
/** Synchronous. A throw rolls the message transaction back, and a thenable or another result throws. */
|
|
151
|
+
export type HostIntentMessageHandler = (input: AgentMessageInput, transaction: MessageTransaction) => MessageDisposition;
|
|
152
|
+
/**
|
|
153
|
+
* The cancel answer of a Host intent (K8 `IntentCancelResult`). `conclusion` is optional: an in-flight intent awaits its
|
|
154
|
+
* terminal, and an unsubmitted intent may await a successful drain after a `drainError` or `wakePending` result.
|
|
155
|
+
*/
|
|
156
|
+
export type HostIntentCancelResult = IntentCancelResult<Conclusion> & {
|
|
157
|
+
wakePending?: true;
|
|
158
|
+
drainError?: unknown;
|
|
159
|
+
};
|
|
160
|
+
/** Reply readback port (§3.3). The Host acceptance record stays the body authority. */
|
|
161
|
+
export type MessageServer = {
|
|
162
|
+
tasks: Partial<Pick<ByokServer['tasks'], 'agentMessage'>>;
|
|
163
|
+
};
|
|
164
|
+
export type AgentMessageInput = Parameters<NonNullable<CreateByokServerOptions['agentMessage']>['consume']>[0];
|
|
165
|
+
/** The local K8 Host. Use one instance per ledger tenant. */
|
|
166
|
+
export declare class BotCollaboration {
|
|
167
|
+
readonly server: ExecutionServer & HomeServer & MessageServer & Partial<Pick<ByokServer, 'machines'>>;
|
|
168
|
+
readonly ledger: HostLedger;
|
|
169
|
+
private readonly options;
|
|
170
|
+
readonly core: HostExecutionCore;
|
|
171
|
+
private chain;
|
|
172
|
+
private timer?;
|
|
173
|
+
private closed;
|
|
174
|
+
private readonly now;
|
|
175
|
+
private readonly connectorTimeoutMs;
|
|
176
|
+
private readonly deliveryTimeoutMs;
|
|
177
|
+
private readonly historyTimeoutMs;
|
|
178
|
+
private readonly contextMaxBytes;
|
|
179
|
+
private readonly contextTurnLimit;
|
|
180
|
+
private readonly handoff;
|
|
181
|
+
private readonly dreaming;
|
|
182
|
+
private readonly instructionMaxBytes;
|
|
183
|
+
private readonly deviceConcurrency;
|
|
184
|
+
private readonly timers;
|
|
185
|
+
private readonly coalesce?;
|
|
186
|
+
private readonly offer;
|
|
187
|
+
/** The default principal of the owner APIs: the caller that the Host authenticated as the owner. */
|
|
188
|
+
private readonly owner;
|
|
189
|
+
/** History mode: Turns whose history read failed in this pass. The timer reads them again. */
|
|
190
|
+
private unread;
|
|
191
|
+
private readonly hostIntentHandlers;
|
|
192
|
+
private readonly hostIntentMessageHandlers;
|
|
193
|
+
/** Terminals that could not apply in the current K4 drain, by intent key. K4 also drains from its own timer. */
|
|
194
|
+
private readonly intentFailures;
|
|
195
|
+
/** The last audited reason of each refused key, so a stuck intent adds one audit row and not one per pass. */
|
|
196
|
+
private readonly auditedFailures;
|
|
197
|
+
constructor(server: ExecutionServer & HomeServer & MessageServer & Partial<Pick<ByokServer, 'machines'>>, ledger: HostLedger, options: BotOptions);
|
|
198
|
+
private models;
|
|
199
|
+
/**
|
|
200
|
+
* Replaces the Host's model templates at run time (#1357), for example after a device key changed. Each unarchived Bot takes
|
|
201
|
+
* the template of its model; a Turn frozen before keeps its execution. No profile revision, readiness or persona projection
|
|
202
|
+
* changes. A Bot whose model is missing keeps its Turns blocked until a later call provides it. A template that fails the
|
|
203
|
+
* toolset check, or model names that the outcome schema cannot take, refuse the call and change nothing.
|
|
204
|
+
*/
|
|
205
|
+
setModels(models: Readonly<Record<string, ExecutionTemplate>>): Promise<void>;
|
|
206
|
+
snapshot(): CollaborationState;
|
|
207
|
+
/**
|
|
208
|
+
* Every K8 write of this Host, except the switch steps (#975). It refuses while the domain is exported, after the work,
|
|
209
|
+
* so a new command on a frozen or H-owned device still gets its device refusal (`writeLedger` lists the others).
|
|
210
|
+
*/
|
|
211
|
+
private write;
|
|
212
|
+
private exclusive;
|
|
213
|
+
/**
|
|
214
|
+
* Returns the id of the Turn that answers this input. With `coalesce`, it is the batch id
|
|
215
|
+
* (the first batched input's id); that Turn appears when the batch seals.
|
|
216
|
+
* Only the owner starts a 1:1 execution (R2).
|
|
217
|
+
*/
|
|
218
|
+
input(key: string, request: string, botId?: string, ...by: PrincipalArg): Promise<string>;
|
|
219
|
+
/**
|
|
220
|
+
* Read-only (#1407): the id that `input` returned for this key, from its command record, or `undefined` when the
|
|
221
|
+
* input is not committed. It runs no `process()` and changes no ledger state, so a caller can tell whether an `input`
|
|
222
|
+
* that threw on its drain committed. A record that retention moved is read from its K4 row in a transaction that writes
|
|
223
|
+
* nothing new; once that row expires, the key reads as not committed.
|
|
224
|
+
*/
|
|
225
|
+
inputRoot(key: string, botId?: string): string | undefined;
|
|
226
|
+
/**
|
|
227
|
+
* IM entry (#552). Classify one message that the channel adapter translated (docs/host-im-adapter.md §3).
|
|
228
|
+
* The input key is `inboundKey(message)`. Only audit rows record a refused or 1:1 bot message.
|
|
229
|
+
* `id` is the Turn id of `owner_input`, or the room input id of `room_input` and `bot_background`.
|
|
230
|
+
*/
|
|
231
|
+
receive(message: InboundMessage): Promise<{
|
|
232
|
+
kind: InboundClass;
|
|
233
|
+
id?: string;
|
|
234
|
+
}>;
|
|
235
|
+
/** Owner opt-in for one canonical conversation. Enabling a replacement revokes its old route. */
|
|
236
|
+
enablePushRoute(conversation: Conversation, channel: string, target: string, ...by: PrincipalArg): Promise<string>;
|
|
237
|
+
revokePushRoute(id: string, ...by: PrincipalArg): Promise<void>;
|
|
238
|
+
resendDelivery(id: string, ...by: PrincipalArg): Promise<string>;
|
|
239
|
+
/** Adapter data can be unverified, so one row is at most 1024 characters. */
|
|
240
|
+
private audit;
|
|
241
|
+
/** R2: refuse an unverified principal. The audit row commits before the error. */
|
|
242
|
+
private verifiedOnly;
|
|
243
|
+
/**
|
|
244
|
+
* The mention entities that may open seats (#1230). A bot mentions nothing (R5). In a group whose `memberMentions`
|
|
245
|
+
* setting is `ignore`, a human who is not the owner mentions nothing either: the message stays room background, with
|
|
246
|
+
* no seat, no device work and no BYOK key. The owner's mention still selects seats, and an omitted principal is the
|
|
247
|
+
* Host's own call. The setting is read here, so it applies to this inbound message only, never to an open root or seat.
|
|
248
|
+
*/
|
|
249
|
+
private seatMentions;
|
|
250
|
+
/** R2: only the owner principal acts. An omitted principal is the owner. A given `undefined` is unverified. */
|
|
251
|
+
private ownerOnly;
|
|
252
|
+
private applyOutcome;
|
|
253
|
+
private commitBotOutcome;
|
|
254
|
+
/** The refused terminals of the last K4 drain: one audit row for each new key and reason, and the error of the pass. */
|
|
255
|
+
private reportIntentFailures;
|
|
256
|
+
/**
|
|
257
|
+
* Host intent (#882): the Host's own work in this tenant's K4 FIFO, with Host authority. One transaction enqueues the
|
|
258
|
+
* intent and records its handler name. Its outcome goes to that handler, never to a Bot Turn. An exact replay returns
|
|
259
|
+
* the same intent. On a Bot's agentRef, it shares that Bot's FIFO.
|
|
260
|
+
*/
|
|
261
|
+
enqueueHostIntent(input: IntentInput, handler: string): Promise<Intent>;
|
|
262
|
+
/**
|
|
263
|
+
* Owner API (#1320): cancels a Host intent through K4, which records the cancel on the intent row. A settled intent returns
|
|
264
|
+
* `already_settled` and sends nothing, so a replay does not fail. An unsubmitted intent returns `cancelled` once its cancel
|
|
265
|
+
* commits; `conclusion` is absent if a failed drain or process pass leaves settlement unfinished. A later successful
|
|
266
|
+
* drain settles it without running its handler and advances its FIFO. Replay to read `already_settled` with its conclusion,
|
|
267
|
+
* or `cancel_pending` while a submitted intent awaits its terminal. A submitted intent gets an SDK cancel; a
|
|
268
|
+
* `task.complete` that arrived before the cancel still runs the handler once. A `handler_failed` intent stays stuck,
|
|
269
|
+
* because K4 applies its terminal again: `failStuckIntent` settles it. Refuses a Bot Turn key and an unknown key.
|
|
270
|
+
*
|
|
271
|
+
* After commit, a wake-only failure returns `wakePending: true`. Other failures return `drainError`, the unchanged
|
|
272
|
+
* first drain or process rejection (the whole AggregateError for mixed failures), even if a later pass succeeds.
|
|
273
|
+
* A drain error comes from that same drain, which coalesces with an in-flight drain and may fail on other Host work.
|
|
274
|
+
* Check `'drainError' in result`, report it and retry pending work with `drain()` or recovery. The cancellation
|
|
275
|
+
* committed; reconciliation may be unfinished. Job/outbox retry state is unchanged; explicit drains and wake hooks
|
|
276
|
+
* still reject. Pre-commit failures still reject.
|
|
277
|
+
*/
|
|
278
|
+
cancelHostIntent(key: string, ...by: PrincipalArg): Promise<HostIntentCancelResult>;
|
|
279
|
+
/**
|
|
280
|
+
* Cancel selected Host intents atomically without a pass. A submitted intent refuses the whole set; after a successful
|
|
281
|
+
* call, successors wait for the next pass, or the Host can call `drain()`. Results keep input order and are replayable.
|
|
282
|
+
*/
|
|
283
|
+
cancelHostIntents(keys: readonly string[], ...by: PrincipalArg): Promise<(IntentCancelResult<Conclusion> & {
|
|
284
|
+
result: 'cancelled' | 'already_settled';
|
|
285
|
+
conclusion: Conclusion;
|
|
286
|
+
})[]>;
|
|
287
|
+
/**
|
|
288
|
+
* Owner API (#882): settles as `failed` an open intent whose K4 terminal K8 refuses with `IntentOutcomeError`, so its FIFO
|
|
289
|
+
* moves on. A fresh K4 drain decides that the intent is stuck, so the call also works right after a restart. One transaction
|
|
290
|
+
* settles it and writes the audit row. The settle runs no handler, and the intent records no terminal; the server task
|
|
291
|
+
* keeps it. The drain before the settle applies the terminal once more, so a `handler_failed` handler runs once inside
|
|
292
|
+
* the call. If that drain applies the outcome, the call refuses with `already_settled`. A Bot Turn records the refusal
|
|
293
|
+
* code as its `settleCode`. A Host intent keeps its `hostIntents` record until K4 compacts it, so an exact replay of
|
|
294
|
+
* `enqueueHostIntent` returns the failed intent. Refuses with `HostIntentError`: `unknown_intent`, `already_settled`, and
|
|
295
|
+
* `not_stuck` for an intent whose terminal K8 did not refuse.
|
|
296
|
+
*/
|
|
297
|
+
failStuckIntent(key: string, ...by: PrincipalArg): Promise<void>;
|
|
298
|
+
/** The channel outbox port of a K4 callback. Delivery code reads the committed ledger. */
|
|
299
|
+
private deliverPort;
|
|
300
|
+
/** An owner command in its own ledger transaction. K4 callbacks use `commitCallback` inside the K4 transaction. */
|
|
301
|
+
private commitOwner;
|
|
302
|
+
/** A keyless owner command (#739 6a). Its id is new at each call, because the store keeps no record of it. */
|
|
303
|
+
private commitKeyless;
|
|
304
|
+
private commitCallback;
|
|
305
|
+
/**
|
|
306
|
+
* Install as the server's `agentMessage.consume`. One ledger transaction
|
|
307
|
+
* checks the exact binding and records the first acceptance (§3.3).
|
|
308
|
+
*/
|
|
309
|
+
consumeMessage(input: AgentMessageInput): Promise<{
|
|
310
|
+
outcome: 'accepted' | 'refused';
|
|
311
|
+
reasonCode?: string;
|
|
312
|
+
}>;
|
|
313
|
+
private applyMessage;
|
|
314
|
+
/**
|
|
315
|
+
* Owner API ("Cancel", §8.8), from A's delegation chip or from B's `bot_request` Turn. Idempotent (#1405): an earlier cancel
|
|
316
|
+
* gives `cancel_pending` and a verdict `already_settled`, and neither writes or sends. Refuses with `DelegationError`.
|
|
317
|
+
* It rejects when `core.cancel` fails. The cancel fact is already committed, and the timer delivers it later.
|
|
318
|
+
*/
|
|
319
|
+
cancelDelegation(id: string, ...by: PrincipalArg): Promise<DelegationCancelResult>;
|
|
320
|
+
/** Owner API ("End", §8.3): close a held reply or an uncertain delegation with `abandoned`. */
|
|
321
|
+
abandonDelegation(id: string, ...by: PrincipalArg): Promise<void>;
|
|
322
|
+
/** A committed cancel fact is delivered after the commit. */
|
|
323
|
+
private settleChain;
|
|
324
|
+
/** The slot admission of one device (#1229 item 1): user-source work may take the last slot, other work may not. */
|
|
325
|
+
private admitsDeviceSlot;
|
|
326
|
+
/**
|
|
327
|
+
* Deliver each committed cancel to its frozen target (§8.8). A crash before
|
|
328
|
+
* `delivered` leaves the fact for the next pass. It never picks a new Turn.
|
|
329
|
+
*/
|
|
330
|
+
private deliverCancels;
|
|
331
|
+
/**
|
|
332
|
+
* Host persona mode (#879): the Host applied `revision` of this Bot's profile to its Agent home. The current revision
|
|
333
|
+
* readies the Bot. An older revision changes nothing, and a newer one refuses.
|
|
334
|
+
*/
|
|
335
|
+
personaReady(botId: string, revision: string): Promise<void>;
|
|
336
|
+
/** Owner API. Advance the desired revision after a rejected persona delivery. */
|
|
337
|
+
retryPersona(botId: string): Promise<void>;
|
|
338
|
+
/**
|
|
339
|
+
* External team mode (#739 Q4c): apply the authority's team snapshot. The command id is its team revision,
|
|
340
|
+
* so the same revision with the same Bots replays, and other Bots are an identity conflict. A revision that
|
|
341
|
+
* is not newer, and not applied before, refuses with `stale_team` after the process pass.
|
|
342
|
+
*/
|
|
343
|
+
applyTeam(snapshot: TeamSnapshot): Promise<void>;
|
|
344
|
+
setMainBot(botId: string, mainBot: boolean): Promise<void>;
|
|
345
|
+
/** The resolved autonomy of one Bot (#1229). A Bot without the field is in observe, the default of a new Bot. */
|
|
346
|
+
autonomy(botId: string): Autonomy;
|
|
347
|
+
/** The would-do rows of one Bot, or of every Bot, oldest first (#1229). The Host UI lists these for the owner. */
|
|
348
|
+
wouldDoRecords(botId?: string): WouldDo[];
|
|
349
|
+
/**
|
|
350
|
+
* The destination of every recorded inbound human message (#1229 item 3), oldest first. It is a projection of the
|
|
351
|
+
* inbound, batch and Turn rows: the ledger holds no second disposition.
|
|
352
|
+
*/
|
|
353
|
+
inboundDispositions(): InboundDisposition[];
|
|
354
|
+
/**
|
|
355
|
+
* Owner API (#1229): switch one Bot between observe and auto. Only the owner principal may switch. It applies to
|
|
356
|
+
* outcomes recorded after the switch; a record made in observe is never replayed.
|
|
357
|
+
*/
|
|
358
|
+
setBotAutonomy(botId: string, autonomy: Autonomy, ...by: PrincipalArg): Promise<void>;
|
|
359
|
+
/** Any verified human can post in a room. The room message records the principal id; without one it is from `user`. */
|
|
360
|
+
roomInput(key: string, roomId: string, text: string, mentions?: Mentions, ...by: PrincipalArg): Promise<string>;
|
|
361
|
+
/**
|
|
362
|
+
* Owner API (#1230): whether a structured mention from a non-owner human in this group opens seats. Only the owner
|
|
363
|
+
* changes it, and only inbound messages that arrive after it see the new value.
|
|
364
|
+
*/
|
|
365
|
+
setMemberMentions(roomId: string, value: MemberMentions, ...by: PrincipalArg): Promise<void>;
|
|
366
|
+
/**
|
|
367
|
+
* Owner API (#1321): create room `roomId` with no model run. The command id comes from the room id, so the same id with
|
|
368
|
+
* the same fields replays, and other fields are an identity conflict.
|
|
369
|
+
*/
|
|
370
|
+
createRoom(roomId: string, fields: RoomFields): Promise<void>;
|
|
371
|
+
updateRoom(roomId: string, update: Partial<RoomFields>): Promise<void>;
|
|
372
|
+
answer(id: string, answer: string, ...by: PrincipalArg): Promise<void>;
|
|
373
|
+
/** For IM, call it only from a verified button callback, never for a text command (R2). */
|
|
374
|
+
decide(id: string, decision: 'confirmed' | 'rejected', ...by: PrincipalArg): Promise<void>;
|
|
375
|
+
/** Owner API for the Main Bot's own routines. */
|
|
376
|
+
setRoutineLifecycle(id: string, value: Routine['lifecycle']): Promise<void>;
|
|
377
|
+
/** Owner API (§55c): completes any open Bot routine, an archived owner's too, with this Host's Main Bot authority. */
|
|
378
|
+
endRoutine(id: string): Promise<void>;
|
|
379
|
+
updateRoutine(action: UpdateRoutineAction): Promise<void>;
|
|
380
|
+
private routineRows;
|
|
381
|
+
/** K4 records routine wakes. The `bot-routine` hook writes the routine Turn in the same commit. */
|
|
382
|
+
readonly consume: (wake: DueWake, signal: AbortSignal) => Promise<void>;
|
|
383
|
+
drain(): Promise<void>;
|
|
384
|
+
/**
|
|
385
|
+
* Owner API. Cancels a Turn, an input batch by its id or a member input id, or B's chain Turn through its delegation.
|
|
386
|
+
* Idempotent (#1405): a Turn whose K4 intent already has a cancel gives `cancel_pending`, and an ended Turn
|
|
387
|
+
* `already_settled`; neither writes or calls `core.cancel`.
|
|
388
|
+
* After commit, a wake-only failure returns `wakePending: true`. Other failures return `drainError`, the unchanged
|
|
389
|
+
* first drain rejection (the whole AggregateError for mixed failures), even if a later pass retries it successfully.
|
|
390
|
+
* Its presence means cancellation committed, not that reconciliation finished. Inspect/report it and retry pending
|
|
391
|
+
* work with `drain()` or recovery, rather than repeating the cancellation. Job/outbox retry state is unchanged;
|
|
392
|
+
* explicit drains and wake hooks still reject. Pre-commit failures still reject.
|
|
393
|
+
*/
|
|
394
|
+
cancelTurn(id: string, ...by: PrincipalArg): Promise<TurnCancelResult & {
|
|
395
|
+
wakePending?: true;
|
|
396
|
+
drainError?: unknown;
|
|
397
|
+
}>;
|
|
398
|
+
private cancelOneTurn;
|
|
399
|
+
/** The L owner record of a device (#957, §4.1). A device with no record is L at revision 0. */
|
|
400
|
+
topology(deviceId: string): DeviceTopology;
|
|
401
|
+
/**
|
|
402
|
+
* Step 1 of a switch away from L (#957, §4.1): durably freezes new work on the device and returns the record read back
|
|
403
|
+
* from the ledger. From the commit on, each entry that can create execution for the device refuses with
|
|
404
|
+
* `DeviceSwitchingError`, and the sync holds the device's Turns. Raises the revision.
|
|
405
|
+
*/
|
|
406
|
+
freezeForSwitch(deviceId: string, expectedRevision: number): Promise<DeviceTopology>;
|
|
407
|
+
/**
|
|
408
|
+
* Step 2: the device's open work. With `cancel`, cancels every open intent and every open Turn and input batch, then runs a
|
|
409
|
+
* pass. Returns the work still open: a tried intent stays open until the reconciler reads its terminal. Waits for nothing.
|
|
410
|
+
*/
|
|
411
|
+
drainForSwitch(deviceId: string, { cancel }?: {
|
|
412
|
+
cancel?: boolean;
|
|
413
|
+
}): Promise<SwitchWork>;
|
|
414
|
+
/**
|
|
415
|
+
* Step 3 (#975): seals the domain's whole state into a switch export, after each of its devices is frozen at the given
|
|
416
|
+
* revision and drained. The export must name every device of a live Bot. From the export on, this Host writes nothing to
|
|
417
|
+
* the ledger, also after a restart, so the commit away can check that the ledger still holds what was exported. Refuses
|
|
418
|
+
* Agent memory, a pending projection (flush them first), and a pending Host job, which K4 would run while the export
|
|
419
|
+
* waits for its commit.
|
|
420
|
+
*/
|
|
421
|
+
exportForSwitch(devices: {
|
|
422
|
+
deviceId: string;
|
|
423
|
+
expectedRevision: number;
|
|
424
|
+
}[], exportedAt?: number): Promise<SwitchExport>;
|
|
425
|
+
/**
|
|
426
|
+
* Step 5, after the new owner imported and verified the export: L records that the new owner owns the whole domain. Every
|
|
427
|
+
* device of the export moves to H in one transaction, on its frozen revision, only when none has open work and `receipt`
|
|
428
|
+
* is the digest of this Host's export. The ledger is sealed again under the export's header and must give the same
|
|
429
|
+
* digest. `deviceId` and `expectedRevision` name one device of the export, whose record is returned. Every entry then
|
|
430
|
+
* refuses those devices with `DeviceModeError`, also after a restart. The export stays, so this Host keeps writing nothing.
|
|
431
|
+
*/
|
|
432
|
+
commitSwitch(deviceId: string, expectedRevision: number, receipt: string): Promise<DeviceTopology>;
|
|
433
|
+
/**
|
|
434
|
+
* A failed export or check: clears the freeze on the frozen revision, so L owns the device again and held Turns run. An
|
|
435
|
+
* abort of a device of the export ends the export, and the new owner discards its import. After the commit every device
|
|
436
|
+
* of the export is owned by H, so none aborts.
|
|
437
|
+
* After commit, a wake-only failure returns `wakePending: true`. Other failures return `drainError`, the unchanged
|
|
438
|
+
* process rejection (the whole AggregateError for mixed failures). Its presence means the abort committed, not that
|
|
439
|
+
* reconciliation finished. Inspect/report it and retry pending work with `drain()` or recovery, rather than repeating
|
|
440
|
+
* the abort with its now-stale revision. Job/outbox retry state is unchanged; explicit drains and wake hooks still
|
|
441
|
+
* reject. A failure may concern other work or already be retried before return. Pre-commit failures still reject.
|
|
442
|
+
*/
|
|
443
|
+
abortSwitch(deviceId: string, expectedRevision: number): Promise<DeviceTopology & {
|
|
444
|
+
wakePending?: true;
|
|
445
|
+
drainError?: unknown;
|
|
446
|
+
}>;
|
|
447
|
+
/**
|
|
448
|
+
* Explicit retention (#798). Moves every row of each acknowledged settled root out of the state, and retires its ids.
|
|
449
|
+
* A root that is still in use throws `RetentionRefused`, and nothing changes. Never runs on its own.
|
|
450
|
+
*/
|
|
451
|
+
retain(input: RetentionInput): Promise<RetentionResult>;
|
|
452
|
+
recover(): Promise<void>;
|
|
453
|
+
private sync;
|
|
454
|
+
/** Example reconcile loop (§3.10). K4 arms no scan after a settled intent, so the Host checks replies itself. */
|
|
455
|
+
private flushReplies;
|
|
456
|
+
private callConnector;
|
|
457
|
+
private flushCards;
|
|
458
|
+
private flushDeliveries;
|
|
459
|
+
/** One sync transaction. In history mode, phase 1 reads the history first, outside the transaction. */
|
|
460
|
+
private syncWithHistory;
|
|
461
|
+
private readHistory;
|
|
462
|
+
/** A failed pass still re-arms the timer, so other timer work keeps its times. K4 retries a failed wake call itself. */
|
|
463
|
+
private process;
|
|
464
|
+
/**
|
|
465
|
+
* A failed K4 drain does not stop the rest of the pass, so deliveries and reply checks still move their due times.
|
|
466
|
+
* The pass does not repeat after it, and it rethrows the first drain error for the caller and the SDK hook.
|
|
467
|
+
*/
|
|
468
|
+
private pass;
|
|
469
|
+
private armTimer;
|
|
470
|
+
private refreshDevices;
|
|
471
|
+
close(): Promise<void>;
|
|
472
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type CollaborationState } from './model.js';
|
|
2
|
+
import type { Json } from './rules/turn.js';
|
|
3
|
+
import { type InboundDisposition, type InboundState } from './rules/inbound.js';
|
|
4
|
+
/** The rows that the pure rule reads. A round with no seat Turn is still the round root that answers its input. */
|
|
5
|
+
export declare function inboundState(state: CollaborationState): InboundState;
|
|
6
|
+
/** The Host UI read (#1229): every recorded inbound human message and its current destination, oldest first. */
|
|
7
|
+
export declare function inboundDispositionsOf(state: CollaborationState): InboundDisposition[];
|
|
8
|
+
/**
|
|
9
|
+
* One projection id per destination transition. The id names the destination, so a projection value never changes and
|
|
10
|
+
* the K4 outbox can hold every transition without an identity conflict.
|
|
11
|
+
*/
|
|
12
|
+
export declare function inboundProjection(disposition: InboundDisposition): {
|
|
13
|
+
id: string;
|
|
14
|
+
value: Json;
|
|
15
|
+
};
|
|
16
|
+
/** Publishes the current destination of each message. `project` is idempotent for an unchanged destination. */
|
|
17
|
+
export declare function projectInboundDispositions(state: CollaborationState, emit: (id: string, value: Json) => void): void;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { inspectLedger } from './store-compatibility.js';
|
|
2
|
+
export { BotCollaboration } from './host.js';
|
|
3
|
+
export { botCompactVeto } from './compaction.js';
|
|
4
|
+
export type { AgentMessageInput, BotOptions, HostIntentCancelResult, HostIntentHandler, HostIntentMessageHandler, MessageServer } from './host.js';
|
|
5
|
+
export { TEAM_ROOM_LIMIT, TeamModeError, teamSnapshot, type TeamModeCode, type TeamSnapshot, type TeamSnapshotBot, type TeamSnapshotRoom } from './rules/team.js';
|
|
6
|
+
export { createBotPersonaProjection } from './persona.js';
|