@agentshouse/app-bridge 0.1.0-c58a055eeaa71 → 0.1.0-c599cdbcc172a
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/README.md +4 -2
- package/dist/calls.d.ts +953 -0
- package/dist/calls.js +1 -0
- package/dist/index.d.ts +32 -11
- package/dist/mdmodel/blocks.d.ts +10 -0
- package/dist/mdmodel/condition.d.ts +148 -0
- package/dist/mdmodel/definition.d.ts +79 -0
- package/dist/mdmodel/divide.d.ts +2 -0
- package/dist/mdmodel/document.d.ts +15 -0
- package/dist/mdmodel/fields.d.ts +5 -0
- package/dist/mdmodel/index.d.ts +18 -0
- package/dist/mdmodel/paths.d.ts +17 -0
- package/dist/mdmodel/profile.d.ts +5 -0
- package/dist/mdmodel/project.d.ts +21 -0
- package/dist/mdmodel/references.d.ts +3 -0
- package/dist/mdmodel/types.d.ts +143 -0
- package/dist/mdmodel/validate.d.ts +8 -0
- package/dist/mdmodel/version.d.ts +1 -0
- package/dist/mdmodel/yaml.d.ts +55 -0
- package/dist/mdruntime/adapter.d.ts +492 -0
- package/dist/mdruntime/binary.d.ts +22 -0
- package/dist/mdruntime/change-set.d.ts +34 -0
- package/dist/mdruntime/change.d.ts +88 -0
- package/dist/mdruntime/client.d.ts +86 -0
- package/dist/mdruntime/collection.d.ts +39 -0
- package/dist/mdruntime/connection.d.ts +146 -0
- package/dist/mdruntime/conversation.d.ts +110 -0
- package/dist/mdruntime/durability.d.ts +14 -0
- package/dist/mdruntime/failure.d.ts +12 -0
- package/dist/mdruntime/file.d.ts +19 -0
- package/dist/mdruntime/model.d.ts +57 -0
- package/dist/mdruntime/observation.d.ts +31 -0
- package/dist/mdruntime/open.d.ts +1 -0
- package/dist/mdruntime/outcome.d.ts +52 -0
- package/dist/mdruntime/overlay.d.ts +28 -0
- package/dist/mdruntime/query.d.ts +273 -0
- package/dist/mdruntime/reach.d.ts +44 -0
- package/dist/mdruntime/readiness.d.ts +52 -0
- package/dist/mdruntime/recovery.d.ts +24 -0
- package/dist/mdruntime/replica.d.ts +50 -0
- package/dist/mdruntime/room-draft.d.ts +155 -0
- package/dist/mdruntime/rows.d.ts +38 -0
- package/dist/mdruntime/save.d.ts +65 -0
- package/dist/mdruntime/search.d.ts +104 -0
- package/dist/mdruntime/seed.d.ts +15 -0
- package/dist/mdruntime/shared.d.ts +13 -0
- package/dist/mdruntime/status.d.ts +26 -0
- package/dist/mdruntime/store.d.ts +174 -0
- package/dist/mdruntime/transfer.d.ts +9 -0
- package/dist/mdruntime/turn.d.ts +8 -0
- package/dist/mdruntime/wire.d.ts +222 -0
- package/dist/test-host.d.ts +5 -5
- package/dist/test-host.js +57 -22
- package/docs/families.md +49 -7
- package/package.json +1 -4
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult } from './connection.js';
|
|
2
|
+
import type { Member, ServiceMode } from './adapter.js';
|
|
3
|
+
import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
4
|
+
import { type Observation } from './observation.js';
|
|
5
|
+
import type { BinaryReference } from './binary.js';
|
|
6
|
+
import type { BinaryAnswer, BinaryLinkAnswer, CallResult, HistoryAnswer, Offline, QueueEntry } from './outcome.js';
|
|
7
|
+
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
|
|
8
|
+
import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
|
|
9
|
+
import type { SearchRequest, SearchResult } from './search.js';
|
|
10
|
+
import type { Readiness } from './readiness.js';
|
|
11
|
+
import type { SyncStatus } from './status.js';
|
|
12
|
+
import { type RuntimePort } from './wire.js';
|
|
13
|
+
export type MdRuntimeClient = {
|
|
14
|
+
rooms(): Promise<readonly AppRoom[]>;
|
|
15
|
+
query: {
|
|
16
|
+
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
17
|
+
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
18
|
+
};
|
|
19
|
+
search(request: SearchRequest): Promise<SearchResult>;
|
|
20
|
+
types(locator: string): Promise<RoomSchemas>;
|
|
21
|
+
roomDraft: {
|
|
22
|
+
list(): Promise<readonly RoomDraft[]>;
|
|
23
|
+
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
24
|
+
write(room: string, path: string, revision: string | null, parts: RoomDraftParts): Promise<RoomDraftWrite>;
|
|
25
|
+
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
26
|
+
};
|
|
27
|
+
save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
|
|
28
|
+
saveParts(room: string, parts: readonly SavedParts[]): Promise<SaveResult>;
|
|
29
|
+
presentation: {
|
|
30
|
+
read(): Promise<unknown>;
|
|
31
|
+
write(value: unknown): Promise<void>;
|
|
32
|
+
edit(members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
conversation: {
|
|
35
|
+
list(): Promise<readonly ConversationEntry[]>;
|
|
36
|
+
read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
|
|
37
|
+
create(input: unknown): Promise<CallResult>;
|
|
38
|
+
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
39
|
+
answer(conversation: string, answer: unknown): Promise<CallResult>;
|
|
40
|
+
interrupt(conversation: string): Promise<CallResult>;
|
|
41
|
+
kill(conversation: string): Promise<CallResult>;
|
|
42
|
+
cancel(conversation: string, turn: string): Promise<CallResult>;
|
|
43
|
+
delete(conversation: string): Promise<CallResult>;
|
|
44
|
+
};
|
|
45
|
+
chatDraft: {
|
|
46
|
+
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
47
|
+
prepend(conversation: string, draft: ChatDraft): Promise<void>;
|
|
48
|
+
discard(conversation: string): Promise<void>;
|
|
49
|
+
};
|
|
50
|
+
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
51
|
+
binaryFile: {
|
|
52
|
+
read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
|
|
53
|
+
link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
|
|
54
|
+
readReference(reference: BinaryReference): Promise<BinaryAnswer>;
|
|
55
|
+
};
|
|
56
|
+
call(name: string, input: unknown): Promise<CallResult>;
|
|
57
|
+
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
58
|
+
log(): Promise<string>;
|
|
59
|
+
persistence(): Promise<boolean>;
|
|
60
|
+
retry(): Promise<void>;
|
|
61
|
+
observe: {
|
|
62
|
+
(topic: 'deployment-facts'): Promise<Observation<unknown>>;
|
|
63
|
+
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
64
|
+
(topic: 'readiness'): Promise<Observation<Readiness>>;
|
|
65
|
+
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
66
|
+
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
67
|
+
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
68
|
+
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
69
|
+
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
70
|
+
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
71
|
+
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
72
|
+
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
73
|
+
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
74
|
+
(topic: 'presentation'): Promise<Observation<unknown>>;
|
|
75
|
+
(topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
|
|
76
|
+
(topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
|
|
77
|
+
(topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
|
|
78
|
+
};
|
|
79
|
+
reauthorize(): Promise<void>;
|
|
80
|
+
settled(): Promise<void>;
|
|
81
|
+
};
|
|
82
|
+
export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
|
|
83
|
+
export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
|
|
84
|
+
export type { Observation } from './observation.js';
|
|
85
|
+
export type { Open } from './open.js';
|
|
86
|
+
export { unanswered, type RuntimePort, type WireMember } from './wire.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Document, type Frontmatter, type Validation } from '../mdmodel/index.js';
|
|
2
|
+
import { type ModelState } from './model.js';
|
|
3
|
+
import type { MdModelIdentity } from './adapter.js';
|
|
4
|
+
import { type Paths } from './shared.js';
|
|
5
|
+
import type { Refused } from './transfer.js';
|
|
6
|
+
import { type Later } from './turn.js';
|
|
7
|
+
export declare const MD_MODEL: MdModelIdentity;
|
|
8
|
+
export type Collection = {
|
|
9
|
+
text: Readonly<Record<string, string>>;
|
|
10
|
+
composition: Composition;
|
|
11
|
+
document(path: string): Document | undefined;
|
|
12
|
+
};
|
|
13
|
+
export type Composition = {
|
|
14
|
+
model: ModelState;
|
|
15
|
+
selection: {
|
|
16
|
+
roots: readonly string[];
|
|
17
|
+
model: ModelState;
|
|
18
|
+
} | null;
|
|
19
|
+
};
|
|
20
|
+
export declare function governing(composition: Composition, path: string): ModelState;
|
|
21
|
+
export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition, previous?: Collection): Collection;
|
|
22
|
+
export declare function collecting(text: Readonly<Record<string, string>>, composition: Composition, previous?: Collection): Generator<number, Collection, void>;
|
|
23
|
+
export declare function passingFrontmatter(collection: Collection, path: string): Frontmatter | undefined;
|
|
24
|
+
export declare function documentsOf(collection: Collection): Generator<readonly [string, Document]>;
|
|
25
|
+
export declare function unreadable(text: Readonly<Record<string, string>>, previous?: Readonly<Record<string, string>>): Generator<number, Refused | null, void>;
|
|
26
|
+
export declare function validRoot(root: unknown): root is string;
|
|
27
|
+
export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition): Generator<number, Validation, void>;
|
|
28
|
+
type Held = {
|
|
29
|
+
text: Paths<string>;
|
|
30
|
+
binaries: Paths<unknown>;
|
|
31
|
+
};
|
|
32
|
+
export declare function indexReferrers(held: Held, composition: Composition): Later<void>;
|
|
33
|
+
export declare function referencesIndexed(held: Held, composition: Composition): boolean;
|
|
34
|
+
export declare function referring(held: Held, composition: Composition, targets: Iterable<string>): ReadonlySet<string> | null;
|
|
35
|
+
export declare function available(composition: Composition): boolean;
|
|
36
|
+
export declare function changedCleanly(next: Held, previous: Held & {
|
|
37
|
+
composition: Composition;
|
|
38
|
+
}, composition: Composition): Generator<number, boolean, void>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { type TypesResult } from './model.js';
|
|
2
|
+
import { type Observation } from './observation.js';
|
|
3
|
+
import { type DocumentQuery, type DocumentResult, type GroupQuery, type GroupResult, type PendingResult } from './query.js';
|
|
4
|
+
import { type EntrySeed } from './seed.js';
|
|
5
|
+
import { type SearchRequest, type SearchResult } from './search.js';
|
|
6
|
+
import { type Adapter, type Authorization, type Member, type ProviderRefusal, type ServiceMode } from './adapter.js';
|
|
7
|
+
import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
|
|
8
|
+
import { type WrittenBy } from './change.js';
|
|
9
|
+
import type { Open } from './open.js';
|
|
10
|
+
import { type BinaryReference } from './binary.js';
|
|
11
|
+
import { type BinaryAnswer, type BinaryLinkAnswer, type CallResult, type HistoryAnswer, type QueueEntry } from './outcome.js';
|
|
12
|
+
import { type Recovery } from './recovery.js';
|
|
13
|
+
import { type SaveRefusal } from './save.js';
|
|
14
|
+
import { type RoomDraft, type RoomDraftParts, type RoomDraftWrite } from './room-draft.js';
|
|
15
|
+
import { type SyncStatus } from './status.js';
|
|
16
|
+
import { type RuntimeShell } from './durability.js';
|
|
17
|
+
import { type CapacityCause, type CodeAvailability, type Persistence, type Readiness, type SearchObligation } from './readiness.js';
|
|
18
|
+
import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
|
|
19
|
+
export type AppTypedSelection = {
|
|
20
|
+
roots: readonly string[];
|
|
21
|
+
model: TypesResult;
|
|
22
|
+
};
|
|
23
|
+
export type AppRoom = {
|
|
24
|
+
name: string;
|
|
25
|
+
locator: string;
|
|
26
|
+
handle: string;
|
|
27
|
+
operations: import('./adapter.js').OperationScopes;
|
|
28
|
+
replica: import('./adapter.js').ReplicaAdmission;
|
|
29
|
+
model: TypesResult;
|
|
30
|
+
typedSelection: AppTypedSelection | null;
|
|
31
|
+
providerOwnedPaths: readonly string[];
|
|
32
|
+
roomVersion: string | null;
|
|
33
|
+
documents: number;
|
|
34
|
+
synchronizationAvailable: boolean;
|
|
35
|
+
refusal: ProviderRefusal | null;
|
|
36
|
+
};
|
|
37
|
+
export type RoomSchemas = {
|
|
38
|
+
collection: TypesResult;
|
|
39
|
+
typedSelection: TypesResult | null;
|
|
40
|
+
};
|
|
41
|
+
type RefusalReason = 'missing-required-guarantee' | 'revoked-authorization';
|
|
42
|
+
export type ConnectionRefusalCode = Open<RefusalReason>;
|
|
43
|
+
export type ConnectionRefusal = {
|
|
44
|
+
code: ConnectionRefusalCode;
|
|
45
|
+
retryable: boolean;
|
|
46
|
+
reauthorizationOffered: boolean;
|
|
47
|
+
refusal: ProviderRefusal | null;
|
|
48
|
+
};
|
|
49
|
+
export type MdRuntimeOptions = {
|
|
50
|
+
adapter: Adapter;
|
|
51
|
+
shell: RuntimeShell;
|
|
52
|
+
authorization?: Authorization;
|
|
53
|
+
signal?: AbortSignal;
|
|
54
|
+
recovery?: Recovery;
|
|
55
|
+
};
|
|
56
|
+
export type SaveResult = {
|
|
57
|
+
outcome: 'saved';
|
|
58
|
+
identifier: string;
|
|
59
|
+
} | ({
|
|
60
|
+
outcome: 'refused';
|
|
61
|
+
} & SaveRefusal);
|
|
62
|
+
export type SavedRoomDraft = {
|
|
63
|
+
readonly path: string;
|
|
64
|
+
readonly revision: string;
|
|
65
|
+
};
|
|
66
|
+
export type SavedParts = {
|
|
67
|
+
readonly path: string;
|
|
68
|
+
readonly parts: RoomDraftParts;
|
|
69
|
+
};
|
|
70
|
+
export type RoomDraftSurface = {
|
|
71
|
+
list(): Promise<readonly RoomDraft[]>;
|
|
72
|
+
read(room: string, path: string): RoomDraft | null;
|
|
73
|
+
write(room: string, path: string, revision: string | null, parts: unknown): Promise<RoomDraftWrite>;
|
|
74
|
+
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
75
|
+
};
|
|
76
|
+
export type PresentationSurface = {
|
|
77
|
+
read(app: string): Promise<unknown>;
|
|
78
|
+
write(app: string, value: unknown): Promise<void>;
|
|
79
|
+
edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
80
|
+
};
|
|
81
|
+
export type BinaryFileSurface = {
|
|
82
|
+
read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
|
|
83
|
+
link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
|
|
84
|
+
readReference(reference: BinaryReference): Promise<BinaryAnswer>;
|
|
85
|
+
};
|
|
86
|
+
export type HistoryQuery = {
|
|
87
|
+
revision?: string;
|
|
88
|
+
pageToken?: string;
|
|
89
|
+
};
|
|
90
|
+
export type MdRuntime = {
|
|
91
|
+
loaded(): Promise<void>;
|
|
92
|
+
rooms(): readonly AppRoom[];
|
|
93
|
+
query: {
|
|
94
|
+
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
95
|
+
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
96
|
+
};
|
|
97
|
+
search(request: SearchRequest): Promise<SearchResult>;
|
|
98
|
+
types(locator: string): RoomSchemas;
|
|
99
|
+
roomDraft: RoomDraftSurface;
|
|
100
|
+
conversation: ConversationSurface;
|
|
101
|
+
chatDraft: ChatDraftSurface;
|
|
102
|
+
presentation: PresentationSurface;
|
|
103
|
+
save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
|
|
104
|
+
saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
|
|
105
|
+
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
106
|
+
binaryFile: BinaryFileSurface;
|
|
107
|
+
call(name: string, input: unknown): Promise<CallResult>;
|
|
108
|
+
reached(locator: string, roomVersion: string, path?: string): boolean;
|
|
109
|
+
log(): string;
|
|
110
|
+
persistence(): boolean;
|
|
111
|
+
retry(): Promise<void>;
|
|
112
|
+
observe: {
|
|
113
|
+
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
114
|
+
(topic: 'readiness'): Promise<Observation<Readiness>>;
|
|
115
|
+
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
116
|
+
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
117
|
+
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
118
|
+
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
119
|
+
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
120
|
+
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
121
|
+
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
122
|
+
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
123
|
+
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
124
|
+
(topic: 'presentation', app: string): Promise<Observation<unknown>>;
|
|
125
|
+
(topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
|
|
126
|
+
(topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
|
|
127
|
+
(topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
|
|
128
|
+
};
|
|
129
|
+
reauthorize(): Promise<void>;
|
|
130
|
+
};
|
|
131
|
+
export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents';
|
|
132
|
+
export type ReadinessPort = {
|
|
133
|
+
readonly target: string;
|
|
134
|
+
readonly code: CodeAvailability;
|
|
135
|
+
readonly capacity: CapacityCause | null;
|
|
136
|
+
readonly search: SearchObligation;
|
|
137
|
+
};
|
|
138
|
+
export type ComposedRuntime = RuntimeView & {
|
|
139
|
+
seed(entry: EntrySeed): void;
|
|
140
|
+
stop(): Promise<void>;
|
|
141
|
+
lose(locators: readonly string[]): Promise<void>;
|
|
142
|
+
persisted(answer: Persistence): void;
|
|
143
|
+
within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
|
|
144
|
+
};
|
|
145
|
+
export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
|
|
146
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { ConversationAction, ConversationAgents, ConversationEvent, ConversationMessage, ConversationStream, ProcessCommand, SessionOption, TurnContext } from './adapter.js';
|
|
2
|
+
import { type ChangeSet } from './change-set.js';
|
|
3
|
+
import { type ChatDraftFile } from './file.js';
|
|
4
|
+
import type { Open } from './open.js';
|
|
5
|
+
import { type CallResult, type Offline } from './outcome.js';
|
|
6
|
+
import type { DocumentResult, PendingResult } from './query.js';
|
|
7
|
+
import type { CycleProgress } from './status.js';
|
|
8
|
+
import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
|
|
9
|
+
export type ConversationState = Open<'working' | 'asking' | 'idle'>;
|
|
10
|
+
export type ConversationEntry = {
|
|
11
|
+
conversation: string;
|
|
12
|
+
agent: {
|
|
13
|
+
identity: string;
|
|
14
|
+
name: string | null;
|
|
15
|
+
};
|
|
16
|
+
name: string;
|
|
17
|
+
created: string;
|
|
18
|
+
finished: string | null;
|
|
19
|
+
outcome: string | null;
|
|
20
|
+
state: ConversationState;
|
|
21
|
+
started: string | null;
|
|
22
|
+
};
|
|
23
|
+
export type ConversationAgent = {
|
|
24
|
+
identity: string;
|
|
25
|
+
name: string;
|
|
26
|
+
};
|
|
27
|
+
export type RunningTurn = {
|
|
28
|
+
turn: string;
|
|
29
|
+
started: string | null;
|
|
30
|
+
parts: readonly unknown[];
|
|
31
|
+
context: TurnContext | null;
|
|
32
|
+
};
|
|
33
|
+
export type ChatDraft = {
|
|
34
|
+
text: string;
|
|
35
|
+
files: readonly ChatDraftFile[];
|
|
36
|
+
};
|
|
37
|
+
export type ConversationOptions = {
|
|
38
|
+
limit?: number;
|
|
39
|
+
after?: string;
|
|
40
|
+
total?: true;
|
|
41
|
+
};
|
|
42
|
+
export type ConversationView = {
|
|
43
|
+
conversation: string;
|
|
44
|
+
messages: readonly ConversationMessage[];
|
|
45
|
+
next?: string;
|
|
46
|
+
total?: number;
|
|
47
|
+
turn: RunningTurn | null;
|
|
48
|
+
questions: readonly unknown[];
|
|
49
|
+
process: {
|
|
50
|
+
running: boolean;
|
|
51
|
+
} | null;
|
|
52
|
+
commands: readonly ProcessCommand[];
|
|
53
|
+
options: readonly SessionOption[];
|
|
54
|
+
chatDraft: (ChatDraft & {
|
|
55
|
+
readonly revision: string;
|
|
56
|
+
}) | null;
|
|
57
|
+
};
|
|
58
|
+
export type ConversationSurface = {
|
|
59
|
+
list(): Promise<readonly ConversationEntry[]>;
|
|
60
|
+
read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
|
|
61
|
+
create(input: unknown): Promise<CallResult>;
|
|
62
|
+
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
63
|
+
answer(conversation: string, answer: unknown): Promise<CallResult>;
|
|
64
|
+
interrupt(conversation: string): Promise<CallResult>;
|
|
65
|
+
kill(conversation: string): Promise<CallResult>;
|
|
66
|
+
cancel(conversation: string, turn: string): Promise<CallResult>;
|
|
67
|
+
delete(conversation: string): Promise<CallResult>;
|
|
68
|
+
};
|
|
69
|
+
export type ChatDraftSurface = {
|
|
70
|
+
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
71
|
+
prepend(conversation: string, draft: ChatDraft): Promise<void>;
|
|
72
|
+
discard(conversation: string): Promise<void>;
|
|
73
|
+
};
|
|
74
|
+
export type ConversationDependencies = {
|
|
75
|
+
agents(): ConversationAgents | undefined;
|
|
76
|
+
documents(agents: ConversationAgents): Promise<DocumentResult | PendingResult>;
|
|
77
|
+
call(name: ConversationAction, input: unknown): Promise<CallResult>;
|
|
78
|
+
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
79
|
+
stream(): ConversationStream | undefined;
|
|
80
|
+
publish(set: ChangeSet): void;
|
|
81
|
+
online(): boolean;
|
|
82
|
+
closed(): boolean;
|
|
83
|
+
unanswered(): void;
|
|
84
|
+
expired(operation: string): boolean;
|
|
85
|
+
};
|
|
86
|
+
export type ConversationStore = {
|
|
87
|
+
surface: ConversationSurface;
|
|
88
|
+
chatDraft: ChatDraftSurface;
|
|
89
|
+
hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[]): void;
|
|
90
|
+
reconcile(): Promise<void>;
|
|
91
|
+
catchUp(progress: CycleProgress): Promise<void>;
|
|
92
|
+
resend(progress: CycleProgress): Promise<void>;
|
|
93
|
+
current(): boolean;
|
|
94
|
+
known(): boolean;
|
|
95
|
+
reconnected(): void;
|
|
96
|
+
reopened(): void;
|
|
97
|
+
lost(): void;
|
|
98
|
+
watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
|
|
99
|
+
watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
|
|
100
|
+
watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
|
|
101
|
+
changed(set: ChangeSet): void;
|
|
102
|
+
receive(event: ConversationEvent): boolean;
|
|
103
|
+
searchable(): readonly string[];
|
|
104
|
+
acquired(conversation: string): boolean;
|
|
105
|
+
close(): void;
|
|
106
|
+
};
|
|
107
|
+
export declare function unheldView(conversation: string): ConversationView;
|
|
108
|
+
export declare const SESSION_STARTED = "Session started";
|
|
109
|
+
export declare function newChat(agent: string): string;
|
|
110
|
+
export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Persistence } from './readiness.js';
|
|
2
|
+
export type StorageEstimate = {
|
|
3
|
+
readonly usage: number;
|
|
4
|
+
readonly quota: number;
|
|
5
|
+
};
|
|
6
|
+
export type RuntimeShell = {
|
|
7
|
+
persistence: Persistence;
|
|
8
|
+
generation: string | null;
|
|
9
|
+
keepGeneration(value: string): void | Promise<void>;
|
|
10
|
+
dropGeneration(): void | Promise<void>;
|
|
11
|
+
estimate?(): Promise<StorageEstimate | null>;
|
|
12
|
+
};
|
|
13
|
+
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
|
14
|
+
export declare function nextGeneration(stored: string | null, reported: string | null): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type RuntimeError = Error & {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
readonly retryable: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type Described = {
|
|
6
|
+
message: string;
|
|
7
|
+
code: string;
|
|
8
|
+
retryable: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function runtimeError(code: string, message?: string, retryable?: boolean): RuntimeError;
|
|
11
|
+
export declare function failed(error: unknown): RuntimeError;
|
|
12
|
+
export declare function described(error: unknown): Described;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ChatDraftFile = {
|
|
2
|
+
name: string;
|
|
3
|
+
blob: Blob;
|
|
4
|
+
};
|
|
5
|
+
export type FileDeclaration = {
|
|
6
|
+
name: string;
|
|
7
|
+
mediaType: string;
|
|
8
|
+
byteLength: number;
|
|
9
|
+
contentHash: string;
|
|
10
|
+
width?: number;
|
|
11
|
+
height?: number;
|
|
12
|
+
};
|
|
13
|
+
export type Extent = {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
};
|
|
17
|
+
export declare function extentOf(bytes: Uint8Array): Extent | null;
|
|
18
|
+
export declare function hexDigest(digest: ArrayBuffer): string;
|
|
19
|
+
export declare function declaredFile(file: ChatDraftFile): Promise<FileDeclaration>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Definition, ValueFacts, VerifiedModel } from '../mdmodel/index.js';
|
|
2
|
+
import type { Open } from './open.js';
|
|
3
|
+
export type ModelIdentity = {
|
|
4
|
+
identity: string;
|
|
5
|
+
version: string;
|
|
6
|
+
};
|
|
7
|
+
export type ModelSnapshot = ModelIdentity & {
|
|
8
|
+
schema: string | null;
|
|
9
|
+
revision: string | null;
|
|
10
|
+
};
|
|
11
|
+
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired' | 'invalid'>;
|
|
12
|
+
export type ModelResult = {
|
|
13
|
+
kind: 'model';
|
|
14
|
+
snapshot: ModelSnapshot;
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'model-unavailable';
|
|
17
|
+
reason: ModelUnavailableReason;
|
|
18
|
+
};
|
|
19
|
+
export type MdType = Definition;
|
|
20
|
+
export type ModelState = {
|
|
21
|
+
status: 'unavailable';
|
|
22
|
+
reason: ModelUnavailableReason;
|
|
23
|
+
schema?: string | null;
|
|
24
|
+
revision?: string | null;
|
|
25
|
+
} | {
|
|
26
|
+
status: 'current' | 'cached';
|
|
27
|
+
snapshot: ModelSnapshot;
|
|
28
|
+
verifiedWith: ModelIdentity;
|
|
29
|
+
types: VerifiedModel['types'];
|
|
30
|
+
};
|
|
31
|
+
export type TypesResult = {
|
|
32
|
+
status: Open<'unavailable'>;
|
|
33
|
+
reason: ModelUnavailableReason;
|
|
34
|
+
types: null;
|
|
35
|
+
schema?: string | null;
|
|
36
|
+
revision?: string | null;
|
|
37
|
+
} | {
|
|
38
|
+
status: Open<'current' | 'cached'>;
|
|
39
|
+
identity: string;
|
|
40
|
+
version: string;
|
|
41
|
+
verifiedWith: ModelIdentity;
|
|
42
|
+
types: readonly MdType[];
|
|
43
|
+
schema: string | null;
|
|
44
|
+
revision: string | null;
|
|
45
|
+
};
|
|
46
|
+
export type ValidationReceipt = {
|
|
47
|
+
identity: string;
|
|
48
|
+
version: string;
|
|
49
|
+
source: Open<'current' | 'cached'>;
|
|
50
|
+
};
|
|
51
|
+
export declare const NO_MODEL: ModelState;
|
|
52
|
+
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
53
|
+
export declare function modelTypes(state: ModelState): TypesResult;
|
|
54
|
+
export declare function cached(state: ModelState): ModelState;
|
|
55
|
+
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
56
|
+
export declare function sameTyping(left: ModelState, right: ModelState): boolean;
|
|
57
|
+
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
2
|
+
export type Observation<T> = {
|
|
3
|
+
current(): T;
|
|
4
|
+
subscribe(listener: (value: T) => void): () => void;
|
|
5
|
+
close(): void;
|
|
6
|
+
};
|
|
7
|
+
export type RowKey = string | number;
|
|
8
|
+
export type KeyedResult = {
|
|
9
|
+
result: QueryResult;
|
|
10
|
+
keys: readonly RowKey[];
|
|
11
|
+
};
|
|
12
|
+
export type QueryChange = {
|
|
13
|
+
changed: readonly (readonly [RowKey, QueryDocument | QueryGroup])[];
|
|
14
|
+
removed: readonly RowKey[];
|
|
15
|
+
order: readonly RowKey[] | null;
|
|
16
|
+
coverage?: QueryCoverage;
|
|
17
|
+
next?: string | null;
|
|
18
|
+
total?: number;
|
|
19
|
+
};
|
|
20
|
+
export type QueryMessage = KeyedResult | QueryChange;
|
|
21
|
+
export type Observed = {
|
|
22
|
+
observation: Observation<unknown>;
|
|
23
|
+
receive(message: unknown): void;
|
|
24
|
+
end(): void;
|
|
25
|
+
};
|
|
26
|
+
export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
|
|
27
|
+
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
28
|
+
export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
|
|
29
|
+
export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
|
|
30
|
+
export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
31
|
+
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Open<Value extends string> = Value | (string & {});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ActionResult, AdapterFailure, BinaryLinkResult, BinaryResult, HistoryResult, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
|
+
import type { ChangeBatch } from './change.js';
|
|
3
|
+
type Refused<Kind extends string> = ProviderRefusal & {
|
|
4
|
+
kind: Kind;
|
|
5
|
+
};
|
|
6
|
+
export type Failure = Refused<'transport-uncertainty'> | Refused<'revoked-authorization'> | (Refused<'room-not-readable'> & {
|
|
7
|
+
locator: string;
|
|
8
|
+
}) | ScopedRefusal;
|
|
9
|
+
export type CallResult = {
|
|
10
|
+
kind: 'action';
|
|
11
|
+
result: unknown;
|
|
12
|
+
at?: RoomVersionAt;
|
|
13
|
+
} | Refused<'rejected'> | Refused<'undeclared'> | Failure;
|
|
14
|
+
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
15
|
+
kind: Failure['kind'];
|
|
16
|
+
}> | Failure;
|
|
17
|
+
export type BinaryAnswer = {
|
|
18
|
+
kind: 'binary';
|
|
19
|
+
blob: Blob;
|
|
20
|
+
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
21
|
+
export type BinaryLinkAnswer = {
|
|
22
|
+
kind: 'link';
|
|
23
|
+
url: string;
|
|
24
|
+
name: string;
|
|
25
|
+
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
26
|
+
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
27
|
+
export declare function binaryAnswer(result: BinaryResult): BinaryAnswer;
|
|
28
|
+
export declare function binaryLinkAnswer(result: BinaryLinkResult): BinaryLinkAnswer;
|
|
29
|
+
export type Offline = {
|
|
30
|
+
readonly kind: 'offline';
|
|
31
|
+
};
|
|
32
|
+
export declare const OFFLINE: Offline;
|
|
33
|
+
export declare const UNCERTAIN: Failure;
|
|
34
|
+
export declare function undeclared(name: string): CallResult;
|
|
35
|
+
export declare function failure(result: AdapterFailure): Failure;
|
|
36
|
+
export declare function calledResult(result: ActionResult): CallResult;
|
|
37
|
+
export declare function historyAnswer(result: HistoryResult): HistoryAnswer;
|
|
38
|
+
export type Submission = {
|
|
39
|
+
readonly state: 'waiting' | 'submitted';
|
|
40
|
+
} | {
|
|
41
|
+
readonly state: 'reset';
|
|
42
|
+
readonly reset: string;
|
|
43
|
+
};
|
|
44
|
+
export type QueueEntry = {
|
|
45
|
+
readonly batch: ChangeBatch;
|
|
46
|
+
} & (Submission | {
|
|
47
|
+
readonly state: 'local';
|
|
48
|
+
} | {
|
|
49
|
+
readonly state: 'accepted';
|
|
50
|
+
readonly roomVersion: string;
|
|
51
|
+
});
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BinaryFile, HeadChange } from './adapter.js';
|
|
2
|
+
import type { ChangeBatch } from './change.js';
|
|
3
|
+
export type Heads = {
|
|
4
|
+
revisions: Readonly<Record<string, string>>;
|
|
5
|
+
fileIds: Readonly<Record<string, string>>;
|
|
6
|
+
changes: Readonly<Record<string, HeadChange>>;
|
|
7
|
+
};
|
|
8
|
+
export type HeldBinary = ({
|
|
9
|
+
readonly state: 'accepted';
|
|
10
|
+
} & BinaryFile) | {
|
|
11
|
+
readonly state: 'pending';
|
|
12
|
+
readonly localId: string;
|
|
13
|
+
readonly byteLength: number;
|
|
14
|
+
readonly mediaType: string;
|
|
15
|
+
readonly sha256: string;
|
|
16
|
+
};
|
|
17
|
+
export type Layer = Heads & {
|
|
18
|
+
documents: Readonly<Record<string, string>>;
|
|
19
|
+
binaries: Readonly<Record<string, HeldBinary>>;
|
|
20
|
+
};
|
|
21
|
+
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Record<string, HeldBinary>;
|
|
22
|
+
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
23
|
+
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
24
|
+
export declare function overlay(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Layer;
|
|
25
|
+
export declare function sameLayerText(left: Layer, right: Layer): boolean;
|
|
26
|
+
export declare function sameText(left: Layer, right: Layer): Generator<number, boolean, void>;
|
|
27
|
+
export declare function changedPaths(left: Layer, right: Layer): ReadonlySet<string>;
|
|
28
|
+
export declare function overlayChanged(base: Layer, queue: readonly ChangeBatch[], previousBase: Layer, previousQueue: readonly ChangeBatch[], previousVisible: Layer): Layer;
|