@agentshouse/mdruntime 0.1.0-c3903a68dcbbf → 0.1.0-c5b50992a4193
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/AGENTS.md +75 -41
- package/README.md +11 -11
- package/dist/adapter.d.ts +81 -51
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +1 -9
- package/dist/attached-model.d.ts +11 -0
- package/dist/attached-model.d.ts.map +1 -0
- package/dist/attached-model.js +47 -0
- package/dist/bootstrap.d.ts +5 -3
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +3 -3
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +2 -6
- package/dist/client.d.ts +4 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -16
- package/dist/collection.d.ts +0 -2
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +2 -12
- package/dist/connection.d.ts +11 -28
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +535 -643
- package/dist/conversation.d.ts +22 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +250 -105
- package/dist/host.d.ts +7 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +37 -57
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/memory.d.ts +11 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +84 -27
- package/dist/model.d.ts +11 -11
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -3
- package/dist/observation.d.ts +2 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +24 -14
- package/dist/outcome.d.ts +5 -21
- package/dist/outcome.d.ts.map +1 -1
- package/dist/paths.d.ts +0 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +0 -16
- package/dist/query.d.ts +8 -3
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +75 -36
- package/dist/reach.d.ts +40 -0
- package/dist/reach.d.ts.map +1 -0
- package/dist/reach.js +270 -0
- package/dist/react.d.ts +32 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +62 -0
- package/dist/read-side.d.ts +4 -0
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +116 -54
- package/dist/refresh.d.ts +2 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +7 -3
- package/dist/replica.d.ts +5 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +16 -21
- package/dist/room-draft.d.ts +3 -0
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +6 -4
- package/dist/rows.d.ts +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +75 -38
- package/dist/save.d.ts +1 -2
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +92 -51
- package/dist/store.d.ts +6 -16
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +10 -32
- package/dist/wire.d.ts +51 -16
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +50 -65
- package/package.json +14 -2
package/dist/host.js
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
import { composeRuntime, } from './connection.js';
|
|
2
2
|
import { removeRuntimeStore } from './store.js';
|
|
3
|
-
import { AUTHORIZATION_ENDED,
|
|
4
|
-
|
|
3
|
+
import { AUTHORIZATION_ENDED, request, WIRE_REACH, } from './wire.js';
|
|
4
|
+
const NARROWED = new Set(['within', 'whole']);
|
|
5
|
+
function answered(md, app, writtenBy, member, input) {
|
|
5
6
|
switch (member) {
|
|
6
7
|
case 'rooms':
|
|
7
8
|
return md.rooms();
|
|
8
|
-
case 'slots':
|
|
9
|
-
return md.slots();
|
|
10
9
|
case 'query':
|
|
11
10
|
return md.query(input[0]);
|
|
12
11
|
case 'search':
|
|
13
12
|
return md.search(input[0]);
|
|
14
13
|
case 'types':
|
|
15
14
|
return md.types(input[0]);
|
|
16
|
-
case 'syncStatus':
|
|
17
|
-
return md.syncStatus();
|
|
18
|
-
case 'serviceMode':
|
|
19
|
-
return md.serviceMode();
|
|
20
15
|
case 'save':
|
|
21
16
|
return md.save(input[0], input[1], writtenBy);
|
|
22
|
-
case 'outcome':
|
|
23
|
-
return md.outcome(input[0]);
|
|
24
17
|
case 'history':
|
|
25
18
|
return md.history(input[0], input[1], input[2]);
|
|
26
19
|
case 'call':
|
|
@@ -29,10 +22,6 @@ function answered(md, app, writtenBy, member, input, deploymentFacts) {
|
|
|
29
22
|
return md.reached(input[0], input[1], input[2]);
|
|
30
23
|
case 'log':
|
|
31
24
|
return md.log();
|
|
32
|
-
case 'storageLoss':
|
|
33
|
-
return md.storageLoss();
|
|
34
|
-
case 'deploymentFacts':
|
|
35
|
-
return structuredClone(deploymentFacts);
|
|
36
25
|
case 'persistence':
|
|
37
26
|
return md.persistence();
|
|
38
27
|
case 'reauthorize':
|
|
@@ -74,7 +63,7 @@ function answered(md, app, writtenBy, member, input, deploymentFacts) {
|
|
|
74
63
|
}
|
|
75
64
|
}
|
|
76
65
|
export function serveMdRuntime(options) {
|
|
77
|
-
|
|
66
|
+
const deploymentFacts = structuredClone(options.deploymentFacts);
|
|
78
67
|
const closing = new AbortController();
|
|
79
68
|
const close = () => {
|
|
80
69
|
closing.abort();
|
|
@@ -83,61 +72,61 @@ export function serveMdRuntime(options) {
|
|
|
83
72
|
if (options.signal?.aborted === true)
|
|
84
73
|
close();
|
|
85
74
|
const runtime = composeRuntime({ ...options, signal: closing.signal });
|
|
86
|
-
const { md
|
|
75
|
+
const { md } = runtime;
|
|
87
76
|
const attachments = new Map();
|
|
88
77
|
let authorized = true;
|
|
89
|
-
const factsObservers = new Set();
|
|
90
78
|
const watchFacts = (deliver) => {
|
|
91
|
-
factsObservers.add(deliver);
|
|
92
79
|
deliver(structuredClone(deploymentFacts));
|
|
93
|
-
return () => {
|
|
94
|
-
factsObservers.delete(deliver);
|
|
95
|
-
};
|
|
80
|
+
return () => { };
|
|
96
81
|
};
|
|
97
|
-
function attach(port, app, release) {
|
|
82
|
+
function attach(port, app, release, reach) {
|
|
98
83
|
if (!authorized)
|
|
99
84
|
throw new Error(AUTHORIZATION_ENDED);
|
|
100
85
|
const writtenBy = release === undefined ? undefined : { app, release };
|
|
101
|
-
const
|
|
86
|
+
const view = runtime.within(reach ?? null);
|
|
87
|
+
const observations = new Map();
|
|
102
88
|
let serving = true;
|
|
103
89
|
const send = (message) => {
|
|
104
|
-
port.postMessage(
|
|
90
|
+
port.postMessage(message);
|
|
105
91
|
};
|
|
106
92
|
const detach = () => {
|
|
107
93
|
if (!serving)
|
|
108
94
|
return;
|
|
109
95
|
serving = false;
|
|
110
|
-
for (const end of
|
|
96
|
+
for (const end of observations.values())
|
|
111
97
|
end();
|
|
112
|
-
|
|
98
|
+
observations.clear();
|
|
113
99
|
attachments.delete(detach);
|
|
114
100
|
};
|
|
101
|
+
const observe = (id, topic, input) => {
|
|
102
|
+
let resolved = false;
|
|
103
|
+
const deliver = (value) => {
|
|
104
|
+
if (!serving)
|
|
105
|
+
return;
|
|
106
|
+
send(resolved ? { kind: 'event', id, value } : { kind: 'result', id, value });
|
|
107
|
+
resolved = true;
|
|
108
|
+
};
|
|
109
|
+
observations.set(id, topic === 'deployment-facts'
|
|
110
|
+
? watchFacts(deliver)
|
|
111
|
+
: (NARROWED.has(WIRE_REACH.topics[topic]) ? view : runtime).watch(topic, topic === 'presentation' ? [app] : input, deliver));
|
|
112
|
+
};
|
|
115
113
|
const serve = async (message) => {
|
|
116
114
|
if (message.kind === 'hello')
|
|
117
115
|
return;
|
|
118
116
|
if (message.kind === 'stop') {
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
observations.get(message.id)?.();
|
|
118
|
+
observations.delete(message.id);
|
|
121
119
|
return;
|
|
122
120
|
}
|
|
123
121
|
try {
|
|
124
122
|
if (message.kind !== 'observe' || message.topic !== 'room-drafts')
|
|
125
123
|
await md.loaded();
|
|
126
124
|
if (message.kind === 'observe') {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const deliver = (value) => {
|
|
130
|
-
if (!serving)
|
|
131
|
-
return;
|
|
132
|
-
send(resolved ? { kind: 'event', id, value } : { kind: 'result', id, value });
|
|
133
|
-
resolved = true;
|
|
134
|
-
};
|
|
135
|
-
subscriptions.set(id, topic === 'deployment-facts'
|
|
136
|
-
? watchFacts(deliver)
|
|
137
|
-
: watch(topic, topic === 'presentation' ? [app] : message.input, deliver));
|
|
125
|
+
if (serving)
|
|
126
|
+
observe(message.id, message.topic, message.input);
|
|
138
127
|
return;
|
|
139
128
|
}
|
|
140
|
-
const value = await answered(md, app, writtenBy, message.member, message.input
|
|
129
|
+
const value = await answered(NARROWED.has(WIRE_REACH.members[message.member]) ? view.md : md, app, writtenBy, message.member, message.input);
|
|
141
130
|
if (serving)
|
|
142
131
|
send({ kind: 'result', id: message.id, value });
|
|
143
132
|
}
|
|
@@ -154,15 +143,7 @@ export function serveMdRuntime(options) {
|
|
|
154
143
|
port.addEventListener('message', (event) => {
|
|
155
144
|
if (!serving)
|
|
156
145
|
return;
|
|
157
|
-
const
|
|
158
|
-
if (wire === null)
|
|
159
|
-
return;
|
|
160
|
-
if (!wire.matching) {
|
|
161
|
-
send({ kind: 'refusal', refusal: PROTOCOL_MISMATCH });
|
|
162
|
-
detach();
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const message = request(wire.message);
|
|
146
|
+
const message = request(event.data);
|
|
166
147
|
if (message === null)
|
|
167
148
|
return;
|
|
168
149
|
void serve(message);
|
|
@@ -170,17 +151,16 @@ export function serveMdRuntime(options) {
|
|
|
170
151
|
port.addEventListener('close', detach);
|
|
171
152
|
port.start();
|
|
172
153
|
attachments.set(detach, send);
|
|
173
|
-
return
|
|
154
|
+
return {
|
|
155
|
+
detach,
|
|
156
|
+
narrow(next) {
|
|
157
|
+
if (serving)
|
|
158
|
+
view.narrow(next);
|
|
159
|
+
},
|
|
160
|
+
};
|
|
174
161
|
}
|
|
175
162
|
return {
|
|
176
163
|
attach,
|
|
177
|
-
replaceDeploymentFacts(value) {
|
|
178
|
-
if (!authorized)
|
|
179
|
-
throw new Error(AUTHORIZATION_ENDED);
|
|
180
|
-
deploymentFacts = structuredClone(value);
|
|
181
|
-
for (const deliver of factsObservers)
|
|
182
|
-
deliver(structuredClone(deploymentFacts));
|
|
183
|
-
},
|
|
184
164
|
async endAuthorization() {
|
|
185
165
|
authorized = false;
|
|
186
166
|
for (const [detach, send] of [...attachments]) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction,
|
|
1
|
+
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldRoom, ListedConversation, MdModelIdentity, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomAttachment, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
|
|
2
2
|
export type { Change, ChangeBatch, Precondition, WrittenBy } from './change.js';
|
|
3
|
-
export type { ChatDraft, ChatDraftSurface, ConversationEntry, ConversationOptions, ConversationSurface, ConversationView,
|
|
3
|
+
export type { ChatDraft, ChatDraftSurface, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
4
4
|
export type { ChatDraftFile, FileDeclaration } from './file.js';
|
|
5
|
-
export type { AppRoom,
|
|
5
|
+
export type { AppRoom, AppTypedSelection, ConnectionRefusal, ConnectionRefusalReason, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedRoomDraft, SaveResult, } from './connection.js';
|
|
6
6
|
export type { Observation } from './observation.js';
|
|
7
|
-
export type {
|
|
7
|
+
export type { CallResult, QueueEntry, Submission } from './outcome.js';
|
|
8
8
|
export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, } from './room-draft.js';
|
|
9
9
|
export type { SaveRefusal } from './save.js';
|
|
10
10
|
export type { DocumentHit, DocumentPart, MessageHit, SearchRequest, SearchResult, } from './search.js';
|
|
11
11
|
export { changeBatchIdentity } from './identity.js';
|
|
12
|
-
export { createMdRuntime } from './connection.js';
|
|
13
12
|
export type { RuntimeShell } from './durability.js';
|
|
14
13
|
export type { AttentionEntry, SyncStatus } from './status.js';
|
|
15
14
|
export type { Backlink, Direction, DocumentQuery, DocumentResult, Filter, GroupQuery, GroupResult, Key, LocalQuery, OrderOptions, Predicate, QueryDocument, QueryGroup, QueryResult, Related, Select, Value, Where, } from './query.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAA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EAAE,MAAM,cAAc,CAAC;AACvE,YAAY,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,YAAY,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,YAAY,EACV,QAAQ,EACR,SAAS,EACT,aAAa,EACb,cAAc,EACd,MAAM,EACN,UAAU,EACV,WAAW,EACX,GAAG,EACH,UAAU,EACV,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,WAAW,EACX,OAAO,EACP,MAAM,EACN,KAAK,EACL,KAAK,GACN,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/memory.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ModelResult } from './model.js';
|
|
2
|
-
import { type AcceptedMessage, type ActionResult, type Adapter, type Capability, type ConversationAction, type ConversationEvent, type DiscoveredRoom, type HeadChange, type
|
|
2
|
+
import { type AcceptedMessage, type ActionResult, type Adapter, type Capability, type ConversationAction, type ConversationEvent, type DiscoveredRoom, type HeadChange, type ListedConversation, type ProviderLimit, type Retention, type RoomAttachment, type ServiceMode } from './adapter.js';
|
|
3
3
|
export type MemoryRoom = DiscoveredRoom & {
|
|
4
4
|
model?: ModelResult;
|
|
5
5
|
selectionModel?: ModelResult;
|
|
@@ -11,6 +11,7 @@ export type MemoryRoom = DiscoveredRoom & {
|
|
|
11
11
|
};
|
|
12
12
|
export type MemoryConversation = {
|
|
13
13
|
conversation: string;
|
|
14
|
+
listed?: Omit<ListedConversation, 'conversation'>;
|
|
14
15
|
messages?: readonly AcceptedMessage[];
|
|
15
16
|
outcomes?: Partial<Record<ConversationAction, ActionResult>>;
|
|
16
17
|
};
|
|
@@ -19,20 +20,25 @@ export type MemoryAdapterOptions = {
|
|
|
19
20
|
conversations?: readonly MemoryConversation[];
|
|
20
21
|
historyPageSize?: number;
|
|
21
22
|
pageSize?: number;
|
|
22
|
-
mdModel?: MdModelIdentity;
|
|
23
|
-
supportedVersions?: readonly number[];
|
|
24
23
|
capabilities?: readonly Capability[];
|
|
25
24
|
providerLimits?: readonly ProviderLimit[];
|
|
26
25
|
retention?: Retention;
|
|
26
|
+
unopened?: boolean;
|
|
27
27
|
};
|
|
28
28
|
export type MemoryAdapter = Adapter & {
|
|
29
29
|
setRooms(rooms: readonly MemoryRoom[]): void;
|
|
30
30
|
setConversations(conversations: readonly MemoryConversation[]): void;
|
|
31
31
|
script(operation: keyof Adapter, answer: unknown): void;
|
|
32
|
-
|
|
32
|
+
open(): void;
|
|
33
|
+
close(revoked?: boolean): void;
|
|
34
|
+
expire(locators: readonly string[]): void;
|
|
35
|
+
notifyRoomVersion(notification: {
|
|
36
|
+
locator: string;
|
|
37
|
+
roomVersion: string;
|
|
38
|
+
}): void;
|
|
33
39
|
notifyConversation(event: ConversationEvent): void;
|
|
34
40
|
notifyServiceMode(mode: ServiceMode): void;
|
|
35
|
-
|
|
41
|
+
heldRooms(): readonly string[];
|
|
36
42
|
replicatedConversations(): readonly string[];
|
|
37
43
|
};
|
|
38
44
|
export declare function createMemoryAdapter(options?: MemoryAdapterOptions): MemoryAdapter;
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,EAIZ,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAItB,KAAK,cAAc,EACnB,KAAK,UAAU,EAGf,KAAK,kBAAkB,EAGvB,KAAK,aAAa,EAGlB,KAAK,SAAS,EACd,KAAK,cAAc,EAGnB,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAkBtB,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG;IACxC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAC/C,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,WAAW,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;IAClD,QAAQ,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IAC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C;CAC9C,CAAC;AA+CF,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CAwbrF"}
|
package/dist/memory.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ROOM_CONTRACT_VERSION, } from './adapter.js';
|
|
2
|
-
import { MD_MODEL } from './collection.js';
|
|
3
1
|
import { sameChange } from './overlay.js';
|
|
4
2
|
const FIXTURE_RETENTION = {
|
|
5
3
|
history: { kind: 'duration', seconds: 1 },
|
|
@@ -15,6 +13,19 @@ function declaredRetention(value) {
|
|
|
15
13
|
}
|
|
16
14
|
throw new Error('history retention duration must be a finite positive number of seconds');
|
|
17
15
|
}
|
|
16
|
+
const MODEL_ABSENT = { kind: 'model-unavailable', reason: 'not-readable' };
|
|
17
|
+
function modelsOf(room) {
|
|
18
|
+
return {
|
|
19
|
+
collection: room.model ?? MODEL_ABSENT,
|
|
20
|
+
...(room.typedSelection === undefined
|
|
21
|
+
? {}
|
|
22
|
+
: { selection: room.selectionModel ?? MODEL_ABSENT }),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function changedModels(room, from) {
|
|
26
|
+
const now = modelsOf(room);
|
|
27
|
+
return JSON.stringify(now) === JSON.stringify(modelsOf(from)) ? undefined : now;
|
|
28
|
+
}
|
|
18
29
|
function named(source, paths) {
|
|
19
30
|
const taken = {};
|
|
20
31
|
for (const path of paths) {
|
|
@@ -31,8 +42,6 @@ async function resolveScript(answer, fallback, request) {
|
|
|
31
42
|
}
|
|
32
43
|
export function createMemoryAdapter(options = {}) {
|
|
33
44
|
let rooms = options.rooms === undefined ? [] : [...options.rooms];
|
|
34
|
-
const mdModel = options.mdModel ?? MD_MODEL;
|
|
35
|
-
const supportedVersions = options.supportedVersions ?? [ROOM_CONTRACT_VERSION];
|
|
36
45
|
const capabilities = options.capabilities ?? [];
|
|
37
46
|
const providerLimits = options.providerLimits ?? [];
|
|
38
47
|
const retention = declaredRetention(options.retention);
|
|
@@ -47,7 +56,8 @@ export function createMemoryAdapter(options = {}) {
|
|
|
47
56
|
const unsealed = new Map();
|
|
48
57
|
const sealed = new Set();
|
|
49
58
|
const historyPageSize = options.historyPageSize;
|
|
50
|
-
let
|
|
59
|
+
let held = [];
|
|
60
|
+
let expiring = [];
|
|
51
61
|
let replicated = [];
|
|
52
62
|
let issued = 0;
|
|
53
63
|
function scriptConversations(entries) {
|
|
@@ -89,12 +99,11 @@ export function createMemoryAdapter(options = {}) {
|
|
|
89
99
|
return {
|
|
90
100
|
name: room.name,
|
|
91
101
|
locator: room.locator,
|
|
102
|
+
handle: room.handle,
|
|
92
103
|
roomVersion: room.roomVersion,
|
|
93
104
|
operations: room.operations,
|
|
94
105
|
replica: room.replica,
|
|
95
|
-
attachedModel: room.attachedModel,
|
|
96
106
|
...(room.typedSelection === undefined ? {} : { typedSelection: room.typedSelection }),
|
|
97
|
-
...(room.untypedFolders === undefined ? {} : { untypedFolders: room.untypedFolders }),
|
|
98
107
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
99
108
|
};
|
|
100
109
|
}
|
|
@@ -107,6 +116,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
107
116
|
return {
|
|
108
117
|
kind: 'bootstrap',
|
|
109
118
|
roomVersion: room.roomVersion,
|
|
119
|
+
...(from === 0 ? { models: modelsOf(room) } : {}),
|
|
110
120
|
documents: named(room.documents ?? {}, taken),
|
|
111
121
|
revisions: named(room.revisions ?? {}, taken),
|
|
112
122
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
@@ -137,9 +147,11 @@ export function createMemoryAdapter(options = {}) {
|
|
|
137
147
|
: [];
|
|
138
148
|
const attachments = room.attachments ?? [];
|
|
139
149
|
const declared = opening && JSON.stringify(attachments) !== JSON.stringify(from.attachments ?? []);
|
|
150
|
+
const models = opening ? changedModels(room, from) : undefined;
|
|
140
151
|
return {
|
|
141
152
|
kind: 'net-advancement',
|
|
142
153
|
roomVersion: room.roomVersion,
|
|
154
|
+
...(models === undefined ? {} : { models }),
|
|
143
155
|
documents: named(current, taken),
|
|
144
156
|
revisions: named(room.revisions ?? {}, taken),
|
|
145
157
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
@@ -222,11 +234,14 @@ export function createMemoryAdapter(options = {}) {
|
|
|
222
234
|
scripted.delete(named);
|
|
223
235
|
return { kind: 'action', result: { conversation: named } };
|
|
224
236
|
}
|
|
237
|
+
function announceList() {
|
|
238
|
+
const entries = [...scripted.values()].flatMap(({ conversation, listed }) => listed === undefined ? [] : [{ conversation, ...listed }]);
|
|
239
|
+
for (const listener of listeners)
|
|
240
|
+
listener({ kind: 'list', entries });
|
|
241
|
+
}
|
|
225
242
|
function discovery() {
|
|
226
243
|
return {
|
|
227
244
|
kind: 'discovery',
|
|
228
|
-
supportedVersions,
|
|
229
|
-
mdModel,
|
|
230
245
|
rooms: rooms.map(declared),
|
|
231
246
|
capabilities,
|
|
232
247
|
providerLimits,
|
|
@@ -241,9 +256,21 @@ export function createMemoryAdapter(options = {}) {
|
|
|
241
256
|
setConversations(next) {
|
|
242
257
|
scriptConversations(next);
|
|
243
258
|
},
|
|
244
|
-
|
|
259
|
+
open() {
|
|
260
|
+
announceList();
|
|
261
|
+
for (const observer of observers)
|
|
262
|
+
observer({ kind: 'opened' });
|
|
263
|
+
},
|
|
264
|
+
close(revoked = false) {
|
|
265
|
+
for (const observer of observers)
|
|
266
|
+
observer({ kind: 'closed', revoked });
|
|
267
|
+
},
|
|
268
|
+
expire(locators) {
|
|
269
|
+
expiring = [...locators];
|
|
270
|
+
},
|
|
271
|
+
notifyRoomVersion({ locator, roomVersion }) {
|
|
245
272
|
for (const observer of observers)
|
|
246
|
-
observer(
|
|
273
|
+
observer({ kind: 'room-version', locator, roomVersion });
|
|
247
274
|
},
|
|
248
275
|
notifyConversation(event) {
|
|
249
276
|
if (event.kind === 'accepted-message') {
|
|
@@ -257,8 +284,8 @@ export function createMemoryAdapter(options = {}) {
|
|
|
257
284
|
for (const observer of modeObservers)
|
|
258
285
|
observer(mode);
|
|
259
286
|
},
|
|
260
|
-
|
|
261
|
-
return
|
|
287
|
+
heldRooms() {
|
|
288
|
+
return held;
|
|
262
289
|
},
|
|
263
290
|
replicatedConversations() {
|
|
264
291
|
return replicated;
|
|
@@ -282,12 +309,45 @@ export function createMemoryAdapter(options = {}) {
|
|
|
282
309
|
};
|
|
283
310
|
},
|
|
284
311
|
},
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
312
|
+
roomStream: {
|
|
313
|
+
hold(asked) {
|
|
314
|
+
held = asked.map((room) => room.locator);
|
|
315
|
+
const expired = expiring.filter((locator) => held.includes(locator));
|
|
316
|
+
expiring = [];
|
|
317
|
+
const moved = asked.flatMap((room) => {
|
|
318
|
+
const current = rooms.find((entry) => entry.locator === room.locator);
|
|
319
|
+
return current === undefined ||
|
|
320
|
+
expired.includes(room.locator) ||
|
|
321
|
+
current.roomVersion === room.roomVersion
|
|
322
|
+
? []
|
|
323
|
+
: [{ locator: room.locator, roomVersion: current.roomVersion }];
|
|
324
|
+
});
|
|
325
|
+
queueMicrotask(() => {
|
|
326
|
+
for (const observer of observers) {
|
|
327
|
+
for (const room of moved)
|
|
328
|
+
observer({ kind: 'room-version', ...room });
|
|
329
|
+
observer({ kind: 'opening', expired });
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
},
|
|
333
|
+
reopen() {
|
|
334
|
+
queueMicrotask(() => {
|
|
335
|
+
for (const observer of observers)
|
|
336
|
+
observer({ kind: 'closed', revoked: false });
|
|
337
|
+
});
|
|
288
338
|
},
|
|
289
339
|
observe(notify) {
|
|
290
340
|
observers.add(notify);
|
|
341
|
+
queueMicrotask(() => {
|
|
342
|
+
if (!observers.has(notify))
|
|
343
|
+
return;
|
|
344
|
+
if (options.unopened === true) {
|
|
345
|
+
notify({ kind: 'closed', revoked: false });
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
announceList();
|
|
349
|
+
notify({ kind: 'opened' });
|
|
350
|
+
});
|
|
291
351
|
return () => {
|
|
292
352
|
observers.delete(notify);
|
|
293
353
|
};
|
|
@@ -299,13 +359,6 @@ export function createMemoryAdapter(options = {}) {
|
|
|
299
359
|
else
|
|
300
360
|
scripts[operation] = answer;
|
|
301
361
|
},
|
|
302
|
-
async model(_authorization, request) {
|
|
303
|
-
return resolveScript(scripts.model, () => {
|
|
304
|
-
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
305
|
-
const answer = request.attached === 'collection' ? room?.model : room?.selectionModel;
|
|
306
|
-
return answer ?? { kind: 'model-unavailable', reason: 'not-readable' };
|
|
307
|
-
}, request);
|
|
308
|
-
},
|
|
309
362
|
async authorize() {
|
|
310
363
|
return resolveScript(scripts.authorize, () => ({}), undefined);
|
|
311
364
|
},
|
|
@@ -318,6 +371,14 @@ export function createMemoryAdapter(options = {}) {
|
|
|
318
371
|
});
|
|
319
372
|
},
|
|
320
373
|
reached,
|
|
374
|
+
follows(locator, roomVersion, next) {
|
|
375
|
+
const scripted = scripts.follows;
|
|
376
|
+
if (typeof scripted === 'boolean')
|
|
377
|
+
return scripted;
|
|
378
|
+
if (scripted !== undefined)
|
|
379
|
+
return scripted(locator, roomVersion, next);
|
|
380
|
+
return true;
|
|
381
|
+
},
|
|
321
382
|
async bootstrap(_authorization, request) {
|
|
322
383
|
return resolveScript(scripts.bootstrap, () => {
|
|
323
384
|
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
@@ -342,10 +403,6 @@ export function createMemoryAdapter(options = {}) {
|
|
|
342
403
|
}
|
|
343
404
|
return advancement(continuation.room, continuation.from, continuation.at);
|
|
344
405
|
}
|
|
345
|
-
if (request.minPosition !== undefined &&
|
|
346
|
-
!reached(room.locator, room.roomVersion, request.minPosition)) {
|
|
347
|
-
return { kind: 'retryable-refusal', code: 'replica_behind', fields: {} };
|
|
348
|
-
}
|
|
349
406
|
if (request.fromRoomVersion === room.roomVersion) {
|
|
350
407
|
return { kind: 'still-current' };
|
|
351
408
|
}
|
package/dist/model.d.ts
CHANGED
|
@@ -1,31 +1,26 @@
|
|
|
1
|
-
import type { Definition,
|
|
1
|
+
import type { Definition, ValueFacts, VerifiedModel } from '@agentshouse/mdmodel';
|
|
2
2
|
export type ModelIdentity = {
|
|
3
3
|
identity: string;
|
|
4
4
|
version: string;
|
|
5
5
|
};
|
|
6
6
|
export type ModelSnapshot = ModelIdentity & {
|
|
7
7
|
schema: string | null;
|
|
8
|
+
revision: string | null;
|
|
8
9
|
};
|
|
9
|
-
export type ModelUnavailableReason = 'not-readable' | 'revoked' | 'not-acquired' | '
|
|
10
|
+
export type ModelUnavailableReason = 'not-readable' | 'revoked' | 'not-acquired' | 'invalid';
|
|
10
11
|
export type ModelResult = {
|
|
11
12
|
kind: 'model';
|
|
12
13
|
snapshot: ModelSnapshot;
|
|
13
14
|
} | {
|
|
14
15
|
kind: 'model-unavailable';
|
|
15
16
|
reason: ModelUnavailableReason;
|
|
16
|
-
} | {
|
|
17
|
-
kind: 'transport-uncertainty';
|
|
18
|
-
} | {
|
|
19
|
-
kind: 'revoked-authorization';
|
|
20
|
-
};
|
|
21
|
-
export type MdType = {
|
|
22
|
-
name: string;
|
|
23
|
-
fields: Readonly<Record<string, FieldSpec>>;
|
|
24
|
-
sections: Readonly<Record<string, SectionSpec>>;
|
|
25
17
|
};
|
|
18
|
+
export type MdType = Definition;
|
|
26
19
|
export type ModelState = {
|
|
27
20
|
status: 'unavailable';
|
|
28
21
|
reason: ModelUnavailableReason;
|
|
22
|
+
schema?: string | null;
|
|
23
|
+
revision?: string | null;
|
|
29
24
|
} | {
|
|
30
25
|
status: 'current' | 'cached';
|
|
31
26
|
snapshot: ModelSnapshot;
|
|
@@ -35,12 +30,16 @@ export type ModelState = {
|
|
|
35
30
|
export type TypesResult = {
|
|
36
31
|
status: 'unavailable';
|
|
37
32
|
reason: ModelUnavailableReason;
|
|
33
|
+
schema?: string | null;
|
|
34
|
+
revision?: string | null;
|
|
38
35
|
} | {
|
|
39
36
|
status: 'current' | 'cached';
|
|
40
37
|
identity: string;
|
|
41
38
|
version: string;
|
|
42
39
|
verifiedWith: ModelIdentity;
|
|
43
40
|
types: readonly MdType[];
|
|
41
|
+
schema: string | null;
|
|
42
|
+
revision: string | null;
|
|
44
43
|
};
|
|
45
44
|
export type ValidationReceipt = {
|
|
46
45
|
identity: string;
|
|
@@ -52,4 +51,5 @@ export declare function definitionOf(state: ModelState, type: string | undefined
|
|
|
52
51
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
53
52
|
export declare function cached(state: ModelState): ModelState;
|
|
54
53
|
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
54
|
+
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
55
55
|
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAElF,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAC/F,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG,SAAS,GAAG,cAAc,GAAG,SAAS,CAAC;AAC7F,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,mBA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G,SAAS,CAGhG;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAgBzD;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAEpD;AACD,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAE5E;AACD,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAErE"}
|
package/dist/model.js
CHANGED
|
@@ -12,9 +12,9 @@ export function modelTypes(state) {
|
|
|
12
12
|
identity: state.snapshot.identity,
|
|
13
13
|
version: state.snapshot.version,
|
|
14
14
|
verifiedWith: { ...state.verifiedWith },
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
schema: state.snapshot.schema,
|
|
16
|
+
revision: state.snapshot.revision,
|
|
17
|
+
types: structuredClone(Object.values(state.types).sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0)),
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
export function cached(state) {
|
|
@@ -23,3 +23,6 @@ export function cached(state) {
|
|
|
23
23
|
export function sameModel(left, right) {
|
|
24
24
|
return left.identity === right.identity && left.version === right.version;
|
|
25
25
|
}
|
|
26
|
+
export function referenceField(facts) {
|
|
27
|
+
return facts?.reference !== undefined || facts?.items?.reference !== undefined;
|
|
28
|
+
}
|
package/dist/observation.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export type Observed = {
|
|
|
20
20
|
end(): void;
|
|
21
21
|
};
|
|
22
22
|
export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
|
|
23
|
+
export declare function applied(keyed: KeyedResult, change: QueryChange): KeyedResult;
|
|
23
24
|
export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
|
|
24
25
|
export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
26
|
+
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>>;
|
|
25
27
|
//# sourceMappingURL=observation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzE,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,IAAI,CAAC,CAAC;IACb,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACpD,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC;IACpE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC,GAAG,IAAI,IAAI,CAAC;CACb,CAAC;AAEF,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC,aAAa,GAAG,UAAU,CAAC,EAAE,CAEnF;
|
|
1
|
+
{"version":3,"file":"observation.d.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