@agentshouse/app-bridge 0.1.0-c8d8dc6285bbd → 0.1.0-c8dc2a697434d

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 (120) hide show
  1. package/README.md +7 -7
  2. package/dist/index.d.ts +595 -24
  3. package/dist/mdmodel/body.d.ts +84 -0
  4. package/dist/mdmodel/built-in.d.ts +3 -0
  5. package/dist/mdmodel/definition.d.ts +20 -11
  6. package/dist/mdmodel/document.d.ts +14 -8
  7. package/dist/mdmodel/event.d.ts +76 -0
  8. package/dist/mdmodel/facts.d.ts +14 -0
  9. package/dist/mdmodel/fields.d.ts +1 -1
  10. package/dist/mdmodel/house-model.d.ts +869 -0
  11. package/dist/mdmodel/house-references/crockford.d.ts +3 -0
  12. package/dist/mdmodel/house-references/patterns.d.ts +8 -0
  13. package/dist/mdmodel/index.d.ts +40 -15
  14. package/dist/mdmodel/kinds.d.ts +17 -0
  15. package/dist/mdmodel/markdown.d.ts +74 -0
  16. package/dist/mdmodel/media-type.d.ts +71 -0
  17. package/dist/mdmodel/moment.d.ts +6 -0
  18. package/dist/mdmodel/not-ready.d.ts +1 -0
  19. package/dist/mdmodel/paths.d.ts +15 -1
  20. package/dist/mdmodel/pattern.d.ts +9 -0
  21. package/dist/mdmodel/query/language.d.ts +253 -0
  22. package/dist/mdmodel/query/match.d.ts +13 -0
  23. package/dist/mdmodel/query/rows.d.ts +31 -0
  24. package/dist/mdmodel/query/sql.d.ts +38 -0
  25. package/dist/mdmodel/references.d.ts +2 -2
  26. package/dist/mdmodel/reserved.d.ts +5 -0
  27. package/dist/mdmodel/room-types.d.ts +6 -0
  28. package/dist/mdmodel/types.d.ts +22 -17
  29. package/dist/mdmodel/validate.d.ts +12 -6
  30. package/dist/mdmodel/yaml.d.ts +4 -4
  31. package/dist/mdruntime/actions.d.ts +25 -0
  32. package/dist/mdruntime/adapter.d.ts +181 -113
  33. package/dist/mdruntime/attached-model.d.ts +6 -0
  34. package/dist/mdruntime/authored.d.ts +87 -0
  35. package/dist/mdruntime/bootstrap.d.ts +43 -0
  36. package/dist/mdruntime/cell.d.ts +5 -0
  37. package/dist/mdruntime/chain.d.ts +2 -1
  38. package/dist/mdruntime/change-set.d.ts +4 -0
  39. package/dist/mdruntime/change.d.ts +5 -0
  40. package/dist/mdruntime/client.d.ts +33 -25
  41. package/dist/mdruntime/collection.d.ts +31 -7
  42. package/dist/mdruntime/compile.d.ts +8 -6
  43. package/dist/mdruntime/conversation-live.d.ts +149 -0
  44. package/dist/mdruntime/conversation-row.d.ts +39 -0
  45. package/dist/mdruntime/conversation.d.ts +72 -51
  46. package/dist/mdruntime/declaration.d.ts +9 -0
  47. package/dist/mdruntime/durability.d.ts +19 -1
  48. package/dist/mdruntime/failure.d.ts +3 -0
  49. package/dist/mdruntime/figures.d.ts +48 -0
  50. package/dist/mdruntime/holdings.d.ts +28 -0
  51. package/dist/mdruntime/identity.d.ts +0 -1
  52. package/dist/mdruntime/install.d.ts +59 -0
  53. package/dist/mdruntime/listing.d.ts +51 -0
  54. package/dist/mdruntime/live.d.ts +24 -0
  55. package/dist/mdruntime/media.d.ts +24 -0
  56. package/dist/mdruntime/messages.d.ts +35 -5
  57. package/dist/mdruntime/model.d.ts +8 -11
  58. package/dist/mdruntime/observation.d.ts +29 -13
  59. package/dist/mdruntime/opened.d.ts +1 -1
  60. package/dist/mdruntime/outcome.d.ts +30 -7
  61. package/dist/mdruntime/overlay.d.ts +7 -2
  62. package/dist/mdruntime/preparation.d.ts +40 -0
  63. package/dist/mdruntime/presence.d.ts +57 -0
  64. package/dist/mdruntime/query.d.ts +18 -208
  65. package/dist/mdruntime/reach.d.ts +21 -13
  66. package/dist/mdruntime/readiness.d.ts +12 -21
  67. package/dist/mdruntime/reads.d.ts +38 -0
  68. package/dist/mdruntime/recovery.d.ts +3 -0
  69. package/dist/mdruntime/refresh.d.ts +26 -0
  70. package/dist/mdruntime/replica.d.ts +13 -20
  71. package/dist/mdruntime/retried.d.ts +29 -0
  72. package/dist/mdruntime/room-draft.d.ts +51 -12
  73. package/dist/mdruntime/room-drafts.d.ts +23 -0
  74. package/dist/mdruntime/runtime.d.ts +33 -0
  75. package/dist/mdruntime/save.d.ts +42 -84
  76. package/dist/mdruntime/saves.d.ts +33 -0
  77. package/dist/mdruntime/search.d.ts +12 -63
  78. package/dist/mdruntime/seed.d.ts +11 -2
  79. package/dist/mdruntime/socket/admission.d.ts +6 -0
  80. package/dist/mdruntime/socket/answers.d.ts +5 -0
  81. package/dist/mdruntime/socket/lanes.d.ts +27 -0
  82. package/dist/mdruntime/socket/session.d.ts +37 -0
  83. package/dist/mdruntime/socket.d.ts +66 -0
  84. package/dist/mdruntime/source.d.ts +58 -0
  85. package/dist/mdruntime/status.d.ts +4 -5
  86. package/dist/mdruntime/store/installs.d.ts +29 -0
  87. package/dist/mdruntime/store/readiness.d.ts +10 -0
  88. package/dist/mdruntime/store/records.d.ts +222 -0
  89. package/dist/mdruntime/store/room-held.d.ts +7 -0
  90. package/dist/mdruntime/store/rooms-shown.d.ts +7 -0
  91. package/dist/mdruntime/store/space.d.ts +10 -0
  92. package/dist/mdruntime/store/watchers.d.ts +16 -0
  93. package/dist/mdruntime/store/writes.d.ts +23 -0
  94. package/dist/mdruntime/store.d.ts +113 -157
  95. package/dist/mdruntime/stored.d.ts +79 -57
  96. package/dist/mdruntime/surface.d.ts +89 -0
  97. package/dist/mdruntime/tables.d.ts +129 -107
  98. package/dist/mdruntime/tallies.d.ts +17 -0
  99. package/dist/mdruntime/transfer.d.ts +0 -5
  100. package/dist/mdruntime/wire.d.ts +75 -13
  101. package/dist/session-content/bounds.d.ts +7 -0
  102. package/dist/session-content/check.d.ts +18 -0
  103. package/dist/session-content/index.d.ts +7 -0
  104. package/dist/session-content/parts.d.ts +103 -0
  105. package/dist/session-content/state.d.ts +61 -0
  106. package/dist/session-content/turn.d.ts +328 -0
  107. package/dist/test-host.d.ts +8 -4
  108. package/dist/test-host.js +28 -28
  109. package/docs/families.md +79 -67
  110. package/package.json +2 -2
  111. package/dist/calls.d.ts +0 -1007
  112. package/dist/calls.js +0 -1
  113. package/dist/mdmodel/blocks.d.ts +0 -10
  114. package/dist/mdmodel/condition.d.ts +0 -160
  115. package/dist/mdmodel/links.d.ts +0 -28
  116. package/dist/mdmodel/profile.d.ts +0 -5
  117. package/dist/mdruntime/connection.d.ts +0 -151
  118. package/dist/mdruntime/file.d.ts +0 -11
  119. package/dist/mdruntime/fulltext.d.ts +0 -26
  120. package/dist/mdruntime/shared.d.ts +0 -15
@@ -12,9 +12,16 @@ export type ModelVerification = {
12
12
  readonly rule: string;
13
13
  readonly location?: string;
14
14
  };
15
+ export type TypedPath = {
16
+ readonly path: string;
17
+ readonly type: string;
18
+ readonly named: boolean;
19
+ readonly body: boolean;
20
+ };
15
21
  export type ValidationContext = {
16
22
  readonly binaryTargets: readonly string[];
17
23
  readonly anyRoom?: true;
24
+ readonly typedPaths?: readonly TypedPath[];
18
25
  };
19
26
  export type ProjectionContext = {
20
27
  readonly documentTargets: readonly string[];
@@ -30,19 +37,22 @@ export type Extent = {
30
37
  export type Span = Extent & {
31
38
  readonly text: string;
32
39
  };
33
- export type Frontmatter = {
40
+ export type Document = {
34
41
  readonly content: string;
35
42
  readonly type: string | undefined;
36
43
  readonly fields: Readonly<Record<string, unknown>>;
37
- };
38
- export type Document = Frontmatter & {
39
44
  readonly preamble: string;
40
45
  readonly sections: Readonly<Record<string, string>>;
46
+ readonly text: string;
47
+ readonly ranges: Readonly<Record<string, Extent>>;
48
+ readonly listEnd: number;
41
49
  };
50
+ export type DefinitionOf = (type: string | undefined) => Definition | undefined;
42
51
  export type Refusal = {
43
52
  readonly file: string;
44
53
  readonly rule: string;
45
54
  readonly location?: string;
55
+ readonly line?: number;
46
56
  readonly referrers?: readonly string[];
47
57
  };
48
58
  export type Reached = {
@@ -80,13 +90,6 @@ export type Division = {
80
90
  readonly ok: false;
81
91
  readonly refusal: Refusal;
82
92
  };
83
- export type FrontmatterResult = {
84
- readonly ok: true;
85
- readonly frontmatter: Frontmatter;
86
- } | {
87
- readonly ok: false;
88
- readonly refusal: Refusal;
89
- };
90
93
  export type ParseResult = {
91
94
  readonly ok: true;
92
95
  readonly document: Document;
@@ -116,12 +119,6 @@ export type RoomReference = {
116
119
  readonly value: string;
117
120
  readonly to: readonly string[];
118
121
  readonly crossRoom?: true;
119
- } | {
120
- readonly kind: 'item';
121
- readonly section: string;
122
- readonly href: string;
123
- readonly to: readonly string[];
124
- readonly crossRoom?: true;
125
122
  });
126
123
  export type Change = {
127
124
  readonly kind: 'field';
@@ -132,11 +129,15 @@ export type Change = {
132
129
  readonly kind: 'section';
133
130
  readonly name: string;
134
131
  readonly value: string;
135
- readonly prior: string;
132
+ readonly prior: string | undefined;
136
133
  } | {
137
134
  readonly kind: 'preamble';
138
135
  readonly value: string;
139
136
  readonly prior: string;
137
+ } | {
138
+ readonly kind: 'text';
139
+ readonly value: string;
140
+ readonly prior: string;
140
141
  } | {
141
142
  readonly kind: 'link';
142
143
  readonly href: string;
@@ -165,3 +166,7 @@ export type BodyResult = {
165
166
  readonly outcome: 'refuse';
166
167
  readonly refusal: Refusal;
167
168
  };
169
+ export type UnlinkedBody = {
170
+ readonly body: string;
171
+ readonly links: ReadonlyMap<string, string>;
172
+ };
@@ -1,14 +1,19 @@
1
1
  import { type Definition } from './definition.js';
2
- import type { DocumentCheck, Library, ModelVerification, Reached, RoomReference, Validation, ValidationContext, ValidationStep, VerifiedModel } from './types.js';
2
+ import { type KeyedLink } from './paths.js';
3
+ import type { DefinitionOf, Document, DocumentCheck, Library, ModelVerification, ParseResult, Reached, RoomReference, TypedPath, Validation, ValidationContext, ValidationStep, VerifiedModel } from './types.js';
4
+ export declare function definitionAt(model: VerifiedModel, file: string, typedPaths?: readonly TypedPath[]): DefinitionOf;
3
5
  export declare function resolves(reference: Reached, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): boolean;
4
6
  export declare function verify(schema: string, provided?: VerifiedModel): ModelVerification;
5
- export declare function checkDocument(file: string, content: string, model: VerifiedModel, context?: Pick<ValidationContext, 'anyRoom'>): DocumentCheck;
6
- export declare function sectionReferences(file: string, content: string, definition: Definition): readonly Reached[];
7
+ export declare function readTypes(schema: string, provided?: VerifiedModel): VerifiedModel;
8
+ type Placing = Pick<ValidationContext, 'anyRoom' | 'typedPaths'>;
9
+ export declare function checkDocument(file: string, content: string, model: VerifiedModel, context?: Placing): DocumentCheck;
7
10
  export declare function bodyRoomLinks(body: string): RoomReference[];
8
- export declare function roomReferences(file: string, content: string, definition?: Definition): readonly RoomReference[];
11
+ export declare function bodyKeyedLinks(body: string): KeyedLink[];
12
+ export declare function roomReferences(document: Document, definition?: Definition): readonly RoomReference[];
9
13
  type Placed = {
10
14
  readonly reference: Reached;
11
15
  readonly location: string;
16
+ readonly line?: number;
12
17
  };
13
18
  export type Assessment = {
14
19
  readonly file: string;
@@ -18,9 +23,9 @@ export type Assessment = {
18
23
  readonly structured: Validation | null;
19
24
  readonly fields: readonly Placed[];
20
25
  readonly linked: boolean;
21
- readonly sections: readonly Placed[];
22
26
  };
23
- export declare function assess(file: string, content: string, binary: boolean, model?: VerifiedModel, context?: Pick<ValidationContext, 'anyRoom'>): Assessment;
27
+ export declare function assess(file: string, parsed: ParseResult, binary: boolean, model?: VerifiedModel, context?: Placing): Assessment;
28
+ export declare function assessReferences(file: string, parsed: ParseResult, changed: ReadonlySet<string>, model?: VerifiedModel, context?: Placing): Assessment;
24
29
  export type Verdicts = {
25
30
  add(assessment: Assessment, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): number;
26
31
  verdict(): Validation;
@@ -28,4 +33,5 @@ export type Verdicts = {
28
33
  export declare function verdicts(): Verdicts;
29
34
  export declare function validating(library: ReadonlyMap<string, string>, context?: ValidationContext, model?: VerifiedModel): Generator<ValidationStep, Validation, void>;
30
35
  export declare function validate(library: Library, context?: ValidationContext, model?: VerifiedModel): Validation;
36
+ export declare function validateParsed(library: ReadonlyMap<string, ParseResult>, context?: ValidationContext, model?: VerifiedModel): Validation;
31
37
  export {};
@@ -31,12 +31,12 @@ export declare function parseYamlMapping(text: string, start: number, end: numbe
31
31
  export declare function jsValue(node: YamlNode): unknown;
32
32
  export declare function mapEntry(map: YamlMap, key: string): YamlEntry | undefined;
33
33
  export declare function isPlainSafe(text: string): boolean;
34
- export type FrontmatterValue = string | number | boolean | null | readonly FrontmatterValue[] | {
35
- readonly [name: string]: FrontmatterValue;
34
+ export type DocumentValue = string | number | boolean | null | readonly DocumentValue[] | {
35
+ readonly [name: string]: DocumentValue;
36
36
  };
37
37
  export declare function plain(value: unknown): value is Record<string, unknown>;
38
- export declare function frontmatterValue(value: unknown): value is FrontmatterValue;
39
- export declare function serializeJs(value: FrontmatterValue): string;
38
+ export declare function documentValue(value: unknown): value is DocumentValue;
39
+ export declare function serializeJs(value: DocumentValue): string;
40
40
  export declare function isRecord(value: unknown): value is Record<string, unknown>;
41
41
  export declare function serializeKey(name: string): string;
42
42
  export declare function bodyStartAfterYaml(content: string, yamlEnd: number): number;
@@ -0,0 +1,25 @@
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 { Attempt } from './retried.js';
5
+ import type { Runtime } from './runtime.js';
6
+ export type HistoryQuery = {
7
+ revision?: string;
8
+ pageToken?: string;
9
+ };
10
+ export declare function readHistory(runtime: Runtime, locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
11
+ export declare function located(runtime: Runtime, room: string, path: string, destination: string): Promise<{
12
+ room: string;
13
+ path: string;
14
+ } | null>;
15
+ export declare function resolveReference(runtime: Runtime, room: string, path: string, destination: string): Promise<Resolution>;
16
+ export type Invoked = {
17
+ readonly dispatching?: () => Promise<void>;
18
+ readonly attempt?: Attempt;
19
+ };
20
+ export declare function invokeAction(runtime: Runtime, name: string, input: unknown, { dispatching, attempt }?: Invoked): Promise<CallResult>;
21
+ export declare function readConversationHistory(runtime: Runtime, request: ConversationHistoryRequest): Promise<CallResult>;
22
+ export declare function called(runtime: Runtime, name: string, input: unknown, attempt?: Attempt): Promise<CallResult>;
23
+ export declare function answeredCall(runtime: Runtime, operation: string): Promise<boolean>;
24
+ export declare function resendCalls(runtime: Runtime, signal: AbortSignal): Promise<Attempted>;
25
+ export declare function resendLater(runtime: Runtime): void;
@@ -1,4 +1,7 @@
1
+ import type { SavedFacts, TypedPath, VerifiedModel } from '../mdmodel/index.js';
2
+ import type { Operation, SessionState } from '../session-content/index.js';
1
3
  import type { ModelResult } from './model.js';
4
+ export type { SavedFacts, TypedPath };
2
5
  import type { Open } from './open.js';
3
6
  import type { ChangeBatch } from './change.js';
4
7
  export type Authorization = object;
@@ -11,35 +14,30 @@ export type TypedSelection = {
11
14
  };
12
15
  export type OperationScopes = {
13
16
  write: readonly string[];
14
- delete: readonly string[];
17
+ erase: readonly string[];
15
18
  };
16
19
  export type ReplicaAdmission = {
17
20
  selection: string;
18
21
  admission: Open<'admitted' | 'unavailable'>;
19
22
  offline: Open<'locked' | 'open'>;
20
23
  };
21
- export type DiscoveredRoom = {
22
- name: string;
23
- locator: string;
24
- handle: string;
25
- roomVersion: string;
26
- operations: OperationScopes;
27
- replica: ReplicaAdmission;
28
- typedSelection?: TypedSelection;
29
- providerOwnedPaths: readonly string[];
24
+ export type RoomDeclaration = {
25
+ readonly name: string;
26
+ readonly handle: string;
27
+ readonly operations: OperationScopes;
28
+ readonly replica: ReplicaAdmission;
29
+ readonly typedSelection: TypedSelection | null;
30
+ readonly providerOwnedPaths: readonly string[];
31
+ readonly authoredPaths: readonly string[];
32
+ };
33
+ export type DiscoveredRoom = RoomDeclaration & {
34
+ readonly locator: string;
35
+ readonly roomVersion: string;
30
36
  };
31
37
  export type Capability = {
32
38
  name: string;
33
39
  limits?: readonly ProviderLimit[];
34
40
  actions?: readonly ActionDeclaration[];
35
- conversationAgents?: ConversationAgents;
36
- };
37
- export type ConversationAgents = {
38
- locator: string;
39
- type: string;
40
- identity: string;
41
- name: string;
42
- retired?: string;
43
41
  };
44
42
  export type ListedConversation = {
45
43
  conversation: string;
@@ -49,8 +47,11 @@ export type ListedConversation = {
49
47
  finished: string | null;
50
48
  outcome: string | null;
51
49
  waiting: boolean;
50
+ newest: string | null;
51
+ processEnded: string | null;
52
+ subject: string | null;
52
53
  };
53
- export type ConversationAction = 'conversation.create' | 'conversation.send' | 'conversation.attach' | 'conversation.answer' | 'conversation.interrupt' | 'conversation.kill' | 'conversation.cancel' | 'conversation.delete' | 'conversation.history';
54
+ export type ConversationAction = 'conversations/create' | 'conversations/send' | 'conversations/interaction/answer' | 'conversations/interrupt' | 'conversations/kill' | 'conversations/delete' | 'conversations/take-out' | 'conversations/rename' | 'conversations/option/set' | 'conversations/retry' | 'agent-functions/decide';
54
55
  export type ConversationMessage = {
55
56
  identity: string;
56
57
  turn: string;
@@ -59,6 +60,7 @@ export type ConversationMessage = {
59
60
  };
60
61
  export type AcceptedMessage = ConversationMessage & {
61
62
  position: string;
63
+ change: string;
62
64
  };
63
65
  export type ConversationHistoryRequest = {
64
66
  conversations: readonly {
@@ -74,37 +76,10 @@ export type ConversationHistoryPage = {
74
76
  export type ConversationHistories = {
75
77
  histories: readonly ConversationHistoryPage[];
76
78
  };
77
- export type TurnContext = {
78
- used: number;
79
- window: number;
80
- };
81
79
  export type TurnOperation = {
82
80
  op: 'begin';
83
81
  at: string;
84
- } | {
85
- op: 'start';
86
- index: number;
87
- part: unknown;
88
- } | {
89
- op: 'append';
90
- index: number;
91
- text: string;
92
- } | {
93
- op: 'status';
94
- index: number;
95
- status: string;
96
- result: unknown;
97
- } | {
98
- op: 'count';
99
- index: number;
100
- count: number;
101
- } | {
102
- op: 'plan';
103
- index: number;
104
- entries: readonly unknown[];
105
- } | ({
106
- op: 'context';
107
- } & TurnContext);
82
+ } | Operation;
108
83
  export type ProcessCommand = {
109
84
  [field: string]: unknown;
110
85
  name: string;
@@ -166,6 +141,10 @@ export type ConversationEvent = {
166
141
  kind: 'starting';
167
142
  conversation: string;
168
143
  step: string | null;
144
+ } | {
145
+ kind: 'state';
146
+ conversation: string;
147
+ state: SessionState | null;
169
148
  } | {
170
149
  kind: 'link';
171
150
  conversation: string;
@@ -173,6 +152,7 @@ export type ConversationEvent = {
173
152
  } | {
174
153
  kind: 'deliveries';
175
154
  conversation: string;
155
+ waiting: readonly string[];
176
156
  unknown: readonly string[];
177
157
  } | {
178
158
  kind: 'accepted-message';
@@ -183,17 +163,77 @@ export type ConversationEvent = {
183
163
  conversation: string;
184
164
  } | {
185
165
  kind: 'list';
166
+ agents: readonly ListedAgent[];
186
167
  entries: readonly ListedConversation[];
168
+ whole: boolean;
169
+ more: boolean;
170
+ cursor: string | null;
187
171
  } | {
188
172
  kind: 'listed';
189
173
  entry: ListedConversation;
174
+ } | {
175
+ kind: 'agent';
176
+ agent: ListedAgent;
190
177
  } | {
191
178
  kind: 'unlisted';
192
179
  conversation: string;
193
180
  };
181
+ export type AgentEnvironment = {
182
+ identity: string;
183
+ name: string;
184
+ state: 'online' | 'offline';
185
+ };
186
+ export type ListedOwner = {
187
+ readonly user: string;
188
+ readonly name: string;
189
+ };
190
+ export type ListedSpaceRef = {
191
+ readonly space_ref: string;
192
+ readonly name: string;
193
+ };
194
+ export type RoomListEntry = {
195
+ readonly room_ref: string;
196
+ readonly room_handle: string;
197
+ readonly name: string;
198
+ readonly level: 'search' | 'open' | 'keep';
199
+ readonly access: 'owner' | 'manage' | 'write' | 'read' | 'public';
200
+ readonly owner: ListedOwner;
201
+ readonly created: string;
202
+ readonly archived?: string;
203
+ readonly exportable?: true;
204
+ readonly space?: ListedSpaceRef;
205
+ };
206
+ export type SpaceListEntry = ListedSpaceRef & {
207
+ readonly owner: ListedOwner;
208
+ readonly created: string;
209
+ readonly manages?: true;
210
+ };
211
+ export type RoomList = {
212
+ readonly rooms: readonly RoomListEntry[];
213
+ readonly spaces: readonly SpaceListEntry[];
214
+ };
215
+ export type ListedAgent = {
216
+ id: string;
217
+ name: string;
218
+ revision: number;
219
+ environment: string;
220
+ environment_name: string;
221
+ environment_connected: boolean;
222
+ launch_directory: string;
223
+ cli: string;
224
+ model: string | null;
225
+ effort: string | null;
226
+ mode: string | null;
227
+ base_instructions: string;
228
+ in_telegram: boolean;
229
+ created: string;
230
+ retired_at: string | null;
231
+ };
194
232
  export type ConversationStream = {
195
233
  replicate(conversations: readonly string[]): void;
234
+ hold(cursor: string | null): void;
196
235
  observe(notify: (event: ConversationEvent) => void): () => void;
236
+ history?(request: ConversationHistoryRequest): Promise<ActionResult>;
197
237
  };
198
238
  export type ActionDeclaration = {
199
239
  name: string;
@@ -213,7 +253,6 @@ export type HistoryRetention = {
213
253
  };
214
254
  export type Retention = {
215
255
  history: HistoryRetention;
216
- outcome: number;
217
256
  refreshHorizon: number;
218
257
  };
219
258
  export type Discovery = {
@@ -223,13 +262,11 @@ export type Discovery = {
223
262
  providerLimits: readonly ProviderLimit[];
224
263
  retention: Retention;
225
264
  member?: Member;
226
- covered?: readonly string[];
227
- };
228
- export type DiscoveryScope = {
229
- readonly authorities: readonly string[];
265
+ roomList?: RoomList;
230
266
  };
231
267
  export type TransportUncertainty = {
232
268
  kind: 'transport-uncertainty';
269
+ failure?: unknown;
233
270
  };
234
271
  export type RoomNotReadable = {
235
272
  kind: 'room-not-readable';
@@ -255,7 +292,7 @@ export type ContractUnavailable = ProviderRefusal & {
255
292
  export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
256
293
  export type PageToken = string;
257
294
  export type ChangeAuthor = {
258
- kind: Open<'user' | 'site' | 'inbox'>;
295
+ kind: Open<'user' | 'site' | 'inbox' | 'app'>;
259
296
  id: string;
260
297
  name: string;
261
298
  };
@@ -273,50 +310,45 @@ export type BinaryFile = {
273
310
  mediaType: string;
274
311
  sha256: string;
275
312
  };
276
- export type HeldFile = {
277
- readonly path: string;
278
- readonly revision: string;
279
- };
280
- export type HeldContent = {
281
- files(after: string | null, limit: number): Promise<readonly HeldFile[]>;
282
- contents(paths: readonly string[]): Promise<ReadonlyMap<string, {
283
- readonly content: string;
284
- readonly revision: string;
285
- }>>;
286
- };
287
313
  export type BootstrapRequest = {
288
314
  locator: string;
289
315
  selection: string;
290
316
  pageToken?: PageToken;
291
- held?: HeldContent;
292
- received?: Uint8Array;
293
317
  arriving?: (bytes: number) => void;
318
+ signal?: AbortSignal;
319
+ };
320
+ export type BootstrapPart = {
321
+ readonly id: string;
322
+ readonly bytes: number;
294
323
  };
295
324
  export type BootstrapInventory = {
296
- readonly parts: number;
297
325
  readonly bytes: number;
298
326
  };
299
327
  export type RoomModels = {
300
328
  collection?: ModelResult;
301
- selection?: ModelResult;
302
329
  };
303
330
  export type BootstrapPage = {
304
331
  kind: 'bootstrap';
305
332
  roomVersion: string;
306
333
  models?: RoomModels;
307
334
  documents: Readonly<Record<string, string>>;
335
+ facts: Readonly<Record<string, SavedFacts>>;
308
336
  revisions: Readonly<Record<string, string>>;
309
337
  fileIds?: Readonly<Record<string, string>>;
338
+ created?: Readonly<Record<string, string>>;
310
339
  changes: Readonly<Record<string, HeadChange>>;
311
340
  binaryFiles: Readonly<Record<string, BinaryFile>>;
312
341
  folders?: readonly string[];
313
342
  pageToken?: PageToken;
314
- inventory?: BootstrapInventory;
315
- received?: Uint8Array;
343
+ parts?: readonly BootstrapPart[];
344
+ bytes?: number;
345
+ };
346
+ export type NotReady = {
347
+ kind: 'not-ready';
316
348
  };
317
349
  export type BootstrapResult = BootstrapPage | {
318
350
  kind: 'beyond-horizon';
319
- } | AdapterFailure;
351
+ } | NotReady | AdapterFailure;
320
352
  export type RefreshRequest = {
321
353
  locator: string;
322
354
  selection: string;
@@ -328,8 +360,10 @@ export type RefreshPage = {
328
360
  roomVersion: string;
329
361
  models?: RoomModels;
330
362
  documents: Readonly<Record<string, string>>;
363
+ facts: Readonly<Record<string, SavedFacts>>;
331
364
  revisions: Readonly<Record<string, string>>;
332
365
  fileIds?: Readonly<Record<string, string>>;
366
+ created?: Readonly<Record<string, string>>;
333
367
  changes: Readonly<Record<string, HeadChange>>;
334
368
  binaryFiles: Readonly<Record<string, BinaryFile>>;
335
369
  removals: readonly string[];
@@ -367,27 +401,18 @@ export type AcceptedRoom = {
367
401
  };
368
402
  export type MutationResult = (AcceptedRoom & {
369
403
  kind: 'accepted';
370
- author?: string;
371
- time?: string;
372
404
  destination?: AcceptedRoom;
373
405
  }) | (ProviderRefusal & {
374
406
  kind: 'conflicted';
375
- roomVersion?: string;
376
407
  affected: Readonly<Record<string, string>>;
377
408
  }) | (ProviderRefusal & {
378
409
  kind: 'rejected';
379
410
  affected: Readonly<Record<string, string>>;
380
411
  }) | RetryableRefusal | {
381
412
  kind: 'write-halted';
382
- } | {
383
- kind: 'expired';
384
- restored?: true;
385
413
  } | AdapterFailure;
386
414
  export type HistoryAuthor = {
387
- kind: 'user';
388
- id: string;
389
- } | {
390
- kind: 'site' | 'inbox';
415
+ kind: 'user' | 'site' | 'inbox' | 'app';
391
416
  id: string;
392
417
  name: string;
393
418
  };
@@ -420,6 +445,10 @@ export type BinaryRequest = {
420
445
  path: string;
421
446
  revision: string;
422
447
  };
448
+ export type KeyedRequest = {
449
+ kind: 'key';
450
+ link: string;
451
+ };
423
452
  export type BinaryResult = {
424
453
  kind: 'binary';
425
454
  body: ReadableStream<Uint8Array>;
@@ -432,6 +461,25 @@ export type BinaryLinkResult = {
432
461
  kind: 'link';
433
462
  url: string;
434
463
  name: string;
464
+ mediaType?: string;
465
+ } | (ProviderRefusal & {
466
+ kind: 'rejected';
467
+ }) | AdapterFailure;
468
+ export type AttachRequest = {
469
+ locator?: string;
470
+ name: string;
471
+ mediaType: string;
472
+ byteLength: number;
473
+ sha256: string;
474
+ blob: Blob;
475
+ };
476
+ export type AttachResult = {
477
+ kind: 'attached';
478
+ path: string;
479
+ revision: string;
480
+ } | {
481
+ kind: 'linked';
482
+ link: string;
435
483
  } | (ProviderRefusal & {
436
484
  kind: 'rejected';
437
485
  }) | AdapterFailure;
@@ -447,68 +495,88 @@ export type ActionResult = {
447
495
  kind: 'action';
448
496
  result: unknown;
449
497
  at?: RoomVersionAt;
498
+ } | (ProviderRefusal & {
499
+ kind: 'rejected';
500
+ reset?: string;
501
+ }) | AdapterFailure;
502
+ export type SearchHit = {
503
+ room: string;
504
+ path: string;
505
+ line?: number;
506
+ snippet?: string;
507
+ };
508
+ export type SearchAsk = {
509
+ text: string;
510
+ rooms: readonly string[] | null;
511
+ };
512
+ export type SearchAnswer = {
513
+ kind: 'found';
514
+ documents: readonly SearchHit[];
450
515
  } | (ProviderRefusal & {
451
516
  kind: 'rejected';
452
517
  }) | AdapterFailure;
453
518
  export type HeldRoom = {
454
519
  locator: string;
520
+ roomVersion: string | null;
521
+ };
522
+ export type RoomChange = {
523
+ kind: 'room-change';
524
+ locator: string;
525
+ from: string | null;
455
526
  roomVersion: string;
527
+ read(): Promise<RefreshPage>;
528
+ };
529
+ export type AuthorityChange = {
530
+ kind: 'authority-changed';
531
+ rooms: readonly DiscoveredRoom[];
532
+ left: readonly string[];
533
+ member?: Member;
534
+ roomList?: RoomList & {
535
+ readonly left: readonly string[];
536
+ };
456
537
  };
457
- export type HeldRevisions = (locator: string, paths: readonly string[]) => Promise<ReadonlyMap<string, string>>;
458
538
  export type RoomStreamEvent = {
459
539
  kind: 'opened';
540
+ } | {
541
+ kind: 'discovered';
542
+ discovery: Discovery;
460
543
  } | {
461
544
  kind: 'closed';
462
545
  revoked: boolean;
463
546
  lost: boolean;
547
+ authorityChanged: boolean;
464
548
  } | {
465
- kind: 'opening';
549
+ kind: 'caught-up';
466
550
  expired: readonly string[];
467
551
  } | {
468
- kind: 'authority-changed';
469
- scope?: DiscoveryScope;
470
- } | {
471
- kind: 'room-version';
472
- locator: string;
473
- roomVersion: string;
474
- };
475
- export type KeptReceipt = {
476
- key: string;
477
- head: unknown;
478
- };
479
- export type StreamReceipts = {
480
- heads(): Promise<readonly KeptReceipt[]>;
481
- parts(key: string, count: number): Promise<readonly unknown[]>;
482
- keep(key: string, head: unknown, part?: {
483
- index: number;
484
- value: unknown;
485
- }): Promise<void>;
486
- drop(keys: readonly string[]): Promise<void>;
487
- };
552
+ kind: 'reported';
553
+ } | AuthorityChange | RoomChange;
488
554
  export type RoomStream = {
489
555
  hold(rooms: readonly HeldRoom[]): void;
490
- reopen(): void;
491
- published(locator: string, roomVersion: string): void;
492
- observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts, revisions: HeldRevisions): () => void;
556
+ observe(notify: (event: RoomStreamEvent) => void): () => void;
493
557
  };
558
+ export type PathRule = (path: string) => boolean;
494
559
  export type Adapter = {
495
560
  readonly localSaves?: true;
496
- readonly exhaustiveDiscovery?: true;
497
- readonly roomTypes?: string;
498
- readonly nameableRoomTypes?: readonly string[];
561
+ readonly roomTypes?: VerifiedModel;
562
+ readonly typedPaths?: readonly TypedPath[];
563
+ readonly pathRule?: PathRule;
564
+ readonly unkeptReads?: readonly string[];
565
+ readonly leadingReads?: readonly string[];
499
566
  authorize(): Promise<Authorization>;
500
- discover(authorization: Authorization, scope?: DiscoveryScope): Promise<DiscoverResult>;
567
+ discover?(authorization: Authorization): Promise<DiscoverResult>;
501
568
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
502
- refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
569
+ refresh?(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
503
570
  mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
504
571
  history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
505
572
  binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
506
- link(authorization: Authorization, request: BinaryRequest): Promise<BinaryLinkResult>;
573
+ link(authorization: Authorization, request: BinaryRequest | KeyedRequest): Promise<BinaryLinkResult>;
574
+ attach(authorization: Authorization, request: AttachRequest): Promise<AttachResult>;
507
575
  action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
576
+ search?(authorization: Authorization, request: SearchAsk): Promise<SearchAnswer>;
508
577
  reached(locator: string, roomVersion: string, target: string): boolean;
509
578
  follows(locator: string, roomVersion: string, next: string): boolean;
510
579
  roomStream?: RoomStream;
511
580
  conversations?: ConversationStream;
512
581
  serviceMode?: ServiceModeSignal;
513
582
  };
514
- export {};
@@ -0,0 +1,6 @@
1
+ import { type VerifiedModel } from '../mdmodel/index.js';
2
+ import type { ModelResult, ModelState } from './model.js';
3
+ export declare const NO_ROOM_TYPES: VerifiedModel;
4
+ export declare function builtInModel(roomTypes: VerifiedModel): ModelState;
5
+ export declare function schemaTypes(schema: string | null, roomTypes: VerifiedModel): VerifiedModel['types'];
6
+ export declare function attachedModel(answer: ModelResult, roomTypes: VerifiedModel): ModelState;