@agentshouse/app-bridge 0.1.0-c43d9cbcf6c8d → 0.1.0-c44cf2cfcc09a
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 +6 -6
- package/dist/index.d.ts +143 -399
- package/dist/mdmodel/body.d.ts +84 -0
- package/dist/mdmodel/definition.d.ts +20 -10
- package/dist/mdmodel/document.d.ts +14 -7
- package/dist/mdmodel/event.d.ts +76 -0
- package/dist/mdmodel/facts.d.ts +14 -0
- package/dist/mdmodel/fields.d.ts +1 -1
- package/dist/mdmodel/index.d.ts +27 -13
- package/dist/mdmodel/kinds.d.ts +17 -0
- package/dist/mdmodel/markdown.d.ts +74 -0
- package/dist/mdmodel/paths.d.ts +10 -1
- package/dist/mdmodel/pattern.d.ts +9 -0
- package/dist/mdmodel/query/language.d.ts +253 -0
- package/dist/mdmodel/query/match.d.ts +13 -0
- package/dist/mdmodel/query/rows.d.ts +31 -0
- package/dist/mdmodel/query/sql.d.ts +38 -0
- package/dist/mdmodel/reserved.d.ts +5 -0
- package/dist/mdmodel/types.d.ts +21 -7
- package/dist/mdmodel/validate.d.ts +10 -6
- package/dist/mdruntime/actions.d.ts +25 -0
- package/dist/mdruntime/adapter.d.ts +71 -69
- package/dist/mdruntime/attached-model.d.ts +7 -0
- package/dist/mdruntime/bootstrap.d.ts +43 -0
- package/dist/mdruntime/cell.d.ts +5 -0
- package/dist/mdruntime/chain.d.ts +2 -1
- package/dist/mdruntime/change-set.d.ts +4 -0
- package/dist/mdruntime/change.d.ts +1 -0
- package/dist/mdruntime/client.d.ts +27 -19
- package/dist/mdruntime/collection.d.ts +23 -4
- package/dist/mdruntime/compile.d.ts +8 -6
- package/dist/mdruntime/conversation-live.d.ts +139 -0
- package/dist/mdruntime/conversation-row.d.ts +32 -0
- package/dist/mdruntime/conversation.d.ts +59 -45
- package/dist/mdruntime/declaration.d.ts +9 -0
- package/dist/mdruntime/durability.d.ts +18 -0
- package/dist/mdruntime/failure.d.ts +3 -0
- package/dist/mdruntime/figures.d.ts +48 -0
- package/dist/mdruntime/holdings.d.ts +28 -0
- package/dist/mdruntime/identity.d.ts +0 -1
- package/dist/mdruntime/listing.d.ts +47 -0
- package/dist/mdruntime/live.d.ts +22 -0
- package/dist/mdruntime/log.d.ts +5 -0
- package/dist/mdruntime/media.d.ts +1 -1
- package/dist/mdruntime/messages.d.ts +24 -3
- package/dist/mdruntime/model.d.ts +2 -10
- package/dist/mdruntime/observation.d.ts +2 -2
- package/dist/mdruntime/opened.d.ts +1 -1
- package/dist/mdruntime/outcome.d.ts +7 -1
- package/dist/mdruntime/overlay.d.ts +6 -1
- package/dist/mdruntime/preparation.d.ts +19 -0
- package/dist/mdruntime/presence.d.ts +51 -0
- package/dist/mdruntime/query.d.ts +13 -209
- package/dist/mdruntime/reach.d.ts +14 -12
- package/dist/mdruntime/readiness.d.ts +0 -3
- package/dist/mdruntime/reads.d.ts +38 -0
- package/dist/mdruntime/recovery.d.ts +3 -1
- package/dist/mdruntime/refresh.d.ts +26 -0
- package/dist/mdruntime/replica.d.ts +11 -16
- package/dist/mdruntime/retried.d.ts +29 -0
- package/dist/mdruntime/room-draft.d.ts +7 -8
- package/dist/mdruntime/room-drafts.d.ts +23 -0
- package/dist/mdruntime/runtime.d.ts +35 -0
- package/dist/mdruntime/save.d.ts +42 -86
- package/dist/mdruntime/saves.d.ts +31 -0
- package/dist/mdruntime/search.d.ts +12 -63
- package/dist/mdruntime/seed.d.ts +11 -2
- package/dist/mdruntime/socket/admission.d.ts +6 -0
- package/dist/mdruntime/socket/answers.d.ts +5 -0
- package/dist/mdruntime/socket/lanes.d.ts +27 -0
- package/dist/mdruntime/socket/session.d.ts +37 -0
- package/dist/mdruntime/socket.d.ts +67 -0
- package/dist/mdruntime/source.d.ts +53 -0
- package/dist/mdruntime/status.d.ts +0 -2
- package/dist/mdruntime/store/installs.d.ts +29 -0
- package/dist/mdruntime/store/readiness.d.ts +9 -0
- package/dist/mdruntime/store/records.d.ts +212 -0
- package/dist/mdruntime/store/room-held.d.ts +7 -0
- package/dist/mdruntime/store/space.d.ts +10 -0
- package/dist/mdruntime/store/watchers.d.ts +16 -0
- package/dist/mdruntime/store/writes.d.ts +23 -0
- package/dist/mdruntime/store.d.ts +112 -145
- package/dist/mdruntime/stored.d.ts +59 -33
- package/dist/mdruntime/surface.d.ts +88 -0
- package/dist/mdruntime/tables.d.ts +116 -29
- package/dist/mdruntime/tallies.d.ts +17 -0
- package/dist/mdruntime/transfer.d.ts +4 -0
- package/dist/mdruntime/wire.d.ts +69 -5
- package/dist/session-content/bounds.d.ts +7 -0
- package/dist/session-content/check.d.ts +18 -0
- package/dist/session-content/index.d.ts +7 -0
- package/dist/session-content/parts.d.ts +102 -0
- package/dist/session-content/state.d.ts +61 -0
- package/dist/session-content/turn.d.ts +328 -0
- package/dist/test-host.js +1 -1
- package/docs/families.md +24 -17
- package/package.json +2 -2
- package/dist/mdmodel/blocks.d.ts +0 -10
- package/dist/mdmodel/condition.d.ts +0 -179
- package/dist/mdmodel/links.d.ts +0 -28
- package/dist/mdmodel/profile.d.ts +0 -5
- package/dist/mdruntime/connection.d.ts +0 -152
- package/dist/mdruntime/fulltext.d.ts +0 -26
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { SessionState } from '../session-content/index.js';
|
|
2
|
+
import type { AcceptedMessage, ConversationAction, ConversationHistoryRequest, ConversationStream, ListedAgent, ListedConversation, ProcessCommand, SessionOption } from './adapter.js';
|
|
3
|
+
import { type Cell } from './cell.js';
|
|
4
|
+
import type { ChangeSet } from './change-set.js';
|
|
5
|
+
import type { Asked, ConversationAgent, ConversationEntry, ConversationView, RunningTurn } from './conversation.js';
|
|
6
|
+
import type { CallResult } from './outcome.js';
|
|
7
|
+
import type { Recovery } from './recovery.js';
|
|
8
|
+
import type { Attempt, Retries } from './retried.js';
|
|
9
|
+
import type { ChatDraftRecord, RuntimeStore } from './store.js';
|
|
10
|
+
export type ConversationDependencies = {
|
|
11
|
+
call(name: ConversationAction, input: unknown, attempt?: Attempt): Promise<CallResult>;
|
|
12
|
+
history(request: ConversationHistoryRequest): Promise<CallResult>;
|
|
13
|
+
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
14
|
+
local(): Promise<RuntimeStore>;
|
|
15
|
+
again(): void;
|
|
16
|
+
settled(): void;
|
|
17
|
+
stream(): ConversationStream | undefined;
|
|
18
|
+
publish(set: ChangeSet): void;
|
|
19
|
+
online(): boolean;
|
|
20
|
+
full(): boolean;
|
|
21
|
+
closed(): boolean;
|
|
22
|
+
unanswered(): void;
|
|
23
|
+
heard(operation: string, lost: boolean): void;
|
|
24
|
+
readonly recovery: Recovery;
|
|
25
|
+
readonly retries: Retries;
|
|
26
|
+
};
|
|
27
|
+
export type Live = {
|
|
28
|
+
turn: RunningTurn | null;
|
|
29
|
+
questions: readonly unknown[];
|
|
30
|
+
process: {
|
|
31
|
+
running: boolean;
|
|
32
|
+
} | null;
|
|
33
|
+
commands: readonly ProcessCommand[];
|
|
34
|
+
options: readonly SessionOption[];
|
|
35
|
+
starting: string | null;
|
|
36
|
+
state: SessionState | null;
|
|
37
|
+
link: {
|
|
38
|
+
connected: boolean;
|
|
39
|
+
} | null;
|
|
40
|
+
deliveryWaiting: readonly string[];
|
|
41
|
+
deliveryUnknown: readonly string[];
|
|
42
|
+
};
|
|
43
|
+
export declare const QUIET: Live;
|
|
44
|
+
export type Fact = Exclude<keyof Live, 'turn'>;
|
|
45
|
+
export declare const FACTS: readonly Fact[];
|
|
46
|
+
type Watcher = {
|
|
47
|
+
readonly notify: (view: ConversationView) => void;
|
|
48
|
+
};
|
|
49
|
+
type HeldWindow = {
|
|
50
|
+
readonly window: readonly AcceptedMessage[] | null;
|
|
51
|
+
readonly draft: ChatDraftRecord | null;
|
|
52
|
+
readonly ended: string | null;
|
|
53
|
+
readonly dismissed: string | null;
|
|
54
|
+
readonly more: boolean;
|
|
55
|
+
readonly total: number | null;
|
|
56
|
+
};
|
|
57
|
+
export type SharedView = {
|
|
58
|
+
readonly conversation: string;
|
|
59
|
+
readonly asked: Asked;
|
|
60
|
+
readonly held: Cell<HeldWindow>;
|
|
61
|
+
ready(): readonly Watcher[];
|
|
62
|
+
join(watcher: Watcher): void;
|
|
63
|
+
admit(watcher: Watcher): boolean;
|
|
64
|
+
leave(watcher: Watcher): boolean;
|
|
65
|
+
empty(): boolean;
|
|
66
|
+
};
|
|
67
|
+
type Listing<T> = (value: T) => void;
|
|
68
|
+
export type Audience<T> = {
|
|
69
|
+
waiting(): boolean;
|
|
70
|
+
told(): boolean;
|
|
71
|
+
join(watcher: Listing<T>): void;
|
|
72
|
+
leave(watcher: Listing<T>): void;
|
|
73
|
+
tell(value: T): void;
|
|
74
|
+
welcome(value: T): void;
|
|
75
|
+
clear(): void;
|
|
76
|
+
};
|
|
77
|
+
type HeldFacts = {
|
|
78
|
+
readonly listKnown: boolean;
|
|
79
|
+
readonly listOwed: boolean;
|
|
80
|
+
readonly listTelling: boolean;
|
|
81
|
+
readonly agentsShown: string | null;
|
|
82
|
+
readonly listedAgents: readonly ListedAgent[] | null;
|
|
83
|
+
readonly agentsReading: boolean;
|
|
84
|
+
readonly replicated: ReadonlySet<string>;
|
|
85
|
+
readonly handedReplicated: string | undefined;
|
|
86
|
+
};
|
|
87
|
+
export type Dispatch = Cell<{
|
|
88
|
+
readonly answered: boolean;
|
|
89
|
+
}>;
|
|
90
|
+
export type LiveConversations = {
|
|
91
|
+
readonly deps: ConversationDependencies;
|
|
92
|
+
readonly held: Cell<HeldFacts>;
|
|
93
|
+
readonly closing: AbortSignal;
|
|
94
|
+
readonly listeners: Audience<readonly ConversationEntry[]>;
|
|
95
|
+
readonly agentListeners: Audience<readonly ConversationAgent[]>;
|
|
96
|
+
views(): Iterable<SharedView>;
|
|
97
|
+
viewJoined(key: string, conversation: string, asked: Asked, notify: (view: ConversationView) => void): {
|
|
98
|
+
readonly view: SharedView;
|
|
99
|
+
readonly watcher: Watcher;
|
|
100
|
+
};
|
|
101
|
+
viewLeft(key: string, view: SharedView, watcher: Watcher): void;
|
|
102
|
+
liveOf(conversation: string): Live;
|
|
103
|
+
liveHeld(conversation: string): Live | undefined;
|
|
104
|
+
holdLive(conversation: string, next: Live | null): void;
|
|
105
|
+
factsOwed(conversation: string): void;
|
|
106
|
+
factsHeard(conversation: string, facts: readonly Fact[]): void;
|
|
107
|
+
factsTaken(): readonly (readonly [string, ReadonlySet<Fact>])[];
|
|
108
|
+
behind(conversation: string): boolean;
|
|
109
|
+
behindAll(): readonly string[];
|
|
110
|
+
fellBehind(conversation: string): void;
|
|
111
|
+
caughtUpTo(conversation: string): void;
|
|
112
|
+
gapOpened(conversation: string): void;
|
|
113
|
+
generation(conversation: string): number;
|
|
114
|
+
heardAt(conversation: string, change: string): void;
|
|
115
|
+
newestHeard(conversation: string): string | undefined;
|
|
116
|
+
catching(conversation: string): Promise<void> | undefined;
|
|
117
|
+
catchingUntil(conversation: string, ended: Promise<void>): void;
|
|
118
|
+
creating(conversation: string): void;
|
|
119
|
+
created(conversation: string): void;
|
|
120
|
+
isCreating(conversation: string): boolean;
|
|
121
|
+
relisting(): boolean;
|
|
122
|
+
relistBegun(): void;
|
|
123
|
+
relistHeard(entries: readonly ListedConversation[]): void;
|
|
124
|
+
relistDropped(conversation: string): void;
|
|
125
|
+
relistTaken(): ReadonlyMap<string, ListedConversation> | null;
|
|
126
|
+
sendingBegan(operation: string): Dispatch;
|
|
127
|
+
sendingEnded(operation: string, dispatch: Dispatch): void;
|
|
128
|
+
sending(operation: string): boolean;
|
|
129
|
+
rowSoon(tell: () => void): void;
|
|
130
|
+
inOrder(work: () => Promise<void>): void;
|
|
131
|
+
forget(conversation: string): void;
|
|
132
|
+
current(): boolean;
|
|
133
|
+
known(): boolean;
|
|
134
|
+
reopened(): void;
|
|
135
|
+
lost(): void;
|
|
136
|
+
close(): void;
|
|
137
|
+
};
|
|
138
|
+
export declare function createLiveConversations(deps: ConversationDependencies): LiveConversations;
|
|
139
|
+
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,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Part, type SessionState } from '../session-content/index.js';
|
|
2
|
+
import type { AgentEnvironment, ConversationEvent, ConversationMessage, ProcessCommand, SessionOption } from './adapter.js';
|
|
2
3
|
import { type ChangeSet } from './change-set.js';
|
|
4
|
+
import { type LiveConversations } from './conversation-live.js';
|
|
5
|
+
import { type ConversationHeld } from './conversation-row.js';
|
|
3
6
|
import type { Open } from './open.js';
|
|
4
7
|
import { type CallResult, type Offline } from './outcome.js';
|
|
8
|
+
import type { ChatRequest } from './source.js';
|
|
5
9
|
import type { CycleProgress } from './status.js';
|
|
6
|
-
import type {
|
|
10
|
+
import type { RuntimeStore } from './store.js';
|
|
7
11
|
export type ConversationState = Open<'working' | 'asking' | 'idle'>;
|
|
8
|
-
export type ConversationEntry = {
|
|
12
|
+
export type ConversationEntry = ConversationHeld & {
|
|
9
13
|
conversation: string;
|
|
10
14
|
agent: {
|
|
11
15
|
identity: string;
|
|
12
16
|
name: string;
|
|
17
|
+
retired: boolean;
|
|
13
18
|
};
|
|
14
19
|
name: string;
|
|
15
20
|
created: string;
|
|
@@ -18,16 +23,20 @@ export type ConversationEntry = {
|
|
|
18
23
|
waiting: boolean;
|
|
19
24
|
state: ConversationState;
|
|
20
25
|
started: string | null;
|
|
26
|
+
line: string | null;
|
|
27
|
+
question: string | null;
|
|
28
|
+
asked: string | null;
|
|
21
29
|
};
|
|
22
30
|
export type ConversationAgent = {
|
|
23
31
|
identity: string;
|
|
24
32
|
name: string;
|
|
33
|
+
cli?: string;
|
|
34
|
+
environment?: AgentEnvironment;
|
|
25
35
|
};
|
|
26
36
|
export type RunningTurn = {
|
|
27
37
|
turn: string;
|
|
28
38
|
started: string | null;
|
|
29
|
-
parts: readonly
|
|
30
|
-
context: TurnContext | null;
|
|
39
|
+
parts: readonly Part[];
|
|
31
40
|
};
|
|
32
41
|
export type ChatDraft = {
|
|
33
42
|
text: string;
|
|
@@ -37,6 +46,9 @@ export type ConversationOptions = {
|
|
|
37
46
|
after?: string;
|
|
38
47
|
total?: true;
|
|
39
48
|
};
|
|
49
|
+
export type ConversationRead = ConversationOptions & {
|
|
50
|
+
text?: string;
|
|
51
|
+
};
|
|
40
52
|
export type ConversationView = {
|
|
41
53
|
conversation: string;
|
|
42
54
|
messages: readonly ConversationMessage[];
|
|
@@ -47,27 +59,41 @@ export type ConversationView = {
|
|
|
47
59
|
process: {
|
|
48
60
|
running: boolean;
|
|
49
61
|
} | null;
|
|
62
|
+
processEnded: string | null;
|
|
50
63
|
commands: readonly ProcessCommand[];
|
|
51
64
|
options: readonly SessionOption[];
|
|
52
65
|
starting: string | null;
|
|
53
|
-
|
|
66
|
+
state: SessionState | null;
|
|
54
67
|
link: {
|
|
55
68
|
connected: boolean;
|
|
56
69
|
} | null;
|
|
70
|
+
deliveryWaiting: readonly string[];
|
|
57
71
|
deliveryUnknown: readonly string[];
|
|
58
72
|
chatDraft: (ChatDraft & {
|
|
59
73
|
readonly revision: string;
|
|
60
74
|
}) | null;
|
|
75
|
+
dismissedSuggestion: string | null;
|
|
61
76
|
};
|
|
77
|
+
export type RequestDecision = 'approve' | 'decline';
|
|
62
78
|
export type ConversationSurface = {
|
|
63
79
|
list(): Promise<readonly ConversationEntry[]>;
|
|
64
|
-
read(conversation: string, options?:
|
|
80
|
+
read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
|
|
65
81
|
create(input: unknown): Promise<CallResult>;
|
|
66
82
|
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
67
|
-
answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
|
|
68
|
-
interrupt(conversation: string): Promise<CallResult>;
|
|
69
|
-
kill(conversation: string): Promise<CallResult>;
|
|
70
|
-
delete(conversation: string): Promise<CallResult>;
|
|
83
|
+
answer(conversation: string, answer: ConversationAnswer, operation: string): Promise<CallResult>;
|
|
84
|
+
interrupt(conversation: string, operation: string): Promise<CallResult>;
|
|
85
|
+
kill(conversation: string, operation: string): Promise<CallResult>;
|
|
86
|
+
delete(conversation: string, operation: string): Promise<CallResult>;
|
|
87
|
+
takeOut(conversation: string, message: string, operation: string): Promise<CallResult>;
|
|
88
|
+
decide(request: ChatRequest, decision: RequestDecision, operation: string): Promise<CallResult>;
|
|
89
|
+
rename(conversation: string, name: string, operation: string): Promise<CallResult>;
|
|
90
|
+
option(conversation: string, option: string, value: string | boolean, operation: string): Promise<CallResult>;
|
|
91
|
+
retry(conversation: string, message: string, operation: string): Promise<CallResult>;
|
|
92
|
+
pins(): Promise<readonly string[]>;
|
|
93
|
+
pin(figures: readonly string[]): Promise<void>;
|
|
94
|
+
openedTurns(): Promise<Readonly<Record<string, string>>>;
|
|
95
|
+
openTurn(conversation: string, turn: string): Promise<void>;
|
|
96
|
+
dismissSuggestion(conversation: string, suggestion: string): Promise<void>;
|
|
71
97
|
};
|
|
72
98
|
export type ConversationAnswer = {
|
|
73
99
|
interaction_id: string;
|
|
@@ -76,43 +102,31 @@ export type ConversationAnswer = {
|
|
|
76
102
|
export type ChatDraftSurface = {
|
|
77
103
|
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
78
104
|
prepend(conversation: string, draft: ChatDraft): Promise<void>;
|
|
105
|
+
append(conversation: string, draft: ChatDraft): Promise<void>;
|
|
79
106
|
discard(conversation: string): Promise<void>;
|
|
80
107
|
};
|
|
81
|
-
export type ConversationDependencies = {
|
|
82
|
-
call(name: ConversationAction, input: unknown): Promise<CallResult>;
|
|
83
|
-
history(request: ConversationHistoryRequest): Promise<CallResult>;
|
|
84
|
-
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
85
|
-
stream(): ConversationStream | undefined;
|
|
86
|
-
publish(set: ChangeSet): void;
|
|
87
|
-
online(): boolean;
|
|
88
|
-
full(): boolean;
|
|
89
|
-
closed(): boolean;
|
|
90
|
-
unanswered(): void;
|
|
91
|
-
expired(operation: string): boolean;
|
|
92
|
-
};
|
|
93
|
-
export type ConversationStore = {
|
|
94
|
-
surface: ConversationSurface;
|
|
95
|
-
chatDraft: ChatDraftSurface;
|
|
96
|
-
hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[], list: readonly ListedConversation[] | null, cursor: string | null): void;
|
|
97
|
-
reconcile(): Promise<void>;
|
|
98
|
-
catchUp(progress: CycleProgress): Promise<void>;
|
|
99
|
-
resend(progress: CycleProgress): Promise<void>;
|
|
100
|
-
current(): boolean;
|
|
101
|
-
known(): boolean;
|
|
102
|
-
learned(): void;
|
|
103
|
-
reopened(): void;
|
|
104
|
-
lost(): void;
|
|
105
|
-
watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
|
|
106
|
-
watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
|
|
107
|
-
watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
|
|
108
|
-
changed(set: ChangeSet): void;
|
|
109
|
-
receive(event: ConversationEvent): boolean;
|
|
110
|
-
searchable(): readonly string[];
|
|
111
|
-
acquired(conversation: string): boolean;
|
|
112
|
-
close(): void;
|
|
113
|
-
};
|
|
114
108
|
export declare function unheldView(conversation: string): ConversationView;
|
|
115
109
|
export declare const SESSION_STARTED = "Session started";
|
|
110
|
+
export declare const CATCHING_UP = "catching-up";
|
|
116
111
|
export declare const HISTORY_CONVERSATIONS = 64;
|
|
117
112
|
export declare function newChat(agent: string): string;
|
|
118
|
-
export
|
|
113
|
+
export type Asked = {
|
|
114
|
+
limit: number;
|
|
115
|
+
after: string | undefined;
|
|
116
|
+
before: readonly [string, string] | null;
|
|
117
|
+
total: boolean;
|
|
118
|
+
};
|
|
119
|
+
export declare function joinedDraft(first: string, second: string): string;
|
|
120
|
+
export declare function conversationsLearned(alive: LiveConversations): void;
|
|
121
|
+
export declare function conversationSurface(alive: LiveConversations): ConversationSurface;
|
|
122
|
+
export declare function chatDraftSurface(alive: LiveConversations): ChatDraftSurface;
|
|
123
|
+
export declare function conversationsOpened(alive: LiveConversations, local: RuntimeStore): Promise<void>;
|
|
124
|
+
export declare function reconcileConversations(alive: LiveConversations): Promise<void>;
|
|
125
|
+
export declare function catchUpConversations(alive: LiveConversations, progress: CycleProgress): Promise<void>;
|
|
126
|
+
export declare function holdsSubmission(alive: LiveConversations, operation: string): Promise<boolean>;
|
|
127
|
+
export declare function resendConversations(alive: LiveConversations, progress: CycleProgress): Promise<void>;
|
|
128
|
+
export declare function watchConversation(alive: LiveConversations, conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
|
|
129
|
+
export declare function watchConversationList(alive: LiveConversations, deliver: (entries: readonly ConversationEntry[]) => void): () => void;
|
|
130
|
+
export declare function watchConversationAgents(alive: LiveConversations, deliver: (agents: readonly ConversationAgent[]) => void): () => void;
|
|
131
|
+
export declare function conversationsChanged(alive: LiveConversations, set: ChangeSet): void;
|
|
132
|
+
export declare function receiveConversationEvent(alive: LiveConversations, event: ConversationEvent): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DiscoveredRoom, OperationScopes, PathRule, RoomDeclaration } from './adapter.js';
|
|
2
|
+
export type WriteRefusal = {
|
|
3
|
+
readonly code: 'room-root' | 'provider-owned-path' | 'invalid-path' | `${keyof OperationScopes}-grant`;
|
|
4
|
+
readonly path: string;
|
|
5
|
+
};
|
|
6
|
+
export type WriteRule = (path: string, needs: readonly (keyof OperationScopes)[]) => WriteRefusal | null;
|
|
7
|
+
export declare function declared({ locator: _locator, roomVersion: _roomVersion, ...declaration }: DiscoveredRoom): RoomDeclaration;
|
|
8
|
+
export declare function sameDeclaration(left: RoomDeclaration, right: RoomDeclaration): boolean;
|
|
9
|
+
export declare function writeRule({ operations, providerOwnedPaths, authoredPaths, }: Pick<RoomDeclaration, 'operations' | 'providerOwnedPaths' | 'authoredPaths'>, pathRule: PathRule, local: boolean): WriteRule;
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import type { Persistence } from './readiness.js';
|
|
2
|
+
import type { RetriedFailure, Step } from './retried.js';
|
|
3
|
+
export type UnsentKind = 'pending-change' | 'call' | 'room-draft' | 'chat-draft';
|
|
4
|
+
export type UnsentWork = {
|
|
5
|
+
readonly kind: UnsentKind;
|
|
6
|
+
readonly count: number;
|
|
7
|
+
};
|
|
8
|
+
export type AppCode = {
|
|
9
|
+
readonly running: number;
|
|
10
|
+
readonly older: number;
|
|
11
|
+
};
|
|
12
|
+
export type HeldCode = {
|
|
13
|
+
readonly house: number | null;
|
|
14
|
+
readonly apps: readonly string[];
|
|
15
|
+
};
|
|
2
16
|
export type RuntimeShell = {
|
|
3
17
|
persistence: Persistence;
|
|
4
18
|
generation: string | null;
|
|
5
19
|
keepGeneration(value: string): void | Promise<void>;
|
|
6
20
|
dropGeneration(): void | Promise<void>;
|
|
7
21
|
cleanUp?(): Promise<number>;
|
|
22
|
+
measure?(measured: (app: string, code: AppCode | null) => void): Promise<HeldCode>;
|
|
23
|
+
reset(): Promise<void>;
|
|
24
|
+
retried?(failure: RetriedFailure): void;
|
|
25
|
+
succeeded?(step: Step): void;
|
|
8
26
|
};
|
|
9
27
|
export declare function refusedForSpace(error: unknown): boolean;
|
|
10
28
|
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProviderRefusal } from './adapter.js';
|
|
1
2
|
export type RuntimeError = Error & {
|
|
2
3
|
readonly code: string;
|
|
3
4
|
readonly retryable: boolean;
|
|
@@ -8,5 +9,7 @@ export type Described = {
|
|
|
8
9
|
retryable: boolean;
|
|
9
10
|
};
|
|
10
11
|
export declare function runtimeError(code: string, message?: string, retryable?: boolean): RuntimeError;
|
|
12
|
+
export declare function refusalError(refusal: ProviderRefusal): RuntimeError;
|
|
11
13
|
export declare function failed(error: unknown): RuntimeError;
|
|
14
|
+
export declare function uncaught(error: unknown): void;
|
|
12
15
|
export declare function described(error: unknown): Described;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 declare const FIGURES_DAY_MS = 86400000;
|
|
15
|
+
export type DayFigures = {
|
|
16
|
+
readonly created: number;
|
|
17
|
+
readonly changed: number;
|
|
18
|
+
readonly chats: number;
|
|
19
|
+
readonly messages: number;
|
|
20
|
+
};
|
|
21
|
+
export type RoomFigures = {
|
|
22
|
+
readonly room: string;
|
|
23
|
+
readonly day: DayFigures;
|
|
24
|
+
readonly total: {
|
|
25
|
+
readonly documents: GroupTotal;
|
|
26
|
+
readonly files: GroupTotal;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export type Figures = {
|
|
30
|
+
readonly rooms: readonly RoomFigures[];
|
|
31
|
+
readonly agentMessages: number;
|
|
32
|
+
};
|
|
33
|
+
export type FiguresResult = Figures | PendingResult;
|
|
34
|
+
export type FiguresCover = PendingResult | {
|
|
35
|
+
readonly rooms: readonly QueryRoom[];
|
|
36
|
+
};
|
|
37
|
+
export type FiguresSources = {
|
|
38
|
+
cover(): Promise<FiguresCover>;
|
|
39
|
+
rooms(rooms: readonly QueryRoom[], since: string): Promise<readonly RoomTally[]>;
|
|
40
|
+
conversations(conversations: readonly string[] | null, since: string): Promise<readonly ConversationTally[]>;
|
|
41
|
+
};
|
|
42
|
+
export type FiguresRead = {
|
|
43
|
+
watch(deliver: Deliver, fail: Fail): () => void;
|
|
44
|
+
touched(set: ChangeSet): void;
|
|
45
|
+
recover(): void;
|
|
46
|
+
close(): void;
|
|
47
|
+
};
|
|
48
|
+
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;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare function changeBatchIdentity(at?: number): string;
|
|
2
|
-
export declare function identityTime(identity: string): number;
|
|
3
2
|
export declare function roomDraftRevision(): string;
|
|
4
3
|
export declare function chatDraftRevision(): string;
|
|
5
4
|
export declare function transferIdentity(): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { HeldRooms } from '../mdmodel/index.js';
|
|
2
|
+
import type { DiscoveredRoom, HeldRoom, OperationScopes, ProviderRefusal, ReplicaAdmission, RoomDeclaration } 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 { Stored } from './store.js';
|
|
9
|
+
export type AppTypedSelection = {
|
|
10
|
+
roots: readonly string[];
|
|
11
|
+
model: TypesResult;
|
|
12
|
+
};
|
|
13
|
+
export type AppRoom = {
|
|
14
|
+
name: string;
|
|
15
|
+
locator: string;
|
|
16
|
+
handle: string;
|
|
17
|
+
operations: OperationScopes;
|
|
18
|
+
replica: ReplicaAdmission;
|
|
19
|
+
model: TypesResult;
|
|
20
|
+
typedSelection: AppTypedSelection | null;
|
|
21
|
+
providerOwnedPaths: readonly string[];
|
|
22
|
+
authoredPaths: 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, presence }: Runtime, locator: string, stored: Stored | undefined): ModelState;
|
|
35
|
+
export declare function compositionFor(runtime: Runtime, record: ReplicaRecord): Composition;
|
|
36
|
+
export declare function declarationOf({ presence }: Runtime, locator: string, stored: Stored | undefined): {
|
|
37
|
+
readonly room: RoomDeclaration;
|
|
38
|
+
readonly available: boolean;
|
|
39
|
+
} | undefined;
|
|
40
|
+
export declare function listedLocators({ presence }: 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({ presence }: Runtime, listing: Listing): readonly AppRoom[];
|
|
44
|
+
export declare function roomFacts(runtime: Runtime, reach?: PortReach | null): Promise<HeldRooms>;
|
|
45
|
+
export declare function heldRooms({ store }: Runtime, listed: readonly DiscoveredRoom[]): Promise<HeldRoom[]>;
|
|
46
|
+
export declare function name(runtime: Runtime, locator: string): Promise<void>;
|
|
47
|
+
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 {};
|
|
@@ -3,5 +3,5 @@ import { type ShownAnswer } from './outcome.js';
|
|
|
3
3
|
export declare const ROOM_MEDIA = "room-media";
|
|
4
4
|
type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
|
|
5
5
|
export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
|
|
6
|
-
export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient
|
|
6
|
+
export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient): void;
|
|
7
7
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AcceptedMessage } from './adapter.js';
|
|
2
2
|
import type { Connection } from './tables.js';
|
|
3
3
|
export declare const MESSAGE_TABLES: readonly string[];
|
|
4
|
+
export declare const ROWS = "WITH chosen AS (\n SELECT listed.value AS conversation,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'assistant' ORDER BY position DESC, identity DESC LIMIT 1) AS answer,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND text <> '' ORDER BY position DESC, identity DESC LIMIT 1) AS said,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' ORDER BY position, identity LIMIT 1) AS opened,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' AND json_extract(message, '$.waiting') = 1 ORDER BY position, identity LIMIT 1) AS asking\n FROM json_each(?) AS listed\n )\n SELECT chosen.conversation AS conversation,\n substr(said.text, 1, 512) AS said_text,\n json_extract(said.message, '$.role') AS said_role,\n json_extract(said.message, '$.accepted_at') AS said_at,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n json_extract(opened.message, '$.source') AS opened_source,\n json_extract(opened.message, '$.sender') AS opened_sender,\n asking.identity AS asking_identity,\n asking.text AS asking_text,\n json_extract(asking.message, '$.accepted_at') AS asking_at,\n json_extract(asking.message, '$.source') AS asking_source,\n json_extract(asking.message, '$.sender') AS asking_sender\n FROM chosen\n LEFT JOIN conversation_messages said ON said.id = chosen.said\n LEFT JOIN conversation_messages answer ON answer.id = chosen.answer\n LEFT JOIN conversation_messages opened ON opened.id = chosen.opened\n LEFT JOIN conversation_messages asking ON asking.id = chosen.asking";
|
|
4
5
|
export type HeldConversation = {
|
|
5
6
|
readonly conversation: string;
|
|
6
7
|
readonly read: string | null | undefined;
|
|
@@ -10,6 +11,25 @@ export type MessageWindow = {
|
|
|
10
11
|
readonly messages: AcceptedMessage[];
|
|
11
12
|
readonly more: boolean;
|
|
12
13
|
};
|
|
14
|
+
export type HeldSource = {
|
|
15
|
+
readonly source: unknown;
|
|
16
|
+
readonly sender: string | null;
|
|
17
|
+
};
|
|
18
|
+
export type HeldRow = {
|
|
19
|
+
readonly conversation: string;
|
|
20
|
+
readonly said: {
|
|
21
|
+
readonly text: string;
|
|
22
|
+
readonly role: string | null;
|
|
23
|
+
readonly at: string | null;
|
|
24
|
+
} | null;
|
|
25
|
+
readonly failure: string | null;
|
|
26
|
+
readonly opened: HeldSource | null;
|
|
27
|
+
readonly asking: (HeldSource & {
|
|
28
|
+
readonly identity: string;
|
|
29
|
+
readonly text: string;
|
|
30
|
+
readonly at: string | null;
|
|
31
|
+
}) | null;
|
|
32
|
+
};
|
|
13
33
|
export type ConversationWrite = {
|
|
14
34
|
readonly conversation: string;
|
|
15
35
|
readonly messages: readonly AcceptedMessage[];
|
|
@@ -18,10 +38,11 @@ export type ConversationWrite = {
|
|
|
18
38
|
readonly partial: boolean;
|
|
19
39
|
};
|
|
20
40
|
};
|
|
21
|
-
export declare function heldConversations(connection: Connection): HeldConversation[];
|
|
41
|
+
export declare function heldConversations(connection: Connection, conversations: readonly string[] | null): HeldConversation[];
|
|
22
42
|
export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
|
|
23
|
-
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null): MessageWindow;
|
|
24
|
-
export declare function messageCount(connection: Connection, conversation: string): number;
|
|
43
|
+
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null, phrase: string | null): MessageWindow;
|
|
44
|
+
export declare function messageCount(connection: Connection, conversation: string, phrase: string | null): number;
|
|
45
|
+
export declare function conversationRows(connection: Connection, conversations: readonly string[]): HeldRow[];
|
|
25
46
|
export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
|
|
26
47
|
export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
|
|
27
48
|
export declare function forgottenMessages(connection: Connection): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Definition,
|
|
1
|
+
import type { Definition, VerifiedModel } from '../mdmodel/index.js';
|
|
2
2
|
import type { Open } from './open.js';
|
|
3
3
|
export type ModelIdentity = {
|
|
4
4
|
identity: string;
|
|
@@ -8,7 +8,7 @@ export type ModelSnapshot = ModelIdentity & {
|
|
|
8
8
|
schema: string | null;
|
|
9
9
|
revision: string | null;
|
|
10
10
|
};
|
|
11
|
-
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired'
|
|
11
|
+
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired'>;
|
|
12
12
|
export type ModelResult = {
|
|
13
13
|
kind: 'model';
|
|
14
14
|
snapshot: ModelSnapshot;
|
|
@@ -20,8 +20,6 @@ export type MdType = Definition;
|
|
|
20
20
|
export type ModelState = {
|
|
21
21
|
status: 'unavailable';
|
|
22
22
|
reason: ModelUnavailableReason;
|
|
23
|
-
schema?: string | null;
|
|
24
|
-
revision?: string | null;
|
|
25
23
|
} | {
|
|
26
24
|
status: 'current' | 'cached';
|
|
27
25
|
snapshot: ModelSnapshot;
|
|
@@ -37,8 +35,6 @@ export type TypesResult = {
|
|
|
37
35
|
status: Open<'unavailable'>;
|
|
38
36
|
reason: ModelUnavailableReason;
|
|
39
37
|
types: null;
|
|
40
|
-
schema?: string | null;
|
|
41
|
-
revision?: string | null;
|
|
42
38
|
} | {
|
|
43
39
|
status: Open<'current' | 'cached'>;
|
|
44
40
|
identity: string;
|
|
@@ -54,9 +50,5 @@ export type ValidationReceipt = {
|
|
|
54
50
|
source: Open<'current' | 'cached'>;
|
|
55
51
|
};
|
|
56
52
|
export declare const NO_MODEL: ModelState;
|
|
57
|
-
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
58
53
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
59
54
|
export declare function storedModel(state: ModelState): StoredModel;
|
|
60
|
-
export declare function cached(state: ModelState): ModelState;
|
|
61
|
-
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
62
|
-
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|