@agentshouse/app-bridge 0.1.0-c3aff7d33e077 → 0.1.0-c3ee7fcd01608

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 (103) hide show
  1. package/README.md +2 -2
  2. package/dist/index.d.ts +173 -422
  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 +23 -10
  6. package/dist/mdmodel/document.d.ts +14 -8
  7. package/dist/mdmodel/event.d.ts +1 -2
  8. package/dist/mdmodel/fields.d.ts +1 -1
  9. package/dist/mdmodel/house-model.d.ts +869 -0
  10. package/dist/mdmodel/house-references/crockford.d.ts +3 -0
  11. package/dist/mdmodel/house-references/patterns.d.ts +8 -0
  12. package/dist/mdmodel/index.d.ts +31 -15
  13. package/dist/mdmodel/indexed.d.ts +8 -0
  14. package/dist/mdmodel/kinds.d.ts +4 -2
  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/query/language.d.ts +2 -1
  21. package/dist/mdmodel/query/match.d.ts +1 -1
  22. package/dist/mdmodel/query/rows.d.ts +1 -1
  23. package/dist/mdmodel/query/sql.d.ts +5 -1
  24. package/dist/mdmodel/query/walk.d.ts +62 -0
  25. package/dist/mdmodel/references.d.ts +2 -2
  26. package/dist/mdmodel/reserved.d.ts +1 -0
  27. package/dist/mdmodel/room-types.d.ts +6 -0
  28. package/dist/mdmodel/types.d.ts +11 -17
  29. package/dist/mdmodel/validate.d.ts +6 -2
  30. package/dist/mdmodel/yaml.d.ts +4 -4
  31. package/dist/mdruntime/actions.d.ts +8 -2
  32. package/dist/mdruntime/adapter.d.ts +120 -57
  33. package/dist/mdruntime/attached-model.d.ts +0 -1
  34. package/dist/mdruntime/authored.d.ts +87 -0
  35. package/dist/mdruntime/bootstrap.d.ts +1 -1
  36. package/dist/mdruntime/change-set.d.ts +4 -0
  37. package/dist/mdruntime/change.d.ts +4 -0
  38. package/dist/mdruntime/client.d.ts +19 -21
  39. package/dist/mdruntime/collection.d.ts +26 -4
  40. package/dist/mdruntime/compile.d.ts +2 -0
  41. package/dist/mdruntime/conversation-live.d.ts +28 -12
  42. package/dist/mdruntime/conversation-row.d.ts +8 -1
  43. package/dist/mdruntime/conversation.d.ts +37 -12
  44. package/dist/mdruntime/declaration.d.ts +9 -0
  45. package/dist/mdruntime/durability.d.ts +5 -0
  46. package/dist/mdruntime/failure.d.ts +3 -0
  47. package/dist/mdruntime/figures.d.ts +1 -0
  48. package/dist/mdruntime/house-query.d.ts +14 -0
  49. package/dist/mdruntime/install.d.ts +10 -6
  50. package/dist/mdruntime/listing.d.ts +29 -22
  51. package/dist/mdruntime/live.d.ts +5 -3
  52. package/dist/mdruntime/media.d.ts +19 -2
  53. package/dist/mdruntime/messages.d.ts +12 -6
  54. package/dist/mdruntime/modal.d.ts +1 -0
  55. package/dist/mdruntime/model.d.ts +4 -3
  56. package/dist/mdruntime/observation.d.ts +29 -12
  57. package/dist/mdruntime/opened.d.ts +1 -1
  58. package/dist/mdruntime/outcome.d.ts +13 -1
  59. package/dist/mdruntime/overlay.d.ts +6 -2
  60. package/dist/mdruntime/preparation.d.ts +33 -7
  61. package/dist/mdruntime/presence.d.ts +57 -0
  62. package/dist/mdruntime/query.d.ts +0 -1
  63. package/dist/mdruntime/reach.d.ts +15 -6
  64. package/dist/mdruntime/readiness.d.ts +20 -5
  65. package/dist/mdruntime/reads.d.ts +4 -2
  66. package/dist/mdruntime/recovery.d.ts +4 -1
  67. package/dist/mdruntime/replica.d.ts +5 -10
  68. package/dist/mdruntime/retried.d.ts +29 -0
  69. package/dist/mdruntime/room-draft.d.ts +31 -8
  70. package/dist/mdruntime/runtime.d.ts +11 -19
  71. package/dist/mdruntime/save.d.ts +42 -88
  72. package/dist/mdruntime/saves.d.ts +4 -40
  73. package/dist/mdruntime/socket/lanes.d.ts +12 -4
  74. package/dist/mdruntime/socket/session.d.ts +4 -2
  75. package/dist/mdruntime/socket.d.ts +4 -6
  76. package/dist/mdruntime/source.d.ts +5 -7
  77. package/dist/mdruntime/store/installs.d.ts +2 -2
  78. package/dist/mdruntime/store/readiness.d.ts +5 -4
  79. package/dist/mdruntime/store/records.d.ts +23 -8
  80. package/dist/mdruntime/store/rooms-shown.d.ts +7 -0
  81. package/dist/mdruntime/store/space.d.ts +1 -1
  82. package/dist/mdruntime/store.d.ts +26 -16
  83. package/dist/mdruntime/stored.d.ts +33 -15
  84. package/dist/mdruntime/surface.d.ts +12 -6
  85. package/dist/mdruntime/tables.d.ts +19 -58
  86. package/dist/mdruntime/wire.d.ts +66 -7
  87. package/dist/session-content/check.d.ts +17 -0
  88. package/dist/session-content/index.d.ts +6 -0
  89. package/dist/session-content/parts.d.ts +30 -0
  90. package/dist/session-content/state.d.ts +59 -0
  91. package/dist/session-content/turn.d.ts +137 -0
  92. package/dist/test-host.d.ts +8 -1
  93. package/dist/test-host.js +44 -1
  94. package/docs/families.md +61 -33
  95. package/package.json +2 -2
  96. package/dist/mdmodel/blocks.d.ts +0 -10
  97. package/dist/mdmodel/links.d.ts +0 -28
  98. package/dist/mdmodel/profile.d.ts +0 -5
  99. package/dist/mdruntime/job.d.ts +0 -32
  100. package/dist/mdruntime/log.d.ts +0 -5
  101. package/dist/mdruntime/socket/rooms.d.ts +0 -42
  102. package/dist/mdruntime/store/fences.d.ts +0 -15
  103. package/dist/mdruntime/turn.d.ts +0 -8
@@ -1,13 +1,14 @@
1
- import type { AcceptedMessage, ConversationAction, ConversationHistoryRequest, ConversationStream, ListedAgent, ListedConversation, ProcessCommand, RunningSubagent, SessionOption } from './adapter.js';
1
+ import type { SessionState } from '../session-content/index.js';
2
+ import type { AcceptedMessage, ConversationAction, ConversationHistoryRequest, ConversationStream, ListedAgent, ListedConversation, ProcessCommand, SessionOption } from './adapter.js';
2
3
  import { type Cell } from './cell.js';
3
4
  import type { ChangeSet } from './change-set.js';
4
5
  import type { Asked, ConversationAgent, ConversationEntry, ConversationView, RunningTurn } from './conversation.js';
5
- import type { JobMarker } from './job.js';
6
6
  import type { CallResult } from './outcome.js';
7
7
  import type { Recovery } from './recovery.js';
8
+ import type { Attempt, Retries } from './retried.js';
8
9
  import type { ChatDraftRecord, RuntimeStore } from './store.js';
9
10
  export type ConversationDependencies = {
10
- call(name: ConversationAction, input: unknown): Promise<CallResult>;
11
+ call(name: ConversationAction, input: unknown, attempt?: Attempt): Promise<CallResult>;
11
12
  history(request: ConversationHistoryRequest): Promise<CallResult>;
12
13
  durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
13
14
  local(): Promise<RuntimeStore>;
@@ -19,7 +20,9 @@ export type ConversationDependencies = {
19
20
  full(): boolean;
20
21
  closed(): boolean;
21
22
  unanswered(): void;
23
+ heard(operation: string, lost: boolean): void;
22
24
  readonly recovery: Recovery;
25
+ readonly retries: Retries;
23
26
  };
24
27
  export type Live = {
25
28
  turn: RunningTurn | null;
@@ -30,10 +33,11 @@ export type Live = {
30
33
  commands: readonly ProcessCommand[];
31
34
  options: readonly SessionOption[];
32
35
  starting: string | null;
33
- subagents: readonly RunningSubagent[];
36
+ state: SessionState | null;
34
37
  link: {
35
38
  connected: boolean;
36
39
  } | null;
40
+ deliveryWaiting: readonly string[];
37
41
  deliveryUnknown: readonly string[];
38
42
  };
39
43
  export declare const QUIET: Live;
@@ -42,11 +46,14 @@ export declare const FACTS: readonly Fact[];
42
46
  type Watcher = {
43
47
  readonly notify: (view: ConversationView) => void;
44
48
  };
45
- type HeldWindow = {
46
- readonly window: readonly AcceptedMessage[] | null;
49
+ export type Kept = {
47
50
  readonly draft: ChatDraftRecord | null;
48
51
  readonly ended: string | null;
49
- readonly marked: readonly JobMarker[];
52
+ readonly dismissed: string | null;
53
+ readonly pins: readonly string[];
54
+ };
55
+ type HeldWindow = Kept & {
56
+ readonly window: readonly AcceptedMessage[] | null;
50
57
  readonly more: boolean;
51
58
  readonly total: number | null;
52
59
  };
@@ -72,23 +79,30 @@ export type Audience<T> = {
72
79
  };
73
80
  type HeldFacts = {
74
81
  readonly listKnown: boolean;
82
+ readonly listHeld: boolean;
83
+ readonly openingRead: boolean;
84
+ readonly openingListed: boolean;
75
85
  readonly listOwed: boolean;
76
86
  readonly listTelling: boolean;
77
87
  readonly agentsShown: string | null;
78
- readonly listedAgents: readonly ListedAgent[] | null;
79
- readonly agentsReading: boolean;
88
+ readonly listedShown: string | null;
80
89
  readonly replicated: ReadonlySet<string>;
81
90
  readonly handedReplicated: string | undefined;
82
91
  };
83
92
  export type Dispatch = Cell<{
84
93
  readonly answered: boolean;
85
94
  }>;
95
+ export type Relisted = {
96
+ readonly conversations: ReadonlyMap<string, ListedConversation>;
97
+ readonly agents: ReadonlyMap<string, ListedAgent>;
98
+ };
86
99
  export type LiveConversations = {
87
100
  readonly deps: ConversationDependencies;
88
101
  readonly held: Cell<HeldFacts>;
89
102
  readonly closing: AbortSignal;
90
103
  readonly listeners: Audience<readonly ConversationEntry[]>;
91
104
  readonly agentListeners: Audience<readonly ConversationAgent[]>;
105
+ readonly listedListeners: Audience<readonly ListedAgent[]>;
92
106
  views(): Iterable<SharedView>;
93
107
  viewJoined(key: string, conversation: string, asked: Asked, notify: (view: ConversationView) => void): {
94
108
  readonly view: SharedView;
@@ -107,7 +121,7 @@ export type LiveConversations = {
107
121
  caughtUpTo(conversation: string): void;
108
122
  gapOpened(conversation: string): void;
109
123
  generation(conversation: string): number;
110
- heardAt(conversation: string, position: string): void;
124
+ heardAt(conversation: string, change: string): void;
111
125
  newestHeard(conversation: string): string | undefined;
112
126
  catching(conversation: string): Promise<void> | undefined;
113
127
  catchingUntil(conversation: string, ended: Promise<void>): void;
@@ -116,9 +130,9 @@ export type LiveConversations = {
116
130
  isCreating(conversation: string): boolean;
117
131
  relisting(): boolean;
118
132
  relistBegun(): void;
119
- relistHeard(entries: readonly ListedConversation[]): void;
133
+ relistHeard(entries: readonly ListedConversation[], agents: readonly ListedAgent[]): void;
120
134
  relistDropped(conversation: string): void;
121
- relistTaken(): ReadonlyMap<string, ListedConversation> | null;
135
+ relistTaken(): Relisted | null;
122
136
  sendingBegan(operation: string): Dispatch;
123
137
  sendingEnded(operation: string, dispatch: Dispatch): void;
124
138
  sending(operation: string): boolean;
@@ -127,6 +141,8 @@ export type LiveConversations = {
127
141
  forget(conversation: string): void;
128
142
  current(): boolean;
129
143
  known(): boolean;
144
+ listHeld(): boolean;
145
+ listed(): boolean;
130
146
  reopened(): void;
131
147
  lost(): void;
132
148
  close(): void;
@@ -1,5 +1,5 @@
1
1
  import type { HeldRow } from './messages.js';
2
- import { type HouseSource } from './source.js';
2
+ import { type HouseSource, type RequestAnswer } from './source.js';
3
3
  export type ConversationLast = {
4
4
  readonly text: string;
5
5
  readonly by: 'owner' | 'agent' | 'house';
@@ -10,18 +10,25 @@ export type ConversationStart = Extract<HouseSource, {
10
10
  }>;
11
11
  export type ConversationAsk = {
12
12
  readonly who: string;
13
+ readonly fromRoom: boolean;
13
14
  readonly agent: string | null;
14
15
  readonly room: {
15
16
  readonly ref: string;
17
+ readonly handle: string;
16
18
  readonly name: string;
17
19
  };
18
20
  readonly prompt: string;
21
+ readonly agentFunction: string | null;
22
+ readonly answer: RequestAnswer | null;
23
+ readonly instruction: string | null;
19
24
  readonly at: string;
20
25
  readonly request: string;
21
26
  readonly message?: string;
22
27
  };
23
28
  export type ConversationHeld = {
24
29
  readonly last: ConversationLast | null;
30
+ readonly answered: string | null;
31
+ readonly opened: string | null;
25
32
  readonly failure: string | null;
26
33
  readonly startedBy: ConversationStart | null;
27
34
  readonly asks: ConversationAsk | null;
@@ -1,10 +1,11 @@
1
- import type { ConversationEvent, ConversationMessage, ProcessCommand, RunningSubagent, SessionOption, TurnContext } from './adapter.js';
1
+ import { type Part, type SessionState } from '../session-content/index.js';
2
+ import type { AgentEnvironment, ConversationEvent, ConversationMessage, ListedAgent, ProcessCommand, SessionOption } from './adapter.js';
2
3
  import { type ChangeSet } from './change-set.js';
3
4
  import { type LiveConversations } from './conversation-live.js';
4
5
  import { type ConversationHeld } from './conversation-row.js';
5
- import type { OpenJob } from './job.js';
6
6
  import type { Open } from './open.js';
7
- import { type CallResult, type Offline } from './outcome.js';
7
+ import { type BinaryLinkAnswer, type CallResult, type ConversationAttachAnswer, type Offline } from './outcome.js';
8
+ import type { ChatRequest } from './source.js';
8
9
  import type { CycleProgress } from './status.js';
9
10
  import type { RuntimeStore } from './store.js';
10
11
  export type ConversationState = Open<'working' | 'asking' | 'idle'>;
@@ -20,6 +21,7 @@ export type ConversationEntry = ConversationHeld & {
20
21
  finished: string | null;
21
22
  outcome: string | null;
22
23
  waiting: boolean;
24
+ subject: string | null;
23
25
  state: ConversationState;
24
26
  started: string | null;
25
27
  line: string | null;
@@ -29,12 +31,15 @@ export type ConversationEntry = ConversationHeld & {
29
31
  export type ConversationAgent = {
30
32
  identity: string;
31
33
  name: string;
34
+ cli: string;
35
+ model: string | null;
36
+ effort: string | null;
37
+ environment: AgentEnvironment;
32
38
  };
33
39
  export type RunningTurn = {
34
40
  turn: string;
35
41
  started: string | null;
36
- parts: readonly unknown[];
37
- context: TurnContext | null;
42
+ parts: readonly Part[];
38
43
  };
39
44
  export type ChatDraft = {
40
45
  text: string;
@@ -61,26 +66,40 @@ export type ConversationView = {
61
66
  commands: readonly ProcessCommand[];
62
67
  options: readonly SessionOption[];
63
68
  starting: string | null;
64
- subagents: readonly RunningSubagent[];
69
+ state: SessionState | null;
65
70
  link: {
66
71
  connected: boolean;
67
72
  } | null;
73
+ deliveryWaiting: readonly string[];
68
74
  deliveryUnknown: readonly string[];
69
75
  chatDraft: (ChatDraft & {
70
76
  readonly revision: string;
71
77
  }) | null;
72
- jobs: readonly OpenJob[];
78
+ dismissedSuggestion: string | null;
79
+ pins: readonly string[];
73
80
  };
81
+ export type RequestDecision = 'approve' | 'decline';
74
82
  export type ConversationSurface = {
75
83
  list(): Promise<readonly ConversationEntry[]>;
76
84
  read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
77
85
  create(input: unknown): Promise<CallResult>;
78
86
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
79
- answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
80
- interrupt(conversation: string): Promise<CallResult>;
81
- kill(conversation: string): Promise<CallResult>;
82
- delete(conversation: string): Promise<CallResult>;
87
+ answer(conversation: string, answer: ConversationAnswer, operation: string): Promise<CallResult>;
88
+ interrupt(conversation: string, operation: string): Promise<CallResult>;
89
+ kill(conversation: string, operation: string): Promise<CallResult>;
90
+ delete(conversation: string, operation: string): Promise<CallResult>;
91
+ takeOut(conversation: string, message: string, operation: string): Promise<CallResult>;
92
+ decide(request: ChatRequest, decision: RequestDecision, operation: string): Promise<CallResult>;
93
+ rename(conversation: string, name: string, operation: string): Promise<CallResult>;
94
+ option(conversation: string, option: string, value: string | boolean, operation: string): Promise<CallResult>;
95
+ retry(conversation: string, message: string, operation: string): Promise<CallResult>;
96
+ pin(figures: readonly string[]): Promise<void>;
97
+ openTurn(conversation: string, turn: string): Promise<void>;
98
+ dismissSuggestion(conversation: string, suggestion: string): Promise<void>;
99
+ attach(file: File): Promise<ConversationAttachAnswer>;
100
+ attachment(link: string): Promise<BinaryLinkAnswer>;
83
101
  };
102
+ export type ConversationFiles = Pick<ConversationSurface, 'attach' | 'attachment'>;
84
103
  export type ConversationAnswer = {
85
104
  interaction_id: string;
86
105
  response: unknown;
@@ -88,10 +107,12 @@ export type ConversationAnswer = {
88
107
  export type ChatDraftSurface = {
89
108
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
90
109
  prepend(conversation: string, draft: ChatDraft): Promise<void>;
110
+ append(conversation: string, draft: ChatDraft): Promise<void>;
91
111
  discard(conversation: string): Promise<void>;
92
112
  };
93
113
  export declare function unheldView(conversation: string): ConversationView;
94
114
  export declare const SESSION_STARTED = "Session started";
115
+ export declare const CATCHING_UP = "catching-up";
95
116
  export declare const HISTORY_CONVERSATIONS = 64;
96
117
  export declare function newChat(agent: string): string;
97
118
  export type Asked = {
@@ -100,15 +121,19 @@ export type Asked = {
100
121
  before: readonly [string, string] | null;
101
122
  total: boolean;
102
123
  };
124
+ export declare function joinedDraft(first: string, second: string): string;
103
125
  export declare function conversationsLearned(alive: LiveConversations): void;
104
- export declare function conversationSurface(alive: LiveConversations): ConversationSurface;
126
+ export declare function conversationSurface(alive: LiveConversations, files: ConversationFiles): ConversationSurface;
105
127
  export declare function chatDraftSurface(alive: LiveConversations): ChatDraftSurface;
106
128
  export declare function conversationsOpened(alive: LiveConversations, local: RuntimeStore): Promise<void>;
129
+ export declare function reconcileOpening(alive: LiveConversations): Promise<void>;
107
130
  export declare function reconcileConversations(alive: LiveConversations): Promise<void>;
108
131
  export declare function catchUpConversations(alive: LiveConversations, progress: CycleProgress): Promise<void>;
132
+ export declare function holdsSubmission(alive: LiveConversations, operation: string): Promise<boolean>;
109
133
  export declare function resendConversations(alive: LiveConversations, progress: CycleProgress): Promise<void>;
110
134
  export declare function watchConversation(alive: LiveConversations, conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
111
135
  export declare function watchConversationList(alive: LiveConversations, deliver: (entries: readonly ConversationEntry[]) => void): () => void;
112
136
  export declare function watchConversationAgents(alive: LiveConversations, deliver: (agents: readonly ConversationAgent[]) => void): () => void;
137
+ export declare function watchListedAgents(alive: LiveConversations, deliver: (agents: readonly ListedAgent[]) => void): () => void;
113
138
  export declare function conversationsChanged(alive: LiveConversations, set: ChangeSet): void;
114
139
  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,9 +1,11 @@
1
1
  import type { Persistence } from './readiness.js';
2
+ import type { RetriedFailure, Step } from './retried.js';
2
3
  export type UnsentKind = 'pending-change' | 'call' | 'room-draft' | 'chat-draft';
3
4
  export type UnsentWork = {
4
5
  readonly kind: UnsentKind;
5
6
  readonly count: number;
6
7
  };
8
+ export declare function leftToSend(unsent: readonly UnsentWork[]): boolean;
7
9
  export type AppCode = {
8
10
  readonly running: number;
9
11
  readonly older: number;
@@ -20,7 +22,10 @@ export type RuntimeShell = {
20
22
  cleanUp?(): Promise<number>;
21
23
  measure?(measured: (app: string, code: AppCode | null) => void): Promise<HeldCode>;
22
24
  reset(): Promise<void>;
25
+ retried?(failure: RetriedFailure): void;
26
+ succeeded?(step: Step): void;
23
27
  };
24
28
  export declare function refusedForSpace(error: unknown): boolean;
25
29
  export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
30
+ export declare function lossStated(persistence: Persistence, loss: string | null): string | null;
26
31
  export declare function nextGeneration(stored: string | null, reported: string | null): string;
@@ -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;
@@ -11,6 +11,7 @@ export declare const ROOM_TOTALS: {
11
11
  readonly size: true;
12
12
  };
13
13
  };
14
+ export declare const FIGURES_DAY_MS = 86400000;
14
15
  export type DayFigures = {
15
16
  readonly created: number;
16
17
  readonly changed: number;
@@ -0,0 +1,14 @@
1
+ import { type DocumentQuery, type GroupQuery } from '../mdmodel/index.js';
2
+ import type { HouseQueryGroups, HouseQueryRows, ProviderRefusal } from './adapter.js';
3
+ import { type Failure, type Offline } from './outcome.js';
4
+ import { type PortReach } from './reach.js';
5
+ import type { Runtime } from './runtime.js';
6
+ export type HouseQuery = (DocumentQuery | GroupQuery) & {
7
+ rooms: readonly [string];
8
+ };
9
+ export type HouseQueryResult = HouseQueryRows | HouseQueryGroups | Offline | (ProviderRefusal & {
10
+ kind: 'rejected';
11
+ }) | (ProviderRefusal & {
12
+ kind: 'undeclared';
13
+ }) | Failure;
14
+ export declare function queriedHouse(runtime: Runtime, input: unknown, reach: PortReach | null): Promise<HouseQueryResult>;
@@ -1,6 +1,6 @@
1
1
  import type { AdapterFailure, Authorization, DiscoveredRoom, NotReady, RetryableRefusal } from './adapter.js';
2
2
  import { type Reads } from './bootstrap.js';
3
- import type { Installation, RoomCoverage } from './readiness.js';
3
+ import type { Installation, InstallationAmount, RoomCoverage } from './readiness.js';
4
4
  import { advancement, type Refresher } from './refresh.js';
5
5
  import type { ReplicaRecord } from './replica.js';
6
6
  import type { Runtime } from './runtime.js';
@@ -33,13 +33,17 @@ type Refreshed = {
33
33
  kind: 'advanced';
34
34
  }>;
35
35
  export declare const ERASE_BATCH = 512;
36
- export declare function installationOf(store: Store, coverage: readonly RoomCoverage[], held: ReadonlyMap<string, CoveredRoom>): Installation;
36
+ export type InstallShare = {
37
+ readonly installing: boolean;
38
+ readonly downloading: boolean;
39
+ readonly bytes: InstallationAmount;
40
+ };
41
+ export declare function installShare(store: Store, { room, state }: RoomCoverage, held: ReadonlyMap<string, CoveredRoom>): InstallShare;
42
+ export declare function installationOf(installing: number, downloading: number, bytes: InstallationAmount): Installation;
37
43
  export declare function roomInFlight(store: Store, locator: string): boolean;
38
- export declare function sweep({ store, socket, journal }: Runtime): void;
39
- export declare function forgetInstall(store: Store, locator: string): void;
44
+ export declare function sweep({ store, socket }: Runtime): void;
40
45
  export declare function caughtUpTo(runtime: Runtime, locator: string): void;
41
46
  export declare function catching(store: Store, locator: string): void;
42
- export declare function confirmedAgain(store: Store, locator: string): void;
43
47
  export declare function standingAt(store: Store, locator: string, held: Pick<ReplicaRecord, 'key'> | undefined): Standing;
44
48
  export declare function showing(system: Runtime, locator: string, roomVersion: string, held: string | undefined): void;
45
49
  export declare function olderThan(system: Runtime, locator: string, roomVersion: string, held: string | undefined): boolean;
@@ -48,7 +52,7 @@ export declare function reachedBy({ store, socket }: Runtime, locator: string, r
48
52
  export declare function behind({ store, socket }: Runtime, room: DiscoveredRoom): Promise<boolean>;
49
53
  export declare function writtenAfter({ store, socket }: Runtime, locator: string, roomVersion: string, path: string): Promise<boolean>;
50
54
  export declare function pullRefresh(runtime: Runtime, authorized: Authorization, record: ReplicaRecord, liveness: Live, hold: InstallHold, refresh: Refresher): Promise<Refreshed>;
51
- export declare function pullBootstrap(runtime: Runtime, authorized: Authorization, room: DiscoveredRoom, local: RuntimeStore, liveness: Live, prior: ReplicaRecord | undefined, from?: Reads, unheld?: Unheld): Promise<import("./bootstrap.js").Bootstrapped | NotReady | import("./adapter.js").RevokedAuthorization | import("./adapter.js").RoomNotReadable | Unconfirmed | {
55
+ export declare function pullBootstrap(runtime: Runtime, authorized: Authorization, room: DiscoveredRoom, local: RuntimeStore, liveness: Live, prior: ReplicaRecord | undefined, from?: Reads, unheld?: Unheld): Promise<import("./bootstrap.js").Bootstrapped | NotReady | import("./adapter.js").RevokedAuthorization | import("./adapter.js").RoomNotReadable | import("./adapter.js").TransportUncertainty | Unconfirmed | {
52
56
  readonly kind: 'transport-uncertainty';
53
57
  } | RetryableRefusal | import("./adapter.js").ScopedRefusal>;
54
58
  export declare function publish(runtime: Runtime, local: RuntimeStore, room: DiscoveredRoom, reached: ReplicaRecord, landing: Landing, live: Live): Promise<boolean>;
@@ -1,52 +1,59 @@
1
1
  import type { HeldRooms } from '../mdmodel/index.js';
2
- import type { DiscoveredRoom, HeldRoom, OperationScopes, ProviderRefusal, ReplicaAdmission } from './adapter.js';
3
- import type { Composition } from './collection.js';
4
- import { type ModelState, type TypesResult } from './model.js';
2
+ import type { DiscoveredRoom, HeldRoom, OperationScopes, ProviderRefusal, ReplicaAdmission, RoomDeclaration } from './adapter.js';
3
+ import { type Composition } from './collection.js';
4
+ import type { KeyedChange } from './observation.js';
5
+ import { type MdType, type ModelState, type TypesResult } from './model.js';
5
6
  import { type PortReach } from './reach.js';
6
7
  import type { ReplicaRecord } from './replica.js';
7
8
  import type { Runtime } from './runtime.js';
8
- import type { RoomDeclaration } from './socket.js';
9
9
  import type { Stored } from './store.js';
10
- export type AppTypedSelection = {
10
+ type Selection<Model> = {
11
11
  roots: readonly string[];
12
- model: TypesResult;
12
+ model: Model;
13
13
  };
14
- export type AppRoom = {
14
+ type Shown<Model> = {
15
15
  name: string;
16
16
  locator: string;
17
17
  handle: string;
18
18
  operations: OperationScopes;
19
19
  replica: ReplicaAdmission;
20
- model: TypesResult;
21
- typedSelection: AppTypedSelection | null;
20
+ model: Model;
21
+ typedSelection: Selection<Model> | null;
22
22
  providerOwnedPaths: readonly string[];
23
+ authoredPaths: readonly string[];
23
24
  roomVersion: string | null;
24
25
  documents: number;
25
26
  synchronizationAvailable: boolean;
26
27
  refusal: ProviderRefusal | null;
27
28
  locked: boolean;
29
+ queriesOnly?: true;
28
30
  };
29
- type ListedRoom = Omit<AppRoom, 'documents' | 'locked'>;
30
- type ListedEntry = ListedRoom & {
31
- readonly documents: number;
31
+ export type AppTypedSelection = Selection<TypesResult>;
32
+ export type AppRoom = Shown<TypesResult>;
33
+ export type ListedRoom = Shown<TypesResult<string>>;
34
+ export type ListedModels = Readonly<Record<string, readonly MdType[]>>;
35
+ export type ListedRooms = {
36
+ readonly rooms: readonly ListedRoom[];
37
+ readonly models: ListedModels;
32
38
  };
39
+ export type ListedEntry = Omit<Shown<ModelState>, 'locked'>;
33
40
  export type Listing = ReadonlyMap<string, ListedEntry>;
34
- export declare function modelIn({ socket }: Runtime, locator: string, stored: Stored | undefined): ModelState;
41
+ export type RoomsChange = KeyedChange<string, ListedRoom> & {
42
+ readonly models: ListedModels;
43
+ };
44
+ export declare function modelIn({ socket, presence }: Runtime, locator: string, stored: Stored | undefined): ModelState;
35
45
  export declare function compositionFor(runtime: Runtime, record: ReplicaRecord): Composition;
36
- export declare function declarationOf({ socket }: Runtime, locator: string, stored: Stored | undefined): {
46
+ export declare function declarationOf({ presence }: Runtime, locator: string, stored: Stored | undefined): {
37
47
  readonly room: RoomDeclaration;
38
48
  readonly available: boolean;
39
49
  } | undefined;
40
- export declare function listedLocators({ store, socket }: Runtime, held: ReadonlyMap<string, unknown>): string[];
41
- export declare function patchedListing(runtime: Runtime, changed: ReadonlySet<string>): Promise<Listing | null>;
50
+ export declare function listedLocators({ presence }: Runtime, held: ReadonlyMap<string, unknown>): string[];
51
+ export declare function listedOrHeld({ presence }: Runtime, held: ReadonlyMap<string, unknown>, locator: string): boolean;
52
+ export declare function listedEntries(runtime: Runtime, touched: readonly string[]): Promise<readonly ListedEntry[] | null>;
42
53
  export declare function listingNow(runtime: Runtime): Promise<Listing>;
43
- export declare function shownRooms(runtime: Runtime, listing: Listing): readonly AppRoom[];
54
+ export declare function shownRooms(runtime: Runtime, listing: Listing): ListedRooms;
55
+ export declare function shownChange(runtime: Runtime, entries: readonly ListedEntry[]): RoomsChange;
44
56
  export declare function roomFacts(runtime: Runtime, reach?: PortReach | null): Promise<HeldRooms>;
45
- export declare function list({ store, socket }: Runtime, room: RoomDeclaration, synchronizationAvailable: boolean): void;
46
- export declare function listHeld({ store, socket }: Runtime, locator: string): void;
47
- export declare function admitted({ socket }: Runtime, room: RoomDeclaration): boolean;
48
- export declare function readable(runtime: Runtime, room: DiscoveredRoom): void;
49
- export declare function usable(runtime: Runtime, room: DiscoveredRoom): void;
50
57
  export declare function heldRooms({ store }: Runtime, listed: readonly DiscoveredRoom[]): Promise<HeldRoom[]>;
51
58
  export declare function name(runtime: Runtime, locator: string): Promise<void>;
52
59
  export {};
@@ -1,6 +1,6 @@
1
1
  import type { ChangeSet } from './change-set.js';
2
2
  import { type KeyedResult, type QueryMessage } from './observation.js';
3
- import type { PendingResult, Plan, QueryCoverage } from './query.js';
3
+ import type { PendingResult, PendingRoom, Plan, QueryCoverage } from './query.js';
4
4
  import type { Fail } from './reach.js';
5
5
  import type { QueryRoom } from './tables.js';
6
6
  export type Cover = {
@@ -11,12 +11,14 @@ export type Ran = KeyedResult & {
11
11
  readonly current: () => boolean;
12
12
  };
13
13
  export type Run = (plan: Plan, cover: () => Promise<Cover>) => Promise<Ran>;
14
+ export type PendingAt<H> = (held: H, rooms: readonly string[]) => ReadonlyMap<string, PendingRoom | null> | null;
14
15
  type Listener = (message: QueryMessage) => void;
15
16
  export type LiveQueries<H> = {
16
17
  touched(set: ChangeSet): void;
17
- recover(): void;
18
- watch(plan: Plan, identity: string, cover: (held: H) => Cover, deliver: Listener, failed: Fail): () => void;
18
+ recover(locators?: readonly string[]): void;
19
+ watch(plan: Plan, identity: string, cover: (held: H) => Cover, pendingAt: PendingAt<H>, deliver: Listener, failed: Fail): () => void;
19
20
  close(): void;
20
21
  };
22
+ export declare function readerOf(plan: Plan): (locator: string) => boolean;
21
23
  export declare function createLiveQueries<H>(run: Run, holding: () => Promise<H>): LiveQueries<H>;
22
24
  export {};
@@ -1,7 +1,24 @@
1
1
  import type { MdRuntimeClient } from './client.js';
2
- import { type ShownAnswer } from './outcome.js';
2
+ import { type DownloadAnswer, type ShownAnswer } from './outcome.js';
3
3
  export declare const ROOM_MEDIA = "room-media";
4
+ export declare const KEYED_MEDIA = "ahc-attachment";
5
+ export declare const MEDIA = "room-media, ahc-attachment";
6
+ export declare const DIAGRAM = "md-diagram";
7
+ export declare const VIEWING = "ahc-viewer";
4
8
  type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
9
+ export type MediaAt = {
10
+ readonly link: string;
11
+ } | {
12
+ readonly room: string;
13
+ readonly path: string;
14
+ readonly revision: string | undefined;
15
+ };
5
16
  export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
6
- export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient, registry?: CustomElementRegistry): void;
17
+ export declare function mediaAt(media: Element): MediaAt | null;
18
+ export declare function mediaTag(at: MediaAt): string;
19
+ export declare function downloadAt(client: MdRuntimeClient, at: MediaAt): Promise<DownloadAnswer>;
20
+ export declare function rendered(element: Element): boolean;
21
+ export declare function viewable(element: Element): boolean;
22
+ export declare function viewFile(client: MdRuntimeClient, media: Element): void;
23
+ export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient): void;
7
24
  export {};
@@ -1,9 +1,7 @@
1
1
  import type { AcceptedMessage } from './adapter.js';
2
- import type { JobMarker } from './job.js';
3
2
  import type { Connection } from './tables.js';
4
3
  export declare const MESSAGE_TABLES: readonly string[];
5
- 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";
6
- export declare const JOB_MARKERS = "SELECT json_extract(part.value, '$.text') AS said,\n json_extract(message, '$.accepted_at') AS at\n FROM conversation_messages, json_each(message, '$.parts') AS part\n WHERE conversation = ? AND instr(message, '\"marker\":\"job\"') > 0\n AND json_extract(part.value, '$.type') = 'marker'\n AND json_extract(part.value, '$.marker') = 'job'\n ORDER BY position, identity, part.key";
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 answer.turn AS answered,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n COALESCE(\n (SELECT value FROM conversation_facts WHERE conversation = chosen.conversation AND name = 'openedTurn'),\n CASE WHEN julianday(json_extract(answer.message, '$.accepted_at')) < (SELECT julianday(json_extract(value, '$')) FROM replica_facts WHERE name = 'readUntil') THEN answer.turn END\n ) AS opened_turn,\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";
7
5
  export type HeldConversation = {
8
6
  readonly conversation: string;
9
7
  readonly read: string | null | undefined;
@@ -24,6 +22,8 @@ export type HeldRow = {
24
22
  readonly role: string | null;
25
23
  readonly at: string | null;
26
24
  } | null;
25
+ readonly answered: string | null;
26
+ readonly openedTurn: string | null;
27
27
  readonly failure: string | null;
28
28
  readonly opened: HeldSource | null;
29
29
  readonly asking: (HeldSource & {
@@ -32,6 +32,12 @@ export type HeldRow = {
32
32
  readonly at: string | null;
33
33
  }) | null;
34
34
  };
35
+ export type ConversationFact = 'openedTurn' | 'dismissedSuggestion';
36
+ export type HeldFact = {
37
+ readonly conversation: string;
38
+ readonly name: ConversationFact;
39
+ readonly value: string;
40
+ };
35
41
  export type ConversationWrite = {
36
42
  readonly conversation: string;
37
43
  readonly messages: readonly AcceptedMessage[];
@@ -45,7 +51,7 @@ export declare function keptMessages(connection: Connection, { conversation, mes
45
51
  export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null, phrase: string | null): MessageWindow;
46
52
  export declare function messageCount(connection: Connection, conversation: string, phrase: string | null): number;
47
53
  export declare function conversationRows(connection: Connection, conversations: readonly string[]): HeldRow[];
48
- export declare function jobMarkers(connection: Connection, conversation: string): JobMarker[];
49
54
  export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
50
- export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
51
- export declare function forgottenMessages(connection: Connection): void;
55
+ export declare function conversationFacts(connection: Connection): HeldFact[];
56
+ export declare function keptFact(connection: Connection, { conversation, name, value }: HeldFact): null;
57
+ export declare function forgottenConversations(connection: Connection): void;
@@ -0,0 +1 @@
1
+ export declare function shownModal(dialog: HTMLDialogElement): void;
@@ -31,7 +31,7 @@ export type StoredModel = Extract<ModelState, {
31
31
  }> | Omit<Extract<ModelState, {
32
32
  status: 'current' | 'cached';
33
33
  }>, 'types'>;
34
- export type TypesResult = {
34
+ export type TypesResult<Types = readonly MdType[]> = {
35
35
  status: Open<'unavailable'>;
36
36
  reason: ModelUnavailableReason;
37
37
  types: null;
@@ -40,7 +40,7 @@ export type TypesResult = {
40
40
  identity: string;
41
41
  version: string;
42
42
  verifiedWith: ModelIdentity;
43
- types: readonly MdType[];
43
+ types: Types;
44
44
  schema: string | null;
45
45
  revision: string | null;
46
46
  };
@@ -50,6 +50,7 @@ export type ValidationReceipt = {
50
50
  source: Open<'current' | 'cached'>;
51
51
  };
52
52
  export declare const NO_MODEL: ModelState;
53
- export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
53
+ export declare function sortedTypes(types: VerifiedModel['types']): readonly MdType[];
54
54
  export declare function modelTypes(state: ModelState): TypesResult;
55
+ export declare function modelResult<Types>(state: ModelState, types: (held: VerifiedModel['types']) => Types): TypesResult<Types>;
55
56
  export declare function storedModel(state: ModelState): StoredModel;