@agentshouse/mdruntime-families 0.1.0-c8ac97acea69a → 0.1.0-c8d38a26efb97

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.
Files changed (58) hide show
  1. package/dist/mdruntime/actions.d.ts +19 -0
  2. package/dist/mdruntime/adapter.d.ts +16 -16
  3. package/dist/mdruntime/attached-model.d.ts +7 -0
  4. package/dist/mdruntime/bootstrap.d.ts +43 -0
  5. package/dist/mdruntime/cell.d.ts +5 -0
  6. package/dist/mdruntime/change.d.ts +1 -0
  7. package/dist/mdruntime/client.d.ts +12 -1
  8. package/dist/mdruntime/compile.d.ts +5 -0
  9. package/dist/mdruntime/conversation-row.d.ts +32 -0
  10. package/dist/mdruntime/conversation.d.ts +14 -5
  11. package/dist/mdruntime/durability.d.ts +9 -0
  12. package/dist/mdruntime/figures.d.ts +47 -0
  13. package/dist/mdruntime/holdings.d.ts +28 -0
  14. package/dist/mdruntime/install.d.ts +55 -0
  15. package/dist/mdruntime/job.d.ts +32 -0
  16. package/dist/mdruntime/listing.d.ts +52 -0
  17. package/dist/mdruntime/live.d.ts +22 -0
  18. package/dist/mdruntime/log.d.ts +5 -0
  19. package/dist/mdruntime/messages.d.ts +25 -1
  20. package/dist/mdruntime/model.d.ts +0 -2
  21. package/dist/mdruntime/outcome.d.ts +1 -0
  22. package/dist/mdruntime/overlay.d.ts +1 -0
  23. package/dist/mdruntime/preparation.d.ts +19 -0
  24. package/dist/mdruntime/query.d.ts +10 -0
  25. package/dist/mdruntime/reach.d.ts +8 -6
  26. package/dist/mdruntime/reads.d.ts +35 -0
  27. package/dist/mdruntime/refresh.d.ts +26 -0
  28. package/dist/mdruntime/replica.d.ts +0 -3
  29. package/dist/mdruntime/room-drafts.d.ts +23 -0
  30. package/dist/mdruntime/runtime.d.ts +41 -0
  31. package/dist/mdruntime/saves.d.ts +69 -0
  32. package/dist/mdruntime/seed.d.ts +11 -2
  33. package/dist/mdruntime/socket/admission.d.ts +6 -0
  34. package/dist/mdruntime/socket/answers.d.ts +5 -0
  35. package/dist/mdruntime/socket/lanes.d.ts +19 -0
  36. package/dist/mdruntime/socket/rooms.d.ts +42 -0
  37. package/dist/mdruntime/socket/session.d.ts +38 -0
  38. package/dist/mdruntime/socket.d.ts +69 -0
  39. package/dist/mdruntime/source.d.ts +60 -0
  40. package/dist/mdruntime/status.d.ts +0 -2
  41. package/dist/mdruntime/store/fences.d.ts +15 -0
  42. package/dist/mdruntime/store/installs.d.ts +29 -0
  43. package/dist/mdruntime/store/readiness.d.ts +9 -0
  44. package/dist/mdruntime/store/records.d.ts +211 -0
  45. package/dist/mdruntime/store/room-held.d.ts +7 -0
  46. package/dist/mdruntime/store/space.d.ts +10 -0
  47. package/dist/mdruntime/store/watchers.d.ts +16 -0
  48. package/dist/mdruntime/store/writes.d.ts +23 -0
  49. package/dist/mdruntime/store.d.ts +107 -142
  50. package/dist/mdruntime/stored.d.ts +55 -28
  51. package/dist/mdruntime/surface.d.ts +87 -0
  52. package/dist/mdruntime/tables.d.ts +108 -20
  53. package/dist/mdruntime/tallies.d.ts +17 -0
  54. package/dist/mdruntime/transfer.d.ts +4 -0
  55. package/dist/mdruntime/turn.d.ts +8 -0
  56. package/dist/mdruntime/wire.d.ts +8 -1
  57. package/package.json +2 -2
  58. package/dist/mdruntime/connection.d.ts +0 -154
@@ -0,0 +1,19 @@
1
+ import type { ConversationHistoryRequest } from './adapter.js';
2
+ import { type CallResult, type HistoryAnswer, type Resolution } from './outcome.js';
3
+ import type { Attempted } from './recovery.js';
4
+ import type { Runtime } from './runtime.js';
5
+ export type HistoryQuery = {
6
+ revision?: string;
7
+ pageToken?: string;
8
+ };
9
+ export declare function readHistory(runtime: Runtime, locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
10
+ export declare function located(runtime: Runtime, room: string, path: string, destination: string): Promise<{
11
+ room: string;
12
+ path: string;
13
+ } | null>;
14
+ export declare function resolveReference(runtime: Runtime, room: string, path: string, destination: string): Promise<Resolution>;
15
+ export declare function invokeAction(runtime: Runtime, name: string, input: unknown, dispatching?: () => Promise<void>): Promise<CallResult>;
16
+ export declare function readConversationHistory(runtime: Runtime, request: ConversationHistoryRequest): Promise<CallResult>;
17
+ export declare function called(runtime: Runtime, name: string, input: unknown): Promise<CallResult>;
18
+ export declare function resendCalls(runtime: Runtime, signal: AbortSignal): Promise<Attempted>;
19
+ export declare function resendLater(runtime: Runtime): void;
@@ -13,7 +13,7 @@ export type TypedSelection = {
13
13
  };
14
14
  export type OperationScopes = {
15
15
  write: readonly string[];
16
- delete: readonly string[];
16
+ erase: readonly string[];
17
17
  };
18
18
  export type ReplicaAdmission = {
19
19
  selection: string;
@@ -285,25 +285,17 @@ export type BinaryFile = {
285
285
  mediaType: string;
286
286
  sha256: string;
287
287
  };
288
- export type HeldFile = {
289
- readonly path: string;
290
- readonly revision: string;
291
- };
292
- export type HeldContent = {
293
- files(after: string | null, limit: number): Promise<readonly HeldFile[]>;
294
- contents(paths: readonly string[]): Promise<ReadonlyMap<string, {
295
- readonly content: string;
296
- readonly revision: string;
297
- }>>;
298
- };
299
288
  export type BootstrapRequest = {
300
289
  locator: string;
301
290
  selection: string;
302
291
  pageToken?: PageToken;
303
- held?: HeldContent;
304
292
  arriving?: (bytes: number) => void;
305
293
  signal?: AbortSignal;
306
294
  };
295
+ export type BootstrapPart = {
296
+ readonly id: string;
297
+ readonly bytes: number;
298
+ };
307
299
  export type BootstrapInventory = {
308
300
  readonly bytes: number;
309
301
  };
@@ -318,15 +310,20 @@ export type BootstrapPage = {
318
310
  facts: Readonly<Record<string, SavedFacts>>;
319
311
  revisions: Readonly<Record<string, string>>;
320
312
  fileIds?: Readonly<Record<string, string>>;
313
+ created?: Readonly<Record<string, string>>;
321
314
  changes: Readonly<Record<string, HeadChange>>;
322
315
  binaryFiles: Readonly<Record<string, BinaryFile>>;
323
316
  folders?: readonly string[];
324
317
  pageToken?: PageToken;
318
+ parts?: readonly BootstrapPart[];
325
319
  bytes?: number;
326
320
  };
321
+ export type NotReady = {
322
+ kind: 'not-ready';
323
+ };
327
324
  export type BootstrapResult = BootstrapPage | {
328
325
  kind: 'beyond-horizon';
329
- } | AdapterFailure;
326
+ } | NotReady | AdapterFailure;
330
327
  export type RefreshRequest = {
331
328
  locator: string;
332
329
  selection: string;
@@ -341,6 +338,7 @@ export type RefreshPage = {
341
338
  facts: Readonly<Record<string, SavedFacts>>;
342
339
  revisions: Readonly<Record<string, string>>;
343
340
  fileIds?: Readonly<Record<string, string>>;
341
+ created?: Readonly<Record<string, string>>;
344
342
  changes: Readonly<Record<string, HeadChange>>;
345
343
  binaryFiles: Readonly<Record<string, BinaryFile>>;
346
344
  removals: readonly string[];
@@ -489,12 +487,12 @@ export type SearchAnswer = {
489
487
  }) | AdapterFailure;
490
488
  export type HeldRoom = {
491
489
  locator: string;
492
- roomVersion: string;
490
+ roomVersion: string | null;
493
491
  };
494
492
  export type RoomChange = {
495
493
  kind: 'room-change';
496
494
  locator: string;
497
- from: string;
495
+ from: string | null;
498
496
  roomVersion: string;
499
497
  read(): Promise<RefreshPage>;
500
498
  };
@@ -527,6 +525,8 @@ export type Adapter = {
527
525
  readonly roomTypes?: string;
528
526
  readonly nameableRoomTypes?: readonly string[];
529
527
  readonly typedPaths?: readonly TypedPath[];
528
+ readonly unkeptReads?: readonly string[];
529
+ readonly leadingReads?: readonly string[];
530
530
  authorize(): Promise<Authorization>;
531
531
  discover?(authorization: Authorization): Promise<DiscoverResult>;
532
532
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
@@ -0,0 +1,7 @@
1
+ import { type VerifiedModel } from '@agentshouse/mdmodel';
2
+ import type { ModelResult, ModelState } from './model.js';
3
+ export declare const NO_ROOM_TYPES: VerifiedModel;
4
+ export declare function roomTypesOf(schema: string | undefined, nameable?: readonly string[]): VerifiedModel;
5
+ export declare function builtInModel(roomTypes: VerifiedModel): ModelState;
6
+ export declare function schemaTypes(schema: string | null, roomTypes: VerifiedModel): VerifiedModel['types'];
7
+ export declare function attachedModel(answer: ModelResult, roomTypes: VerifiedModel): ModelState;
@@ -0,0 +1,43 @@
1
+ import type { ModelState } from './model.js';
2
+ import type { Adapter, TypedPath, AdapterFailure, Authorization, BootstrapPart, DiscoveredRoom, NotReady, RetryableRefusal, RoomModels } from './adapter.js';
3
+ import type { Composition } from './collection.js';
4
+ import type { InstallationStep } from './readiness.js';
5
+ import { type Refreshing } from './refresh.js';
6
+ import type { ReplicaRecord } from './replica.js';
7
+ import type { StagedPage, TransferRecord } from './store.js';
8
+ import { type Unconfirmed } from './transfer.js';
9
+ export type Bootstrapped = {
10
+ kind: 'staged';
11
+ record: ReplicaRecord;
12
+ refreshed: boolean;
13
+ };
14
+ export type BootstrapOutcome = Bootstrapped | Unconfirmed | NotReady | RetryableRefusal | AdapterFailure;
15
+ export type HeldModels = {
16
+ collection: ModelState;
17
+ };
18
+ export type Remodel = (models: RoomModels | undefined, held: HeldModels) => HeldModels;
19
+ export type Reads = Pick<Adapter, 'bootstrap' | 'refresh' | 'reached'>;
20
+ export type Arriving = {
21
+ at(bytes: number): void;
22
+ end(): void;
23
+ };
24
+ export type Resumed = {
25
+ readonly record: TransferRecord | null;
26
+ readonly staged: ReadonlySet<string>;
27
+ };
28
+ export type Staging = {
29
+ held(locator: string): TransferRecord | null;
30
+ turn(locator: string, step: InstallationStep): Promise<() => void>;
31
+ unqueued(): Promise<void>;
32
+ queued(text: number): () => void;
33
+ arriving(locator: string): Arriving;
34
+ readonly streamed: boolean;
35
+ stage(record: TransferRecord, page: StagedPage, composition: Composition): Promise<TransferRecord | null>;
36
+ resume(record: TransferRecord, parts: readonly BootstrapPart[], composition: Composition): Promise<Resumed | null>;
37
+ derive(locator: string, key: number, composition: Composition): Promise<boolean>;
38
+ refreshing(locator: string, key: number, composition: Composition): Promise<Refreshing>;
39
+ abandon(locator: string): Promise<void>;
40
+ setAside(locator: string): Promise<void>;
41
+ release(key: number): Promise<void>;
42
+ };
43
+ export declare function bootstrapRoom(adapter: Reads, authorization: Authorization, room: DiscoveredRoom, held: HeldModels, builtIn: ModelState, typedPaths: readonly TypedPath[], remodel: Remodel, continuing: () => boolean, staging: Staging): Promise<BootstrapOutcome>;
@@ -0,0 +1,5 @@
1
+ export type Cell<T> = {
2
+ now(): T;
3
+ set(change: Partial<T>): void;
4
+ };
5
+ export declare function createCell<T extends object>(first: T): Cell<T>;
@@ -50,6 +50,7 @@ type Arriving = {
50
50
  readonly path: string;
51
51
  readonly revision?: string;
52
52
  readonly fileId?: string;
53
+ readonly created?: string;
53
54
  readonly change?: HeadChange;
54
55
  };
55
56
  export type RoomMove = {
@@ -1,14 +1,21 @@
1
1
  import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
2
- import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult } from './connection.js';
2
+ import type { HistoryQuery } from './actions.js';
3
+ import type { AppRoom } from './listing.js';
4
+ import type { ConnectionRefusal } from './socket.js';
5
+ import type { RoomSchemas } from './surface.js';
6
+ import type { SavedParts, SavedRoomDraft, SaveResult } from './saves.js';
3
7
  import type { Member, ServiceMode } from './adapter.js';
4
8
  import type { UnsentWork } from './durability.js';
5
9
  import type { ChatDraft, ConversationAgent, ConversationAnswer, ConversationEntry, ConversationOptions, ConversationRead, ConversationView } from './conversation.js';
6
10
  import { type Observation } from './observation.js';
7
11
  import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
12
+ import type { FiguresResult } from './figures.js';
13
+ import type { Holdings } from './holdings.js';
8
14
  import type { DocumentResult, GroupResult, PendingResult } from './query.js';
9
15
  import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
10
16
  import type { SearchRequest, SearchResult } from './search.js';
11
17
  import type { Readiness } from './readiness.js';
18
+ import type { ObservedRead } from './reads.js';
12
19
  import type { SyncStatus } from './status.js';
13
20
  import { type RuntimePort } from './wire.js';
14
21
  export type MdRuntimeClient = {
@@ -62,6 +69,7 @@ export type MdRuntimeClient = {
62
69
  cleanUp(): Promise<number>;
63
70
  unsent(): Promise<readonly UnsentWork[]>;
64
71
  reset(): Promise<void>;
72
+ readAgain(): Promise<void>;
65
73
  observe: {
66
74
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
67
75
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
@@ -80,6 +88,9 @@ export type MdRuntimeClient = {
80
88
  (topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
81
89
  (topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
82
90
  (topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
91
+ (topic: 'figures'): Promise<Observation<FiguresResult>>;
92
+ (topic: 'holdings'): Promise<Observation<Holdings>>;
93
+ (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
83
94
  };
84
95
  reauthorize(): Promise<void>;
85
96
  settled(): Promise<void>;
@@ -1,10 +1,15 @@
1
+ import { sql } from '@agentshouse/mdmodel';
1
2
  import type { Plan, QueryRows } from './query.js';
2
3
  import type { Connection } from './tables.js';
3
4
  export type QueryRoom = {
4
5
  readonly locator: string;
5
6
  readonly key: number;
6
7
  };
8
+ type Fragment = sql.Fragment;
9
+ export declare const VISIBLE: (alias: string) => string;
10
+ export declare function within(alias: string, path: string): Fragment;
7
11
  export type QueryAnswer = QueryRows & {
8
12
  readonly more?: string;
9
13
  };
10
14
  export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
15
+ export {};
@@ -0,0 +1,32 @@
1
+ import type { HeldRow } from './messages.js';
2
+ import { type HouseSource } from './source.js';
3
+ export type ConversationLast = {
4
+ readonly text: string;
5
+ readonly by: 'owner' | 'agent' | 'house';
6
+ readonly at: string;
7
+ };
8
+ export type ConversationStart = Extract<HouseSource, {
9
+ readonly kind: 'request' | 'trigger';
10
+ }>;
11
+ export type ConversationAsk = {
12
+ readonly who: string;
13
+ readonly agent: string | null;
14
+ readonly room: {
15
+ readonly ref: string;
16
+ readonly name: string;
17
+ };
18
+ readonly prompt: string;
19
+ readonly at: string;
20
+ readonly request: string;
21
+ readonly message?: string;
22
+ };
23
+ export type ConversationHeld = {
24
+ readonly last: ConversationLast | null;
25
+ readonly failure: string | null;
26
+ readonly startedBy: ConversationStart | null;
27
+ readonly asks: ConversationAsk | null;
28
+ };
29
+ export declare function heldFacts(held: HeldRow | undefined, listed: {
30
+ readonly outcome: string | null;
31
+ readonly waiting: boolean;
32
+ }): ConversationHeld;
@@ -1,15 +1,18 @@
1
- import type { ConversationAction, ConversationEvent, ConversationHistoryRequest, ConversationMessage, ConversationStream, ListedConversation, ProcessCommand, RunningSubagent, SessionOption, TurnContext } from './adapter.js';
1
+ import type { ConversationAction, ConversationEvent, ConversationHistoryRequest, ConversationMessage, ConversationStream, ProcessCommand, RunningSubagent, SessionOption, TurnContext } from './adapter.js';
2
2
  import { type ChangeSet } from './change-set.js';
3
+ import { type ConversationHeld } from './conversation-row.js';
4
+ import type { OpenJob } from './job.js';
3
5
  import type { Open } from './open.js';
4
6
  import { type CallResult, type Offline } from './outcome.js';
5
7
  import type { CycleProgress } from './status.js';
6
- import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
8
+ import type { RuntimeStore } from './store.js';
7
9
  export type ConversationState = Open<'working' | 'asking' | 'idle'>;
8
- export type ConversationEntry = {
10
+ export type ConversationEntry = ConversationHeld & {
9
11
  conversation: string;
10
12
  agent: {
11
13
  identity: string;
12
14
  name: string;
15
+ retired: boolean;
13
16
  };
14
17
  name: string;
15
18
  created: string;
@@ -18,6 +21,8 @@ export type ConversationEntry = {
18
21
  waiting: boolean;
19
22
  state: ConversationState;
20
23
  started: string | null;
24
+ line: string | null;
25
+ question: string | null;
21
26
  };
22
27
  export type ConversationAgent = {
23
28
  identity: string;
@@ -62,6 +67,7 @@ export type ConversationView = {
62
67
  chatDraft: (ChatDraft & {
63
68
  readonly revision: string;
64
69
  }) | null;
70
+ jobs: readonly OpenJob[];
65
71
  };
66
72
  export type ConversationSurface = {
67
73
  list(): Promise<readonly ConversationEntry[]>;
@@ -86,6 +92,9 @@ export type ConversationDependencies = {
86
92
  call(name: ConversationAction, input: unknown): Promise<CallResult>;
87
93
  history(request: ConversationHistoryRequest): Promise<CallResult>;
88
94
  durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
95
+ local(): Promise<RuntimeStore>;
96
+ again(): void;
97
+ settled(): void;
89
98
  stream(): ConversationStream | undefined;
90
99
  publish(set: ChangeSet): void;
91
100
  online(): boolean;
@@ -96,7 +105,7 @@ export type ConversationDependencies = {
96
105
  export type ConversationStore = {
97
106
  surface: ConversationSurface;
98
107
  chatDraft: ChatDraftSurface;
99
- hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[], list: readonly ListedConversation[] | null, cursor: string | null): void;
108
+ opened(local: RuntimeStore): Promise<void>;
100
109
  reconcile(): Promise<void>;
101
110
  catchUp(progress: CycleProgress): Promise<void>;
102
111
  resend(progress: CycleProgress): Promise<void>;
@@ -109,7 +118,7 @@ export type ConversationStore = {
109
118
  watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
110
119
  watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
111
120
  changed(set: ChangeSet): void;
112
- receive(event: ConversationEvent): boolean;
121
+ receive(event: ConversationEvent): void;
113
122
  close(): void;
114
123
  };
115
124
  export declare function unheldView(conversation: string): ConversationView;
@@ -4,12 +4,21 @@ export type UnsentWork = {
4
4
  readonly kind: UnsentKind;
5
5
  readonly count: number;
6
6
  };
7
+ export type AppCode = {
8
+ readonly running: number;
9
+ readonly older: number;
10
+ };
11
+ export type HeldCode = {
12
+ readonly house: number | null;
13
+ readonly apps: readonly string[];
14
+ };
7
15
  export type RuntimeShell = {
8
16
  persistence: Persistence;
9
17
  generation: string | null;
10
18
  keepGeneration(value: string): void | Promise<void>;
11
19
  dropGeneration(): void | Promise<void>;
12
20
  cleanUp?(): Promise<number>;
21
+ measure?(measured: (app: string, code: AppCode | null) => void): Promise<HeldCode>;
13
22
  reset(): Promise<void>;
14
23
  };
15
24
  export declare function refusedForSpace(error: unknown): boolean;
@@ -0,0 +1,47 @@
1
+ import type { ChangeSet } from './change-set.js';
2
+ import type { GroupTotal, PendingResult } from './query.js';
3
+ import type { Deliver, Fail } from './reach.js';
4
+ import type { ConversationTally, RoomTally } from './tallies.js';
5
+ import type { QueryRoom } from './tables.js';
6
+ export declare const HOUSE_DIRECTORY = "house";
7
+ export declare const ROOM_TOTALS: {
8
+ readonly outside: readonly ["house"];
9
+ readonly groupBy: readonly ["room"];
10
+ readonly select: {
11
+ readonly size: true;
12
+ };
13
+ };
14
+ export type DayFigures = {
15
+ readonly created: number;
16
+ readonly changed: number;
17
+ readonly chats: number;
18
+ readonly messages: number;
19
+ };
20
+ export type RoomFigures = {
21
+ readonly room: string;
22
+ readonly day: DayFigures;
23
+ readonly total: {
24
+ readonly documents: GroupTotal;
25
+ readonly files: GroupTotal;
26
+ };
27
+ };
28
+ export type Figures = {
29
+ readonly rooms: readonly RoomFigures[];
30
+ readonly agentMessages: number;
31
+ };
32
+ export type FiguresResult = Figures | PendingResult;
33
+ export type FiguresCover = PendingResult | {
34
+ readonly rooms: readonly QueryRoom[];
35
+ };
36
+ export type FiguresSources = {
37
+ cover(): Promise<FiguresCover>;
38
+ rooms(rooms: readonly QueryRoom[], since: string): Promise<readonly RoomTally[]>;
39
+ conversations(conversations: readonly string[] | null, since: string): Promise<readonly ConversationTally[]>;
40
+ };
41
+ export type FiguresRead = {
42
+ watch(deliver: Deliver, fail: Fail): () => void;
43
+ touched(set: ChangeSet): void;
44
+ recover(): void;
45
+ close(): void;
46
+ };
47
+ export declare function createFigures(sources: FiguresSources): FiguresRead;
@@ -0,0 +1,28 @@
1
+ import type { AppCode } from './durability.js';
2
+ import type { GroupTotal, PendingResult } from './query.js';
3
+ import type { Deliver, Fail } from './reach.js';
4
+ import type { Runtime } from './runtime.js';
5
+ import type { OpenedRoom } from './tables.js';
6
+ export type RoomDocuments = {
7
+ readonly room: string;
8
+ readonly documents: GroupTotal;
9
+ };
10
+ export type HeldApp = ({
11
+ readonly app: string;
12
+ readonly state: 'measured';
13
+ } & AppCode) | {
14
+ readonly app: string;
15
+ readonly state: 'asking' | 'unknown';
16
+ };
17
+ export type Holdings = {
18
+ readonly rooms: readonly RoomDocuments[] | PendingResult;
19
+ readonly opened: GroupTotal & {
20
+ readonly rooms: readonly OpenedRoom[];
21
+ };
22
+ readonly apps: readonly HeldApp[];
23
+ readonly house: number | null;
24
+ readonly total: number | null;
25
+ readonly cleanUp: number | null;
26
+ };
27
+ export declare const CLEANED_TOPIC = "cleaned";
28
+ export declare function watchHoldings({ store, figures, shell }: Runtime, deliver: Deliver, fail: Fail): () => void;
@@ -0,0 +1,55 @@
1
+ import type { AdapterFailure, Authorization, DiscoveredRoom, NotReady, RetryableRefusal } from './adapter.js';
2
+ import { type Reads } from './bootstrap.js';
3
+ import type { Installation, RoomCoverage } from './readiness.js';
4
+ import { advancement, type Refresher } from './refresh.js';
5
+ import type { ReplicaRecord } from './replica.js';
6
+ import type { Runtime } from './runtime.js';
7
+ import type { Live } from './socket.js';
8
+ import { type CoveredRoom, type InstallHold, type RuntimeStore, type Store } from './store.js';
9
+ import { type Unconfirmed } from './transfer.js';
10
+ type Standing = {
11
+ readonly key: number | null;
12
+ readonly confirmed: number;
13
+ };
14
+ export type Unheld = {
15
+ readonly staged: boolean;
16
+ };
17
+ export type Withheld = AdapterFailure | RetryableRefusal | NotReady | Unconfirmed;
18
+ type Landing = {
19
+ readonly kind: 'refreshed';
20
+ readonly from: Standing;
21
+ readonly remodelled: boolean;
22
+ } | {
23
+ readonly kind: 'bootstrapped';
24
+ readonly refreshed: boolean;
25
+ readonly from: Standing;
26
+ };
27
+ type Refreshed = {
28
+ kind: 'advanced';
29
+ record: ReplicaRecord;
30
+ from: Standing;
31
+ remodelled: boolean;
32
+ } | Exclude<Awaited<ReturnType<typeof advancement>>, {
33
+ kind: 'advanced';
34
+ }>;
35
+ export declare const ERASE_BATCH = 512;
36
+ export declare function installationOf(store: Store, coverage: readonly RoomCoverage[], held: ReadonlyMap<string, CoveredRoom>): Installation;
37
+ export declare function roomInFlight(store: Store, locator: string): boolean;
38
+ export declare function sweep({ store, socket, journal }: Runtime): void;
39
+ export declare function forgetInstall(store: Store, locator: string): void;
40
+ export declare function caughtUpTo(runtime: Runtime, locator: string): void;
41
+ export declare function catching(store: Store, locator: string): void;
42
+ export declare function confirmedAgain(store: Store, locator: string): void;
43
+ export declare function standingAt(store: Store, locator: string, held: Pick<ReplicaRecord, 'key'> | undefined): Standing;
44
+ export declare function showing(system: Runtime, locator: string, roomVersion: string, held: string | undefined): void;
45
+ export declare function olderThan(system: Runtime, locator: string, roomVersion: string, held: string | undefined): boolean;
46
+ export declare function replaced(store: Store, locators: readonly string[]): void;
47
+ export declare function reachedBy({ store, socket }: Runtime, locator: string, roomVersion: string): Promise<boolean>;
48
+ export declare function behind({ store, socket }: Runtime, room: DiscoveredRoom): Promise<boolean>;
49
+ export declare function writtenAfter({ store, socket }: Runtime, locator: string, roomVersion: string, path: string): Promise<boolean>;
50
+ export declare function pullRefresh(runtime: Runtime, authorized: Authorization, record: ReplicaRecord, liveness: Live, hold: InstallHold, refresh: Refresher): Promise<Refreshed>;
51
+ export declare function pullBootstrap(runtime: Runtime, authorized: Authorization, room: DiscoveredRoom, local: RuntimeStore, liveness: Live, prior: ReplicaRecord | undefined, from?: Reads, unheld?: Unheld): Promise<import("./bootstrap.js").Bootstrapped | NotReady | import("./adapter.js").RevokedAuthorization | import("./adapter.js").RoomNotReadable | Unconfirmed | {
52
+ readonly kind: 'transport-uncertainty';
53
+ } | RetryableRefusal | import("./adapter.js").ScopedRefusal>;
54
+ export declare function publish(runtime: Runtime, local: RuntimeStore, room: DiscoveredRoom, reached: ReplicaRecord, landing: Landing, live: Live): Promise<boolean>;
55
+ export {};
@@ -0,0 +1,32 @@
1
+ type Job = {
2
+ readonly label: string;
3
+ readonly kind: 'started' | 'scheduled' | 'ended';
4
+ readonly state: string;
5
+ readonly next: string | null;
6
+ };
7
+ export type RunningJob = {
8
+ readonly name: string;
9
+ readonly running_since: string;
10
+ };
11
+ export type JobMarker = {
12
+ readonly said: string;
13
+ readonly at: string;
14
+ };
15
+ export type OpenJob<At = string | null> = {
16
+ readonly name: string;
17
+ readonly started: At;
18
+ };
19
+ export declare function jobOf(said: string): Job;
20
+ export declare function closeLast(open: {
21
+ readonly key: string;
22
+ }[], key: string): void;
23
+ export declare function markerMoved<Kept extends {
24
+ readonly key: string;
25
+ }>(open: Kept[], said: string, opened: (job: Job, key: string) => Kept | null): void;
26
+ export declare function openJobs<At>(markers: readonly {
27
+ readonly said: string;
28
+ readonly at: At;
29
+ }[]): readonly OpenJob<At>[];
30
+ export declare function jobsRunning(jobs: readonly RunningJob[], now: number): string[];
31
+ export declare function sessionEnded(jobs: readonly RunningJob[], now: number): string;
32
+ export {};
@@ -0,0 +1,52 @@
1
+ import type { HeldRooms } from '@agentshouse/mdmodel';
2
+ import type { DiscoveredRoom, HeldRoom, OperationScopes, ProviderRefusal, ReplicaAdmission } from './adapter.js';
3
+ import type { Composition } from './collection.js';
4
+ import { type ModelState, type TypesResult } from './model.js';
5
+ import { type PortReach } from './reach.js';
6
+ import type { ReplicaRecord } from './replica.js';
7
+ import type { Runtime } from './runtime.js';
8
+ import type { RoomDeclaration } from './socket.js';
9
+ import type { Stored } from './store.js';
10
+ export type AppTypedSelection = {
11
+ roots: readonly string[];
12
+ model: TypesResult;
13
+ };
14
+ export type AppRoom = {
15
+ name: string;
16
+ locator: string;
17
+ handle: string;
18
+ operations: OperationScopes;
19
+ replica: ReplicaAdmission;
20
+ model: TypesResult;
21
+ typedSelection: AppTypedSelection | null;
22
+ providerOwnedPaths: readonly string[];
23
+ roomVersion: string | null;
24
+ documents: number;
25
+ synchronizationAvailable: boolean;
26
+ refusal: ProviderRefusal | null;
27
+ locked: boolean;
28
+ };
29
+ type ListedRoom = Omit<AppRoom, 'documents' | 'locked'>;
30
+ type ListedEntry = ListedRoom & {
31
+ readonly documents: number;
32
+ };
33
+ export type Listing = ReadonlyMap<string, ListedEntry>;
34
+ export declare function modelIn({ socket }: Runtime, locator: string, stored: Stored | undefined): ModelState;
35
+ export declare function compositionFor(runtime: Runtime, record: ReplicaRecord): Composition;
36
+ export declare function declarationOf({ socket }: Runtime, locator: string, stored: Stored | undefined): {
37
+ readonly room: RoomDeclaration;
38
+ readonly available: boolean;
39
+ } | undefined;
40
+ export declare function listedLocators({ store, socket }: Runtime, held: ReadonlyMap<string, unknown>): string[];
41
+ export declare function patchedListing(runtime: Runtime, changed: ReadonlySet<string>): Promise<Listing | null>;
42
+ export declare function listingNow(runtime: Runtime): Promise<Listing>;
43
+ export declare function shownRooms(runtime: Runtime, listing: Listing): readonly AppRoom[];
44
+ export declare function roomFacts(runtime: Runtime, reach?: PortReach | null): Promise<HeldRooms>;
45
+ export declare function list({ store, socket }: Runtime, room: RoomDeclaration, synchronizationAvailable: boolean): void;
46
+ export declare function listHeld({ store, socket }: Runtime, locator: string): void;
47
+ export declare function admitted({ socket }: Runtime, room: RoomDeclaration): boolean;
48
+ export declare function readable(runtime: Runtime, room: DiscoveredRoom): void;
49
+ export declare function usable(runtime: Runtime, room: DiscoveredRoom): void;
50
+ export declare function heldRooms({ store }: Runtime, listed: readonly DiscoveredRoom[]): Promise<HeldRoom[]>;
51
+ export declare function name(runtime: Runtime, locator: string): Promise<void>;
52
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { ChangeSet } from './change-set.js';
2
+ import { type KeyedResult, type QueryMessage } from './observation.js';
3
+ import type { PendingResult, Plan, QueryCoverage } from './query.js';
4
+ import type { Fail } from './reach.js';
5
+ import type { QueryRoom } from './tables.js';
6
+ export type Cover = {
7
+ coverage: QueryCoverage;
8
+ rooms: readonly QueryRoom[];
9
+ } | PendingResult;
10
+ export type Ran = KeyedResult & {
11
+ readonly current: () => boolean;
12
+ };
13
+ export type Run = (plan: Plan, cover: () => Promise<Cover>) => Promise<Ran>;
14
+ type Listener = (message: QueryMessage) => void;
15
+ export type LiveQueries<H> = {
16
+ touched(set: ChangeSet): void;
17
+ recover(): void;
18
+ watch(plan: Plan, identity: string, cover: (held: H) => Cover, deliver: Listener, failed: Fail): () => void;
19
+ close(): void;
20
+ };
21
+ export declare function createLiveQueries<H>(run: Run, holding: () => Promise<H>): LiveQueries<H>;
22
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare function createLog(): {
2
+ record(event: string): void;
3
+ export(): string;
4
+ };
5
+ export type Log = ReturnType<typeof createLog>;