@agentshouse/mdruntime 0.1.0-cfb2ae0107054 → 0.1.0-cfcbb238a5fa0
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 +262 -262
- package/dist/acquisition.d.ts +14 -0
- package/dist/acquisition.d.ts.map +1 -0
- package/dist/acquisition.js +24 -0
- package/dist/adapter.d.ts +14 -7
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +2 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +4 -0
- package/dist/change-set.d.ts +2 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +36 -10
- package/dist/chat/kit.d.ts +2 -1
- package/dist/chat/kit.d.ts.map +1 -1
- package/dist/chat/kit.js +3 -3
- package/dist/chat/list.d.ts +2 -1
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +4 -3
- package/dist/chat/message.d.ts.map +1 -1
- package/dist/chat/message.js +2 -2
- package/dist/chat/messages.d.ts +1 -0
- package/dist/chat/messages.d.ts.map +1 -1
- package/dist/chat/messages.js +4 -0
- package/dist/chat/provider.d.ts +1 -1
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +26 -17
- package/dist/chat/ready.d.ts +1 -0
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +2 -2
- package/dist/client.d.ts +10 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +11 -2
- package/dist/collection.d.ts +17 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +230 -19
- package/dist/connection.d.ts +23 -7
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1065 -192
- package/dist/conversation.d.ts +11 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +241 -100
- package/dist/durability.d.ts +7 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +2 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +3 -3
- package/dist/host.d.ts +16 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +82 -8
- package/dist/identity.d.ts +2 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +6 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/memory.d.ts +7 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +20 -7
- package/dist/model.d.ts +4 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +10 -1
- package/dist/observation.d.ts +5 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +22 -11
- package/dist/overlay.d.ts +2 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +58 -55
- package/dist/query.d.ts +35 -3
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +8 -2
- package/dist/reach.d.ts +6 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +16 -4
- package/dist/react.d.ts +7 -4
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +6 -4
- package/dist/read-side.d.ts +13 -6
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +285 -83
- package/dist/readiness.d.ts +53 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +33 -0
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +98 -0
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +197 -0
- package/dist/refresh.d.ts +4 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +17 -10
- package/dist/replica.d.ts +1 -1
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +57 -20
- package/dist/room-draft.d.ts +13 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +2 -2
- package/dist/rows.d.ts +5 -13
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +5 -13
- package/dist/save.d.ts +5 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +36 -13
- package/dist/search.d.ts +36 -6
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +132 -46
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +61 -0
- package/dist/shared.d.ts +11 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +368 -0
- package/dist/status.d.ts +4 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/store.d.ts +21 -5
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +157 -53
- package/dist/turn.d.ts +7 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +45 -0
- package/dist/wire.d.ts +136 -32
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +48 -31
- package/package.json +2 -2
package/dist/durability.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import type { Persistence } from './readiness.js';
|
|
2
|
+
export type StorageEstimate = {
|
|
3
|
+
readonly usage: number;
|
|
4
|
+
readonly quota: number;
|
|
5
|
+
};
|
|
1
6
|
export type RuntimeShell = {
|
|
2
|
-
|
|
7
|
+
persistence: Persistence;
|
|
3
8
|
generation: string | null;
|
|
4
9
|
keepGeneration(value: string): void | Promise<void>;
|
|
5
10
|
dropGeneration(): void | Promise<void>;
|
|
11
|
+
estimate?(): Promise<StorageEstimate | null>;
|
|
6
12
|
};
|
|
7
13
|
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
|
8
14
|
export declare function nextGeneration(stored: string | null, reported: string | null): string;
|
package/dist/durability.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,cAAc,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,QAAQ,CAAC,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;CAC9C,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAG/F;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGrF"}
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type QueryRows } from './query.js';
|
|
2
2
|
export { QueryError } from './query.js';
|
|
3
3
|
export type EntryRoom = {
|
|
4
4
|
locator: string;
|
|
@@ -11,7 +11,7 @@ export declare function boundQuery(template: unknown, args: EntryArguments): unk
|
|
|
11
11
|
export declare function entryParameters(template: unknown): readonly string[];
|
|
12
12
|
export declare function entryRefusal(template: unknown): string | null;
|
|
13
13
|
export type EntryScope = {
|
|
14
|
-
results(queries: Readonly<Record<string, unknown>>): Promise<Record<string,
|
|
14
|
+
results(queries: Readonly<Record<string, unknown>>): Promise<Record<string, QueryRows>>;
|
|
15
15
|
};
|
|
16
16
|
export declare function entryScope(rooms: readonly EntryRoom[]): EntryScope;
|
|
17
17
|
//# sourceMappingURL=entry.d.ts.map
|
package/dist/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,SAAS,EAEf,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9D,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AA0D7E,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAE3E;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAMpE;AAkCD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAQ7D;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;CACzF,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,UAAU,CAsDlE"}
|
package/dist/entry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { attachedModel } from './attached-model.js';
|
|
2
|
-
import { collectionOf,
|
|
2
|
+
import { collectionOf, passingFrontmatter } from './collection.js';
|
|
3
3
|
import { NO_MODEL } from './model.js';
|
|
4
4
|
import { invalid, planOf, plain, QueryError, } from './query.js';
|
|
5
5
|
import { createReadSide } from './read-side.js';
|
|
@@ -131,7 +131,7 @@ export function entryScope(rooms) {
|
|
|
131
131
|
locator: room.locator,
|
|
132
132
|
path,
|
|
133
133
|
before: [],
|
|
134
|
-
after: rowsOf(room.locator, path,
|
|
134
|
+
after: rowsOf(room.locator, path, passingFrontmatter(collection, path) ?? null, composition, null, null, null),
|
|
135
135
|
}));
|
|
136
136
|
});
|
|
137
137
|
readSide.apply({
|
|
@@ -148,7 +148,7 @@ export function entryScope(rooms) {
|
|
|
148
148
|
async results(queries) {
|
|
149
149
|
const results = {};
|
|
150
150
|
for (const [name, query] of Object.entries(queries)) {
|
|
151
|
-
results[name] = await readSide.query(planOf(query, planned));
|
|
151
|
+
results[name] = (await readSide.query(planOf(query, planned), () => null)).rows;
|
|
152
152
|
}
|
|
153
153
|
return results;
|
|
154
154
|
},
|
package/dist/host.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type MdRuntimeOptions } from './connection.js';
|
|
2
|
+
import type { RuntimeDemand } from './acquisition.js';
|
|
2
3
|
import type { PortReach } from './reach.js';
|
|
4
|
+
import type { CapacityCause, CodeAvailability, Persistence, Readiness, SearchObligation } from './readiness.js';
|
|
5
|
+
import type { EntrySeed } from './seed.js';
|
|
3
6
|
import { type RuntimePort } from './wire.js';
|
|
4
7
|
export type MdRuntimeHostOptions = MdRuntimeOptions & {
|
|
5
8
|
deploymentFacts?: unknown;
|
|
@@ -7,15 +10,26 @@ export type MdRuntimeHostOptions = MdRuntimeOptions & {
|
|
|
7
10
|
export type AttachedPort = {
|
|
8
11
|
detach(): void;
|
|
9
12
|
narrow(reach: PortReach): void;
|
|
13
|
+
readiness(deliver: (readiness: Readiness) => void): () => void;
|
|
14
|
+
answered(queries: readonly unknown[], done: () => void): void;
|
|
15
|
+
code(code: CodeAvailability, capacity: CapacityCause | null): void;
|
|
16
|
+
search(search: SearchObligation): void;
|
|
10
17
|
};
|
|
11
18
|
export type MdRuntimeHost = {
|
|
12
|
-
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach): AttachedPort;
|
|
19
|
+
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach, code?: CodeAvailability, search?: SearchObligation): AttachedPort;
|
|
20
|
+
acquire(demand: RuntimeDemand): void;
|
|
21
|
+
seed(entry: EntrySeed): void;
|
|
22
|
+
persisted(answer: Persistence): void;
|
|
13
23
|
endAuthorization(holder?: string): Promise<void>;
|
|
14
24
|
lose(locators: readonly string[]): Promise<void>;
|
|
15
25
|
stop(): Promise<void>;
|
|
16
26
|
};
|
|
17
27
|
export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
|
|
28
|
+
export type { RuntimeDemand } from './acquisition.js';
|
|
29
|
+
export { entrySeedOf, type EntrySeed } from './seed.js';
|
|
18
30
|
export type { PortReach, ReachedDocument } from './reach.js';
|
|
19
|
-
export {
|
|
31
|
+
export type { CapacityCause, CodeAvailability, Persistence, SearchObligation, } from './readiness.js';
|
|
32
|
+
export { createRecovery, retryDelay, type Attempt, type Attempted, type AttemptOptions, type Recovery, type RecoveryOptions, } from './recovery.js';
|
|
33
|
+
export { AUTHORED_SCHEMA, authoredBinding, authoredBy, authoredHolder, bindAuthored, openDatabase, STORE_SCHEMA, } from './store.js';
|
|
20
34
|
export type { RuntimePort } from './wire.js';
|
|
21
35
|
//# sourceMappingURL=host.d.ts.map
|
package/dist/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAEA,OAAO,E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,MAAM,CAAC,EAAE,gBAAgB,GACxB,YAAY,CAAC;IAChB,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IACrC,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC;AAqGF,wBAAgB,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAyK3E;AAED,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACxD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,cAAc,EACd,UAAU,EACV,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,eAAe,EACf,eAAe,EACf,UAAU,EACV,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/host.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { composeRuntime, } from './connection.js';
|
|
2
|
+
import { queryKey } from './query.js';
|
|
2
3
|
import { described } from './failure.js';
|
|
3
4
|
import { removeRuntimeStore } from './store.js';
|
|
4
|
-
import { AUTHORIZATION_ENDED, request,
|
|
5
|
+
import { AUTHORIZATION_ENDED, request, WIRE, } from './wire.js';
|
|
5
6
|
const NARROWED = new Set(['within', 'whole']);
|
|
6
7
|
function answered(md, app, writtenBy, member, input) {
|
|
7
8
|
switch (member) {
|
|
@@ -29,6 +30,8 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
29
30
|
return md.log();
|
|
30
31
|
case 'persistence':
|
|
31
32
|
return md.persistence();
|
|
33
|
+
case 'retry':
|
|
34
|
+
return md.retry();
|
|
32
35
|
case 'reauthorize':
|
|
33
36
|
return md.reauthorize();
|
|
34
37
|
case 'roomDraft.list':
|
|
@@ -67,6 +70,14 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
67
70
|
return md.chatDraft.discard(input[0]);
|
|
68
71
|
}
|
|
69
72
|
}
|
|
73
|
+
function answeredResult(value) {
|
|
74
|
+
return typeof value === 'object' && value !== null && !('pending' in value);
|
|
75
|
+
}
|
|
76
|
+
function answeredMessage(value) {
|
|
77
|
+
if (typeof value !== 'object' || value === null)
|
|
78
|
+
return false;
|
|
79
|
+
return !('result' in value) || answeredResult(value.result);
|
|
80
|
+
}
|
|
70
81
|
export function serveMdRuntime(options) {
|
|
71
82
|
const deploymentFacts = structuredClone(options.deploymentFacts);
|
|
72
83
|
const closing = new AbortController();
|
|
@@ -84,13 +95,25 @@ export function serveMdRuntime(options) {
|
|
|
84
95
|
deliver(structuredClone(deploymentFacts));
|
|
85
96
|
return () => { };
|
|
86
97
|
};
|
|
87
|
-
function attach(port, app, release, reach) {
|
|
98
|
+
function attach(port, app, release, reach, code = 'stored', search = 'unused') {
|
|
88
99
|
if (!authorized)
|
|
89
100
|
throw new Error(AUTHORIZATION_ENDED);
|
|
90
101
|
const writtenBy = release === undefined ? undefined : { app, release };
|
|
91
|
-
|
|
102
|
+
let facts = { target: app, code, capacity: null, search };
|
|
103
|
+
const view = runtime.within(reach ?? null, facts);
|
|
92
104
|
const observations = new Map();
|
|
105
|
+
const followed = new Set();
|
|
106
|
+
const answeredKeys = new Set();
|
|
107
|
+
let awaited = null;
|
|
93
108
|
let serving = true;
|
|
109
|
+
const answeredQuery = (query) => {
|
|
110
|
+
answeredKeys.add(queryKey(query));
|
|
111
|
+
if (awaited === null || !awaited.keys.every((key) => answeredKeys.has(key)))
|
|
112
|
+
return;
|
|
113
|
+
const { done } = awaited;
|
|
114
|
+
awaited = null;
|
|
115
|
+
done();
|
|
116
|
+
};
|
|
94
117
|
const send = (message) => {
|
|
95
118
|
port.postMessage(message);
|
|
96
119
|
};
|
|
@@ -101,6 +124,8 @@ export function serveMdRuntime(options) {
|
|
|
101
124
|
for (const end of observations.values())
|
|
102
125
|
end();
|
|
103
126
|
observations.clear();
|
|
127
|
+
for (const end of [...followed])
|
|
128
|
+
end();
|
|
104
129
|
attachments.delete(detach);
|
|
105
130
|
};
|
|
106
131
|
const observe = (id, topic, input) => {
|
|
@@ -110,10 +135,12 @@ export function serveMdRuntime(options) {
|
|
|
110
135
|
return;
|
|
111
136
|
send(resolved ? { kind: 'event', id, value } : { kind: 'result', id, value });
|
|
112
137
|
resolved = true;
|
|
138
|
+
if (topic === 'query' && answeredMessage(value))
|
|
139
|
+
answeredQuery(input[0]);
|
|
113
140
|
};
|
|
114
141
|
observations.set(id, topic === 'deployment-facts'
|
|
115
142
|
? watchFacts(deliver)
|
|
116
|
-
: (NARROWED.has(
|
|
143
|
+
: (NARROWED.has(WIRE.topics[topic]) ? view : runtime).watch(topic, topic === 'presentation' ? [app] : input, deliver));
|
|
117
144
|
};
|
|
118
145
|
const serve = async (message) => {
|
|
119
146
|
if (message.kind === 'hello')
|
|
@@ -131,9 +158,12 @@ export function serveMdRuntime(options) {
|
|
|
131
158
|
observe(message.id, message.topic, message.input);
|
|
132
159
|
return;
|
|
133
160
|
}
|
|
134
|
-
const value = await answered(NARROWED.has(
|
|
135
|
-
if (serving)
|
|
136
|
-
|
|
161
|
+
const value = await answered(NARROWED.has(WIRE.members[message.member].reach) ? view.md : md, app, writtenBy, message.member, message.input);
|
|
162
|
+
if (!serving)
|
|
163
|
+
return;
|
|
164
|
+
send({ kind: 'result', id: message.id, value });
|
|
165
|
+
if (message.member === 'query' && answeredResult(value))
|
|
166
|
+
answeredQuery(message.input[0]);
|
|
137
167
|
}
|
|
138
168
|
catch (error) {
|
|
139
169
|
if (serving)
|
|
@@ -157,10 +187,52 @@ export function serveMdRuntime(options) {
|
|
|
157
187
|
if (serving)
|
|
158
188
|
view.narrow(next);
|
|
159
189
|
},
|
|
190
|
+
code(next, capacity) {
|
|
191
|
+
if (!serving)
|
|
192
|
+
return;
|
|
193
|
+
facts = { ...facts, code: next, capacity };
|
|
194
|
+
view.facts(facts);
|
|
195
|
+
},
|
|
196
|
+
search(next) {
|
|
197
|
+
if (!serving)
|
|
198
|
+
return;
|
|
199
|
+
facts = { ...facts, search: next };
|
|
200
|
+
view.facts(facts);
|
|
201
|
+
},
|
|
202
|
+
answered(queries, done) {
|
|
203
|
+
const keys = queries.map(queryKey);
|
|
204
|
+
if (keys.every((key) => answeredKeys.has(key)))
|
|
205
|
+
done();
|
|
206
|
+
else
|
|
207
|
+
awaited = { keys, done };
|
|
208
|
+
},
|
|
209
|
+
readiness(deliver) {
|
|
210
|
+
if (!serving)
|
|
211
|
+
return () => { };
|
|
212
|
+
const stop = view.watch('readiness', [], (value) => {
|
|
213
|
+
if (serving)
|
|
214
|
+
deliver(value);
|
|
215
|
+
});
|
|
216
|
+
const end = () => {
|
|
217
|
+
followed.delete(end);
|
|
218
|
+
stop();
|
|
219
|
+
};
|
|
220
|
+
followed.add(end);
|
|
221
|
+
return end;
|
|
222
|
+
},
|
|
160
223
|
};
|
|
161
224
|
}
|
|
162
225
|
return {
|
|
163
226
|
attach,
|
|
227
|
+
acquire(demand) {
|
|
228
|
+
runtime.acquire(demand);
|
|
229
|
+
},
|
|
230
|
+
seed(entry) {
|
|
231
|
+
runtime.seed(entry);
|
|
232
|
+
},
|
|
233
|
+
persisted(answer) {
|
|
234
|
+
runtime.persisted(answer);
|
|
235
|
+
},
|
|
164
236
|
async endAuthorization(holder) {
|
|
165
237
|
authorized = false;
|
|
166
238
|
for (const [detach, send] of [...attachments]) {
|
|
@@ -179,4 +251,6 @@ export function serveMdRuntime(options) {
|
|
|
179
251
|
},
|
|
180
252
|
};
|
|
181
253
|
}
|
|
182
|
-
export {
|
|
254
|
+
export { entrySeedOf } from './seed.js';
|
|
255
|
+
export { createRecovery, retryDelay, } from './recovery.js';
|
|
256
|
+
export { AUTHORED_SCHEMA, authoredBinding, authoredBy, authoredHolder, bindAuthored, openDatabase, STORE_SCHEMA, } from './store.js';
|
package/dist/identity.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare function changeBatchIdentity(at?: number): string;
|
|
2
|
+
export declare function identityTime(identity: string): number;
|
|
2
3
|
export declare function roomDraftRevision(): string;
|
|
3
4
|
export declare function chatDraftRevision(): string;
|
|
4
5
|
export declare function transferIdentity(): string;
|
|
6
|
+
export declare function indexGeneration(): string;
|
|
5
7
|
export declare function binaryLocalId(): string;
|
|
6
8
|
//# sourceMappingURL=identity.d.ts.map
|
package/dist/identity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErD;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|
package/dist/identity.js
CHANGED
|
@@ -10,6 +10,9 @@ export function changeBatchIdentity(at = Date.now()) {
|
|
|
10
10
|
const hex = [...bytes].map((byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
11
11
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
12
12
|
}
|
|
13
|
+
export function identityTime(identity) {
|
|
14
|
+
return Number.parseInt(identity.replaceAll('-', '').slice(0, 12), 16);
|
|
15
|
+
}
|
|
13
16
|
function randomIdentity() {
|
|
14
17
|
const bytes = new Uint8Array(16);
|
|
15
18
|
crypto.getRandomValues(bytes);
|
|
@@ -24,6 +27,9 @@ export function chatDraftRevision() {
|
|
|
24
27
|
export function transferIdentity() {
|
|
25
28
|
return randomIdentity();
|
|
26
29
|
}
|
|
30
|
+
export function indexGeneration() {
|
|
31
|
+
return randomIdentity();
|
|
32
|
+
}
|
|
27
33
|
export function binaryLocalId() {
|
|
28
34
|
return randomIdentity();
|
|
29
35
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryRequest, BinaryResult, ReferrerScope, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldContent, HeldRoom, KeptReceipt, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, StreamReceipts, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
|
|
1
|
+
export type { AcquiredDemand, AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryRequest, BinaryResult, ReferrerScope, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldContent, HeldRoom, KeptReceipt, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, StreamReceipts, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
|
|
2
2
|
export type { Change, ChangeBatch, Precondition, WrittenBy } from './change.js';
|
|
3
3
|
export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
4
4
|
export type { ChatDraftFile, FileDeclaration } from './file.js';
|
|
@@ -7,16 +7,19 @@ export type { Observation } from './observation.js';
|
|
|
7
7
|
export type { BinaryAnswer, CallResult, Failure, HistoryAnswer, Offline, QueueEntry, Submission, } from './outcome.js';
|
|
8
8
|
export type { BinaryFileRecord, BinaryReference } from './binary.js';
|
|
9
9
|
export type { RuntimeError } from './failure.js';
|
|
10
|
-
export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, } from './room-draft.js';
|
|
10
|
+
export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, TextParts, } from './room-draft.js';
|
|
11
11
|
export type { SaveRefusal } from './save.js';
|
|
12
|
-
export type { DocumentHit, DocumentPart, MessageHit, SearchRequest, SearchResult, } from './search.js';
|
|
12
|
+
export type { DocumentHit, DocumentPart, MessageHit, PendingConversation, SearchCoverage, SearchHits, SearchPending, SearchRequest, SearchResult, SearchUndeclared, } from './search.js';
|
|
13
13
|
export { departure } from './change.js';
|
|
14
|
+
export { partsAfter } from './room-draft.js';
|
|
15
|
+
export { SESSION_STARTED } from './conversation.js';
|
|
14
16
|
export { changeBatchIdentity } from './identity.js';
|
|
15
17
|
export { attempts, identities, intentOf, type Answered, type Attempt, type Attempts, type Identities, } from './attempt.js';
|
|
16
18
|
export { expectedList, expecting, type ExpectedOf, type Expecting } from './expectation.js';
|
|
17
|
-
export type { RuntimeShell } from './durability.js';
|
|
19
|
+
export type { RuntimeShell, StorageEstimate } from './durability.js';
|
|
20
|
+
export type { CapacityCause, CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Persistence, Readiness, ReadinessStatus, RefusedRoom, RoomCoverage, RoomPreparation, SearchObligation, TargetCoverage, } from './readiness.js';
|
|
18
21
|
export type { AttentionEntry, SyncStatus } from './status.js';
|
|
19
|
-
export type { Backlink, Direction, DocumentQuery, DocumentResult, Filter, GroupQuery, GroupResult, Key, LocalQuery, OrderOptions, Predicate, QueryDocument, QueryGroup, QueryResult, Related, Select, Value, Where, } from './query.js';
|
|
22
|
+
export type { Awaits, Backlink, CoveredRoom, Direction, DocumentQuery, DocumentResult, Filter, GroupQuery, GroupResult, Key, LocalQuery, OrderOptions, PendingResult, PendingRoom, Predicate, QueryCoverage, QueryDocument, QueryGroup, QueryResult, QueryRows, Related, Select, Value, Where, } from './query.js';
|
|
20
23
|
export type { MdType, ModelIdentity, ModelSnapshot, ModelState, ModelResult, TypesResult, ValidationReceipt, } from './model.js';
|
|
21
24
|
export type { OperationScopes, ReplicaAdmission, ScopedRefusal } from './adapter.js';
|
|
22
25
|
//# sourceMappingURL=index.d.ts.map
|
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,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,UAAU,EACV,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAChF,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAChE,YAAY,EACV,OAAO,EACP,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EACV,YAAY,EACZ,UAAU,EACV,OAAO,EACP,aAAa,EACb,OAAO,EACP,UAAU,EACV,UAAU,GACX,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACrE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B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WAAW,EACX,GAAG,EACH,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,SAAS,EACT,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
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { departure } from './change.js';
|
|
2
|
+
export { partsAfter } from './room-draft.js';
|
|
3
|
+
export { SESSION_STARTED } from './conversation.js';
|
|
2
4
|
export { changeBatchIdentity } from './identity.js';
|
|
3
5
|
export { attempts, identities, intentOf, } from './attempt.js';
|
|
4
6
|
export { expectedList, expecting } from './expectation.js';
|
package/dist/memory.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ModelResult } from './model.js';
|
|
2
|
-
import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveredRoom, type HeadChange, type ListedConversation, type Member, type ProviderLimit, type Retention, type ServiceMode } from './adapter.js';
|
|
2
|
+
import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveredRoom, type HeadChange, type ListedConversation, type Member, type ProviderLimit, type Retention, type AcquiredDemand, type ServiceMode } from './adapter.js';
|
|
3
3
|
export type MemoryRoom = DiscoveredRoom & {
|
|
4
4
|
model?: ModelResult;
|
|
5
5
|
selectionModel?: ModelResult;
|
|
6
6
|
documents?: Readonly<Record<string, string>>;
|
|
7
7
|
revisions?: Readonly<Record<string, string>>;
|
|
8
|
+
fileIds?: Readonly<Record<string, string>>;
|
|
8
9
|
changes?: Readonly<Record<string, HeadChange>>;
|
|
9
10
|
binaryFiles?: Readonly<Record<string, BinaryFile>>;
|
|
10
11
|
blobs?: Readonly<Record<string, Blob>>;
|
|
@@ -32,7 +33,10 @@ export type MemoryAdapter = Adapter & {
|
|
|
32
33
|
setConversations(conversations: readonly MemoryConversation[]): void;
|
|
33
34
|
script(operation: keyof Adapter, answer: unknown): void;
|
|
34
35
|
open(): void;
|
|
35
|
-
close(
|
|
36
|
+
close(closing?: {
|
|
37
|
+
revoked?: boolean;
|
|
38
|
+
lost?: boolean;
|
|
39
|
+
}): void;
|
|
36
40
|
expire(locators: readonly string[]): void;
|
|
37
41
|
notifyRoomVersion(notification: {
|
|
38
42
|
locator: string;
|
|
@@ -41,6 +45,7 @@ export type MemoryAdapter = Adapter & {
|
|
|
41
45
|
notifyConversation(event: ConversationEvent): void;
|
|
42
46
|
notifyServiceMode(mode: ServiceMode): void;
|
|
43
47
|
heldRooms(): readonly string[];
|
|
48
|
+
heldDemand(): AcquiredDemand | null;
|
|
44
49
|
replicatedConversations(): readonly string[];
|
|
45
50
|
};
|
|
46
51
|
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,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,EAEZ,KAAK,UAAU,EAKf,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAItB,KAAK,cAAc,EACnB,KAAK,UAAU,EAGf,KAAK,kBAAkB,EACvB,KAAK,MAAM,EAGX,KAAK,aAAa,EAIlB,KAAK,SAAS,EAGd,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAkBtB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C,SAAS,EAAE,MAAM,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACxD,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC7D,MAAM,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAC1C,iBAAiB,CAAC,YAAY,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAChF,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACnD,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C,SAAS,IAAI,SAAS,MAAM,EAAE,CAAC;IAC/B,UAAU,IAAI,cAAc,GAAG,IAAI,CAAC;IACpC,uBAAuB,IAAI,SAAS,MAAM,EAAE,CAAC;CAC9C,CAAC;AA+CF,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CAgfrF"}
|
package/dist/memory.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sameChange } from './overlay.js';
|
|
2
2
|
const FIXTURE_RETENTION = {
|
|
3
3
|
history: { kind: 'duration', seconds: 1 },
|
|
4
|
-
outcome:
|
|
4
|
+
outcome: 604_800,
|
|
5
5
|
refreshHorizon: 1,
|
|
6
6
|
};
|
|
7
7
|
function declaredRetention(value) {
|
|
@@ -58,6 +58,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
58
58
|
const sentTurns = new Map();
|
|
59
59
|
const historyPageSize = options.historyPageSize;
|
|
60
60
|
let held = [];
|
|
61
|
+
let heldDemand = null;
|
|
61
62
|
let expiring = [];
|
|
62
63
|
let replicated = [];
|
|
63
64
|
let issued = 0;
|
|
@@ -122,6 +123,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
122
123
|
...(opening ? { models: modelsOf(room) } : {}),
|
|
123
124
|
documents: named(room.documents ?? {}, taken),
|
|
124
125
|
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
126
|
+
...(room.fileIds === undefined
|
|
127
|
+
? {}
|
|
128
|
+
: { fileIds: named(room.fileIds, [...taken, ...targets]) }),
|
|
125
129
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
126
130
|
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
127
131
|
...(next < paths.length ? { pageToken: taken.at(-1) } : {}),
|
|
@@ -133,6 +137,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
133
137
|
const currentTargets = new Set(Object.keys(room.binaryFiles ?? {}));
|
|
134
138
|
const previousTargets = new Set(Object.keys(from.binaryFiles ?? {}));
|
|
135
139
|
const headMoved = (path) => room.revisions?.[path] !== from.revisions?.[path] ||
|
|
140
|
+
room.fileIds?.[path] !== from.fileIds?.[path] ||
|
|
136
141
|
!sameChange(room.changes?.[path], from.changes?.[path]);
|
|
137
142
|
const changed = Object.keys(current)
|
|
138
143
|
.filter((path) => current[path] !== previous[path] || headMoved(path))
|
|
@@ -154,6 +159,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
154
159
|
...(models === undefined ? {} : { models }),
|
|
155
160
|
documents: named(current, taken),
|
|
156
161
|
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
162
|
+
...(room.fileIds === undefined
|
|
163
|
+
? {}
|
|
164
|
+
: { fileIds: named(room.fileIds, [...taken, ...targets]) }),
|
|
157
165
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
158
166
|
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
159
167
|
removals: opening
|
|
@@ -273,9 +281,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
273
281
|
for (const observer of observers)
|
|
274
282
|
observer({ kind: 'opened' });
|
|
275
283
|
},
|
|
276
|
-
close(revoked = false) {
|
|
284
|
+
close({ revoked = false, lost = !revoked } = {}) {
|
|
277
285
|
for (const observer of observers)
|
|
278
|
-
observer({ kind: 'closed', revoked });
|
|
286
|
+
observer({ kind: 'closed', revoked, lost });
|
|
279
287
|
},
|
|
280
288
|
expire(locators) {
|
|
281
289
|
expiring = [...locators];
|
|
@@ -299,6 +307,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
299
307
|
heldRooms() {
|
|
300
308
|
return held;
|
|
301
309
|
},
|
|
310
|
+
heldDemand() {
|
|
311
|
+
return heldDemand;
|
|
312
|
+
},
|
|
302
313
|
replicatedConversations() {
|
|
303
314
|
return replicated;
|
|
304
315
|
},
|
|
@@ -322,8 +333,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
322
333
|
},
|
|
323
334
|
},
|
|
324
335
|
roomStream: {
|
|
325
|
-
hold(asked) {
|
|
336
|
+
hold(asked, demand) {
|
|
326
337
|
held = asked.map((room) => room.locator);
|
|
338
|
+
heldDemand = demand;
|
|
327
339
|
const expired = expiring.filter((locator) => held.includes(locator));
|
|
328
340
|
expiring = [];
|
|
329
341
|
const moved = asked.flatMap((room) => {
|
|
@@ -344,8 +356,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
344
356
|
},
|
|
345
357
|
reopen() {
|
|
346
358
|
queueMicrotask(() => {
|
|
347
|
-
for (const observer of observers)
|
|
348
|
-
observer({ kind: 'closed', revoked: false });
|
|
359
|
+
for (const observer of observers) {
|
|
360
|
+
observer({ kind: 'closed', revoked: false, lost: false });
|
|
361
|
+
}
|
|
349
362
|
});
|
|
350
363
|
},
|
|
351
364
|
published() { },
|
|
@@ -355,7 +368,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
355
368
|
if (!observers.has(notify))
|
|
356
369
|
return;
|
|
357
370
|
if (options.unopened === true) {
|
|
358
|
-
notify({ kind: 'closed', revoked: false });
|
|
371
|
+
notify({ kind: 'closed', revoked: false, lost: true });
|
|
359
372
|
return;
|
|
360
373
|
}
|
|
361
374
|
announceList();
|
package/dist/model.d.ts
CHANGED
|
@@ -29,12 +29,13 @@ export type ModelState = {
|
|
|
29
29
|
types: VerifiedModel['types'];
|
|
30
30
|
};
|
|
31
31
|
export type TypesResult = {
|
|
32
|
-
status: 'unavailable'
|
|
32
|
+
status: Open<'unavailable'>;
|
|
33
33
|
reason: ModelUnavailableReason;
|
|
34
|
+
types: null;
|
|
34
35
|
schema?: string | null;
|
|
35
36
|
revision?: string | null;
|
|
36
37
|
} | {
|
|
37
|
-
status: 'current' | 'cached'
|
|
38
|
+
status: Open<'current' | 'cached'>;
|
|
38
39
|
identity: string;
|
|
39
40
|
version: string;
|
|
40
41
|
verifiedWith: ModelIdentity;
|
|
@@ -52,5 +53,6 @@ export declare function definitionOf(state: ModelState, type: string | undefined
|
|
|
52
53
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
53
54
|
export declare function cached(state: ModelState): ModelState;
|
|
54
55
|
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
56
|
+
export declare function sameTyping(left: ModelState, right: ModelState): boolean;
|
|
55
57
|
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
56
58
|
//# 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,UAAU,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,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,GA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C;AACN,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC;CACpC,CAAC;AACF,eAAO,MAAM,QAAQ,EAAE,UAA8D,CAAC;AACtF,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,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,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CASvE;AACD,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAErE"}
|
package/dist/model.js
CHANGED
|
@@ -6,7 +6,7 @@ export function definitionOf(state, type) {
|
|
|
6
6
|
}
|
|
7
7
|
export function modelTypes(state) {
|
|
8
8
|
return state.status === 'unavailable'
|
|
9
|
-
? { ...state }
|
|
9
|
+
? { ...state, types: null }
|
|
10
10
|
: {
|
|
11
11
|
status: state.status,
|
|
12
12
|
identity: state.snapshot.identity,
|
|
@@ -23,6 +23,15 @@ 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 sameTyping(left, right) {
|
|
27
|
+
if (left === right)
|
|
28
|
+
return true;
|
|
29
|
+
if (left.status === 'unavailable' || right.status === 'unavailable') {
|
|
30
|
+
return left.status === right.status;
|
|
31
|
+
}
|
|
32
|
+
return (left.snapshot.schema === right.snapshot.schema &&
|
|
33
|
+
sameModel(left.verifiedWith, right.verifiedWith));
|
|
34
|
+
}
|
|
26
35
|
export function referenceField(facts) {
|
|
27
36
|
return facts?.reference !== undefined || facts?.items?.reference !== undefined;
|
|
28
37
|
}
|
package/dist/observation.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
1
|
+
import type { QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
2
2
|
export type Observation<T> = {
|
|
3
3
|
current(): T;
|
|
4
4
|
subscribe(listener: (value: T) => void): () => void;
|
|
@@ -13,14 +13,17 @@ export type QueryChange = {
|
|
|
13
13
|
changed: readonly (readonly [RowKey, QueryDocument | QueryGroup])[];
|
|
14
14
|
removed: readonly RowKey[];
|
|
15
15
|
order: readonly RowKey[] | null;
|
|
16
|
+
coverage?: QueryCoverage;
|
|
16
17
|
};
|
|
18
|
+
export type QueryMessage = KeyedResult | QueryChange;
|
|
17
19
|
export type Observed = {
|
|
18
20
|
observation: Observation<unknown>;
|
|
19
21
|
receive(message: unknown): void;
|
|
20
22
|
end(): void;
|
|
21
23
|
};
|
|
22
24
|
export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
|
|
23
|
-
export declare function
|
|
25
|
+
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
26
|
+
export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
|
|
24
27
|
export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
|
|
25
28
|
export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
26
29
|
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>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation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