@agentshouse/app-bridge 0.1.0-c1bc683ed8f4e → 0.1.0-c1ccced28150f

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 (57) hide show
  1. package/README.md +9 -9
  2. package/dist/index.d.ts +826 -18
  3. package/dist/mdmodel/condition.d.ts +41 -11
  4. package/dist/mdmodel/definition.d.ts +17 -1
  5. package/dist/mdmodel/document.d.ts +5 -5
  6. package/dist/mdmodel/index.d.ts +11 -9
  7. package/dist/mdmodel/links.d.ts +28 -0
  8. package/dist/mdmodel/paths.d.ts +9 -1
  9. package/dist/mdmodel/project.d.ts +1 -0
  10. package/dist/mdmodel/types.d.ts +28 -4
  11. package/dist/mdmodel/validate.d.ts +27 -3
  12. package/dist/mdruntime/adapter.d.ts +121 -66
  13. package/dist/mdruntime/binary.d.ts +0 -5
  14. package/dist/mdruntime/chain.d.ts +10 -0
  15. package/dist/mdruntime/change-set.d.ts +9 -16
  16. package/dist/mdruntime/change.d.ts +31 -1
  17. package/dist/mdruntime/client.d.ts +15 -8
  18. package/dist/mdruntime/collection.d.ts +10 -21
  19. package/dist/mdruntime/compile.d.ts +15 -0
  20. package/dist/mdruntime/connection.d.ts +28 -14
  21. package/dist/mdruntime/conversation.d.ts +26 -11
  22. package/dist/mdruntime/durability.d.ts +2 -5
  23. package/dist/mdruntime/fulltext.d.ts +26 -0
  24. package/dist/mdruntime/identity.d.ts +6 -0
  25. package/dist/mdruntime/media.d.ts +7 -0
  26. package/dist/mdruntime/messages.d.ts +27 -0
  27. package/dist/mdruntime/model.d.ts +6 -1
  28. package/dist/mdruntime/observation.d.ts +15 -0
  29. package/dist/mdruntime/opened.d.ts +21 -0
  30. package/dist/mdruntime/outcome.d.ts +45 -7
  31. package/dist/mdruntime/overlay.d.ts +3 -5
  32. package/dist/mdruntime/query.d.ts +38 -2
  33. package/dist/mdruntime/reach.d.ts +14 -6
  34. package/dist/mdruntime/readiness.d.ts +14 -15
  35. package/dist/mdruntime/recovery.d.ts +3 -2
  36. package/dist/mdruntime/replica.d.ts +55 -33
  37. package/dist/mdruntime/room-draft.d.ts +33 -3
  38. package/dist/mdruntime/save.d.ts +53 -14
  39. package/dist/mdruntime/search.d.ts +32 -43
  40. package/dist/mdruntime/seed.d.ts +15 -0
  41. package/dist/mdruntime/status.d.ts +4 -3
  42. package/dist/mdruntime/store.d.ts +93 -98
  43. package/dist/mdruntime/stored.d.ts +129 -0
  44. package/dist/mdruntime/tables.d.ts +324 -0
  45. package/dist/mdruntime/wire.d.ts +33 -5
  46. package/dist/test-host.d.ts +7 -4
  47. package/dist/test-host.js +18 -28
  48. package/docs/families.md +52 -47
  49. package/package.json +8 -3
  50. package/dist/calls.d.ts +0 -117
  51. package/dist/calls.js +0 -1
  52. package/dist/mdruntime/acquisition.d.ts +0 -13
  53. package/dist/mdruntime/file.d.ts +0 -19
  54. package/dist/mdruntime/rows.d.ts +0 -36
  55. package/dist/mdruntime/shared.d.ts +0 -10
  56. package/dist/mdruntime/transfer.d.ts +0 -9
  57. package/dist/mdruntime/turn.d.ts +0 -6
@@ -1,54 +1,37 @@
1
- import type { ModelState } from './model.js';
2
- import type { Capability, HeadChange, Member, OperationScopes, ProviderLimit, ReplicaAdmission, TypedSelection } from './adapter.js';
3
- import type { AcceptedMessage, KeptReceipt } from './adapter.js';
1
+ import type { BootstrapInventory, Capability, ListedConversation, Member, ProviderLimit } from './adapter.js';
4
2
  import type { ChangeBatch } from './change.js';
5
- import { type HeldBinary } from './overlay.js';
6
- import type { ChatDraftFile } from './file.js';
3
+ import { type Composition } from './collection.js';
4
+ import type { Plan } from './query.js';
5
+ import type { ReplicaRecord } from './replica.js';
7
6
  import type { Submission } from './outcome.js';
8
7
  import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
9
- export declare const STORE_SCHEMA = 25;
10
- export declare const AUTHORED_SCHEMA = 2;
11
- export type ReplicaRecord = {
12
- locator: string;
13
- name: string;
14
- handle: string;
15
- operations: OperationScopes;
16
- replica: ReplicaAdmission;
17
- model: ModelState;
18
- typedSelection: TypedSelection | null;
19
- selectionModel: ModelState;
20
- providerOwnedPaths: readonly string[];
21
- roomVersion: string;
22
- transfer: string;
23
- documents: Readonly<Record<string, string>>;
24
- binaries: Readonly<Record<string, HeldBinary>>;
25
- revisions: Readonly<Record<string, string>>;
26
- changes: Readonly<Record<string, HeadChange>>;
27
- written: Readonly<Record<string, string>>;
28
- };
29
- export type StagedLayer = Pick<ReplicaRecord, 'documents' | 'binaries' | 'revisions' | 'changes' | 'written'>;
8
+ import type { ModelState, StoredModel } from './model.js';
9
+ import type { SearchWindow } from './search.js';
10
+ import type { CommittedWrite, ConversationWrite, CountedRoom, HeldConversation, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, RoomCommit, RuntimeDatabase, SearchAsk, StoredEntry, StoredFile, TypedEntry, View } from './tables.js';
11
+ export type { ConversationWrite, HeldConversation, MessageWindow } from './tables.js';
30
12
  export type TransferRecord = {
31
- locator: string;
32
- transfer: string;
33
- selection: string;
34
- from: string;
35
- last: string;
36
- pageToken: string | null;
37
- models: {
38
- collection: ModelState;
39
- selection: ModelState;
13
+ readonly locator: string;
14
+ readonly transfer: string;
15
+ readonly selection: string;
16
+ readonly from: string;
17
+ readonly last: string;
18
+ readonly done: BootstrapInventory;
19
+ readonly models: {
20
+ readonly collection: ModelState;
40
21
  };
22
+ readonly key: number | null;
23
+ };
24
+ export type StoredReplica = Omit<ReplicaRecord, 'model'> & {
25
+ readonly model: StoredModel;
41
26
  };
42
27
  export type PendingState = {
43
28
  readonly drafts: readonly SavedDraft[];
44
29
  readonly submission: Submission;
45
30
  readonly lost: boolean;
46
31
  readonly upload?: unknown;
47
- readonly accepted?: string;
48
32
  };
49
33
  export type TargetRecord = {
50
34
  established: boolean;
51
- search: boolean;
52
35
  };
53
36
  export type QueueRecord = {
54
37
  locator: string;
@@ -61,99 +44,111 @@ export type PresentationRecord = {
61
44
  app: string;
62
45
  value: unknown;
63
46
  };
64
- export type HeldConversation = {
65
- conversation: string;
66
- read: string | null | undefined;
67
- partial: boolean;
68
- };
69
- export type ConversationWrite = {
70
- conversation: string;
71
- messages: readonly AcceptedMessage[];
72
- read?: {
73
- at: string | null;
74
- partial: boolean;
75
- };
76
- };
77
47
  export type ChatSubmission = {
78
48
  readonly operation: string;
79
49
  readonly text: string;
80
- readonly files: readonly ChatDraftFile[];
81
50
  readonly turn: string | null;
82
51
  };
83
52
  export type ChatDraftRecord = {
84
53
  conversation: string;
85
54
  text: string;
86
- files: readonly ChatDraftFile[];
87
55
  revision: string;
88
56
  submitted?: readonly ChatSubmission[];
57
+ moves?: readonly string[];
89
58
  };
90
- export type RecordWrite = {
91
- next: ReplicaRecord;
92
- previous: ReplicaRecord | null;
93
- stored?: StagedLayer;
59
+ export type CallRecord = {
60
+ readonly operation: string;
61
+ readonly name: string;
62
+ readonly input: unknown;
94
63
  };
95
64
  export type AuthoredWrite = {
96
65
  locator: string;
97
- queue: readonly ChangeBatch[];
66
+ queue?: readonly ChangeBatch[];
67
+ founded?: readonly ChangeBatch[];
98
68
  saved?: ReadonlyMap<string, readonly SavedDraft[]>;
99
69
  roomDrafts?: readonly RoomDraftRecord[];
100
70
  consumedRoomDrafts?: readonly string[];
101
71
  };
72
+ export type StagedPage = {
73
+ readonly entries: readonly StoredEntry[];
74
+ readonly folders: readonly string[];
75
+ };
76
+ export type RefreshedPage = StagedPage & {
77
+ readonly removals: readonly string[];
78
+ readonly folderRemovals: readonly string[];
79
+ };
80
+ export type Opened = {
81
+ readonly rooms: ReadonlyMap<string, StoredReplica>;
82
+ readonly unindexed: ReadonlySet<number>;
83
+ readonly overlaid: ReadonlyMap<number, ReadonlySet<string>>;
84
+ readonly erasing: boolean;
85
+ readonly orphans: readonly number[];
86
+ readonly lastCompleted: string | null;
87
+ readonly providerLimits: readonly ProviderLimit[];
88
+ readonly capabilities: readonly Capability[];
89
+ readonly member: Member | null;
90
+ readonly targets: Readonly<Record<string, TargetRecord>>;
91
+ readonly presentation: readonly PresentationRecord[];
92
+ readonly conversationList: readonly ListedConversation[] | null;
93
+ readonly conversationCursor: string | null;
94
+ };
95
+ export type Commit = {
96
+ readonly rooms: readonly RoomCommit[];
97
+ readonly writes?: readonly AuthoredWrite[];
98
+ readonly files?: readonly StoredFile[];
99
+ readonly whole?: boolean;
100
+ readonly discards?: readonly string[];
101
+ };
102
102
  export type RuntimeStore = {
103
- all(): Promise<readonly ReplicaRecord[]>;
104
- keepAuthored(input: AuthoredWrite): Promise<void>;
105
- write(input: RecordWrite): Promise<void>;
106
- revokeModels(records: readonly ReplicaRecord[]): Promise<void>;
107
- lastCompleted(): Promise<string | null>;
108
- complete(at: string): Promise<void>;
109
- providerLimits(): Promise<readonly ProviderLimit[]>;
110
- capabilities(): Promise<readonly Capability[]>;
111
- declare(limits: readonly ProviderLimit[], capabilities: readonly Capability[]): Promise<void>;
112
- member(): Promise<Member | null>;
113
- keepMember(member: Member | null): Promise<void>;
114
- targets(): Promise<Readonly<Record<string, TargetRecord>>>;
115
- keepTargets(targets: Readonly<Record<string, TargetRecord>>): Promise<void>;
103
+ opened(): Promise<Opened>;
104
+ counts(rooms: readonly CountedRoom[]): Promise<readonly number[]>;
105
+ query(plan: Plan, rooms: readonly QueryRoom[], budget: number | null): Promise<QueryAnswer>;
106
+ changes(keys: readonly number[]): number;
107
+ entries(key: number, view: View, paths: readonly string[]): Promise<readonly HeldEntry[]>;
108
+ typed(key: number, view: View, paths: readonly string[]): Promise<readonly TypedEntry[]>;
109
+ referrers(key: number, view: View, targets: readonly string[], kinds: readonly string[]): Promise<readonly Referrer[]>;
110
+ files(key: number, view: View, after: string | null, limit: number): Promise<readonly {
111
+ readonly path: string;
112
+ readonly revision: string;
113
+ }[]>;
114
+ folders(key: number, view: View, paths: readonly string[]): Promise<readonly string[]>;
115
+ typedWithin(key: number, view: View, roots: readonly string[], within: boolean): Promise<boolean>;
116
+ search(ask: SearchAsk): Promise<SearchWindow>;
117
+ stage(record: TransferRecord, composition: Composition, page: StagedPage): Promise<number | null>;
118
+ refresh(key: number, composition: Composition, page: RefreshedPage): Promise<void>;
119
+ unrefresh(key: number): Promise<void>;
120
+ commit(commit: Commit): Promise<CommittedWrite>;
121
+ fence(locators: readonly string[]): Promise<void>;
122
+ erase(locator: string | null, limit: number): Promise<boolean>;
123
+ abandon(locator: string): Promise<void>;
124
+ release(key: number): Promise<void>;
125
+ rederive(key: number, composition: Composition, bytes: number, ms: number, floor: number): Promise<{
126
+ readonly done: boolean;
127
+ readonly text: number;
128
+ }>;
129
+ fact(name: string, value: unknown): Promise<void>;
116
130
  queues(): Promise<readonly QueueRecord[]>;
117
131
  submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
118
- accept(locator: string, id: string, roomVersion: string): Promise<void>;
119
132
  keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
120
133
  roomDrafts(): Promise<readonly RoomDraftRecord[]>;
121
- presentation(): Promise<readonly PresentationRecord[]>;
122
134
  present(record: PresentationRecord): Promise<void>;
123
135
  conversations(): Promise<readonly HeldConversation[]>;
124
136
  keepMessages(write: ConversationWrite): Promise<void>;
125
- messageWindow(conversation: string, limit: number | undefined): Promise<AcceptedMessage[]>;
126
- messagesAfter(conversation: string, identity: string | null): Promise<AcceptedMessage[]>;
127
- messageIdentities(conversation: string): Promise<readonly string[]>;
137
+ messageWindow(conversation: string, limit: number, before: readonly [string, string] | null): Promise<MessageWindow>;
138
+ messageCount(conversation: string): Promise<number>;
128
139
  turnArrived(conversation: string, turn: string): Promise<boolean>;
129
140
  dropConversations(conversations: readonly string[]): Promise<void>;
130
141
  chatDrafts(): Promise<readonly ChatDraftRecord[]>;
131
- keepChatDraft(record: ChatDraftRecord): Promise<void>;
142
+ keepChatDrafts(records: readonly ChatDraftRecord[]): Promise<void>;
132
143
  dropChatDraft(conversation: string): Promise<void>;
133
- keepRoomDraft(record: RoomDraftRecord): Promise<void>;
144
+ calls(): Promise<readonly CallRecord[]>;
145
+ keepCall(record: CallRecord): Promise<void>;
146
+ dropCall(operation: string): Promise<void>;
147
+ keepRoomDraft(record: RoomDraftRecord, files: readonly StoredFile[]): Promise<void>;
134
148
  discardRoomDraft(locator: string, path: string): Promise<void>;
135
149
  fences(): Promise<readonly string[]>;
136
- erase(locators: readonly string[]): Promise<void>;
137
- discard(locator: string): Promise<void>;
138
- transfers(): Promise<readonly TransferRecord[]>;
139
- staged(record: TransferRecord): Promise<StagedLayer>;
140
- stage(record: TransferRecord, page: StagedLayer): Promise<void>;
141
- abandon(locator: string): Promise<void>;
142
- receivedHeads(): Promise<readonly KeptReceipt[]>;
143
- receivedParts(key: string, count: number): Promise<readonly unknown[]>;
144
- keepReceived(key: string, head: unknown, part?: {
145
- index: number;
146
- value: unknown;
147
- }): Promise<void>;
148
- dropReceived(keys: readonly string[]): Promise<void>;
149
150
  generation(): Promise<string | null>;
150
151
  rememberGeneration(value: string): Promise<void>;
151
- close(): void;
152
+ file(key: string, type: string): Promise<Blob>;
152
153
  };
153
- export declare function authoredHolder(): Promise<string | null>;
154
- export declare function authoredBy(holder: string): Promise<boolean>;
155
- export declare function authoredBinding(): Promise<string | null>;
156
- export declare function bindAuthored(binding: string): Promise<void>;
157
- export declare function removeRuntimeStore(holder?: string): Promise<boolean>;
158
- export declare function openDatabase(name: string, version: number, upgrade: (opening: IDBOpenDBRequest, oldVersion: number) => void): Promise<IDBDatabase>;
159
- export declare function openRuntimeStore(fenced: (locator: string) => boolean): Promise<RuntimeStore>;
154
+ export declare function openRuntimeStore(fenced: (locator: string) => boolean, authored: RuntimeDatabase): RuntimeStore;
@@ -0,0 +1,129 @@
1
+ import type { HeadChange } from './adapter.js';
2
+ import { type Composed, type Composition } from './collection.js';
3
+ import type { HeldBinary } from './overlay.js';
4
+ import type { Connection } from './tables.js';
5
+ export declare const REPLICA_TABLES: readonly string[];
6
+ export type View = 'confirmed' | 'visible' | 'refreshed';
7
+ export type StoredEntry = {
8
+ readonly path: string;
9
+ readonly content: string | null;
10
+ readonly binary: HeldBinary | null;
11
+ readonly revision: string | null;
12
+ readonly fileId: string | null;
13
+ readonly change: HeadChange | null;
14
+ readonly written: string | null;
15
+ };
16
+ export type OverlayEntry = StoredEntry & {
17
+ readonly present: boolean;
18
+ };
19
+ export type HeldEntry = StoredEntry & {
20
+ readonly type: string | null;
21
+ };
22
+ export type TypedEntry = {
23
+ readonly path: string;
24
+ readonly type: string | null;
25
+ readonly binary: boolean;
26
+ };
27
+ export type Referrer = {
28
+ readonly path: string;
29
+ readonly target: string;
30
+ readonly kind: string;
31
+ };
32
+ export type HeldKey = {
33
+ readonly key: number;
34
+ readonly locator: string;
35
+ readonly transfer: string;
36
+ readonly rederiving: number | null;
37
+ readonly searching: number | null;
38
+ };
39
+ export type ReplicaOpened = {
40
+ readonly rooms: readonly {
41
+ readonly locator: string;
42
+ readonly key: number;
43
+ readonly record: string;
44
+ }[];
45
+ readonly keys: readonly HeldKey[];
46
+ readonly facts: Readonly<Record<string, string>>;
47
+ readonly presentation: readonly {
48
+ readonly app: string;
49
+ readonly value: string;
50
+ }[];
51
+ readonly overlaid: readonly {
52
+ readonly key: number;
53
+ readonly path: string;
54
+ }[];
55
+ readonly erasing: readonly {
56
+ readonly key: number;
57
+ readonly locator: string;
58
+ }[];
59
+ readonly orphans: readonly number[];
60
+ };
61
+ export type RoomCommit = {
62
+ readonly locator: string;
63
+ readonly key: number;
64
+ readonly record?: string;
65
+ readonly roots?: readonly string[];
66
+ readonly published?: {
67
+ readonly from: number | null;
68
+ };
69
+ readonly refreshed?: true;
70
+ readonly composed: Composed;
71
+ readonly confirmed?: {
72
+ readonly set: readonly StoredEntry[];
73
+ readonly removed: readonly string[];
74
+ };
75
+ readonly overlay?: {
76
+ readonly set: readonly OverlayEntry[];
77
+ readonly cleared: readonly string[];
78
+ };
79
+ };
80
+ export type Committed = {
81
+ readonly counts: Readonly<Record<string, number>>;
82
+ readonly changed: Readonly<Record<string, readonly string[] | null>>;
83
+ readonly indexed: Readonly<Record<string, boolean>>;
84
+ };
85
+ export type CountedRoom = {
86
+ readonly key: number;
87
+ readonly roots: readonly string[];
88
+ };
89
+ export declare function entered(connection: Connection, locator: string, composition: Composition, rows: readonly StoredEntry[]): number;
90
+ export declare function stage(connection: Connection, request: {
91
+ readonly locator: string;
92
+ readonly transfer: string;
93
+ readonly key: number | null;
94
+ readonly fingerprint: string;
95
+ readonly entries: readonly StoredEntry[];
96
+ readonly folders: readonly string[];
97
+ }): number;
98
+ export declare function refreshing(connection: Connection, request: {
99
+ readonly key: number;
100
+ readonly composed: Composed;
101
+ readonly entries: readonly StoredEntry[];
102
+ readonly removals: readonly string[];
103
+ readonly folders: readonly string[];
104
+ readonly folderRemovals: readonly string[];
105
+ }): null;
106
+ export declare function unrefresh(connection: Connection, key: number): null;
107
+ export declare function counts(connection: Connection, rooms: readonly CountedRoom[]): number[];
108
+ export declare function commit(connection: Connection, rooms: readonly RoomCommit[]): Committed;
109
+ export declare function fenceRooms(connection: Connection, locators: readonly string[]): null;
110
+ export declare function abandon(connection: Connection, locator: string): null;
111
+ export declare function release(connection: Connection, key: number): null;
112
+ export declare function erase(connection: Connection, locator: string | null, limit: number): {
113
+ readonly remaining: boolean;
114
+ };
115
+ export declare function rederive(connection: Connection, key: number, composed: Composed, bytes: number, ms: number, floor: number): {
116
+ readonly done: boolean;
117
+ readonly text: number;
118
+ };
119
+ export declare function entries(connection: Connection, key: number, view: View, list: readonly string[]): HeldEntry[];
120
+ export declare function typed(connection: Connection, key: number, view: View, list: readonly string[]): TypedEntry[];
121
+ export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[], kinds: readonly string[]): Referrer[];
122
+ export declare function files(connection: Connection, key: number, view: View, after: string | null, limit: number): {
123
+ readonly path: string;
124
+ readonly revision: string;
125
+ }[];
126
+ export declare function folders(connection: Connection, key: number, view: View, list: readonly string[]): string[];
127
+ export declare function typedWithin(connection: Connection, key: number, view: View, roots: readonly string[], within: boolean): boolean;
128
+ export declare function opened(connection: Connection): ReplicaOpened;
129
+ export declare function ended(connection: Connection): void;