@agentshouse/mdruntime 0.1.0-cebcd51f70ed1 → 0.1.0-cedb03eaa48b6
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 +283 -222
- package/README.md +20 -10
- package/dist/adapter.d.ts +95 -20
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +15 -2
- package/dist/attempt.d.ts +16 -0
- package/dist/attempt.d.ts.map +1 -0
- package/dist/attempt.js +70 -0
- package/dist/binary.d.ts +23 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +18 -5
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +113 -37
- package/dist/change-set.d.ts +2 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +49 -16
- package/dist/change.d.ts +15 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +26 -1
- package/dist/chat/acts.d.ts +33 -0
- package/dist/chat/acts.d.ts.map +1 -0
- package/dist/chat/acts.js +36 -0
- package/dist/chat/context.d.ts +3 -0
- package/dist/chat/context.d.ts.map +1 -0
- package/dist/chat/context.js +10 -0
- package/dist/chat/earlier.d.ts +10 -0
- package/dist/chat/earlier.d.ts.map +1 -0
- package/dist/chat/earlier.js +54 -0
- package/dist/chat/input.d.ts +9 -0
- package/dist/chat/input.d.ts.map +1 -0
- package/dist/chat/input.js +99 -0
- package/dist/chat/kit.d.ts +61 -0
- package/dist/chat/kit.d.ts.map +1 -0
- package/dist/chat/kit.js +123 -0
- package/dist/chat/lasting.d.ts +6 -0
- package/dist/chat/lasting.d.ts.map +1 -0
- package/dist/chat/lasting.js +19 -0
- package/dist/chat/list.d.ts +27 -0
- package/dist/chat/list.d.ts.map +1 -0
- package/dist/chat/list.js +99 -0
- package/dist/chat/markdown.d.ts +20 -0
- package/dist/chat/markdown.d.ts.map +1 -0
- package/dist/chat/markdown.js +188 -0
- package/dist/chat/message.d.ts +6 -0
- package/dist/chat/message.d.ts.map +1 -0
- package/dist/chat/message.js +192 -0
- package/dist/chat/messages.d.ts +22 -0
- package/dist/chat/messages.d.ts.map +1 -0
- package/dist/chat/messages.js +155 -0
- package/dist/chat/name.d.ts +6 -0
- package/dist/chat/name.d.ts.map +1 -0
- package/dist/chat/name.js +37 -0
- package/dist/chat/opened.d.ts +11 -0
- package/dist/chat/opened.d.ts.map +1 -0
- package/dist/chat/opened.js +17 -0
- package/dist/chat/overlay.d.ts +31 -0
- package/dist/chat/overlay.d.ts.map +1 -0
- package/dist/chat/overlay.js +97 -0
- package/dist/chat/parts.d.ts +57 -0
- package/dist/chat/parts.d.ts.map +1 -0
- package/dist/chat/parts.js +119 -0
- package/dist/chat/process.d.ts +20 -0
- package/dist/chat/process.d.ts.map +1 -0
- package/dist/chat/process.js +32 -0
- package/dist/chat/provider.d.ts +63 -0
- package/dist/chat/provider.d.ts.map +1 -0
- package/dist/chat/provider.js +628 -0
- package/dist/chat/question.d.ts +9 -0
- package/dist/chat/question.d.ts.map +1 -0
- package/dist/chat/question.js +69 -0
- package/dist/chat/questions.d.ts +31 -0
- package/dist/chat/questions.d.ts.map +1 -0
- package/dist/chat/questions.js +111 -0
- package/dist/chat/read.d.ts +5 -0
- package/dist/chat/read.d.ts.map +1 -0
- package/dist/chat/read.js +13 -0
- package/dist/chat/ready.d.ts +34 -0
- package/dist/chat/ready.d.ts.map +1 -0
- package/dist/chat/ready.js +91 -0
- package/dist/chat/style.d.ts +4 -0
- package/dist/chat/style.d.ts.map +1 -0
- package/dist/chat/style.js +302 -0
- package/dist/chat.d.ts +14 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +8 -0
- package/dist/client.d.ts +30 -13
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +79 -16
- package/dist/collection.d.ts +21 -12
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +301 -23
- package/dist/connection.d.ts +50 -16
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1936 -415
- package/dist/conversation.d.ts +31 -10
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +521 -170
- package/dist/durability.d.ts +7 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +17 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +157 -0
- package/dist/expectation.d.ts +21 -0
- package/dist/expectation.d.ts.map +1 -0
- package/dist/expectation.js +70 -0
- package/dist/failure.d.ts +13 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +19 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/host.d.ts +15 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +102 -19
- package/dist/identity.d.ts +5 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +19 -1
- package/dist/index.d.ts +16 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/memory.d.ts +11 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +91 -24
- package/dist/model.d.ts +14 -4
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +12 -1
- package/dist/observation.d.ts +7 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +29 -12
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- package/dist/outcome.d.ts +38 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +45 -1
- package/dist/overlay.d.ts +16 -3
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +118 -77
- package/dist/query.d.ts +60 -4
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +41 -38
- package/dist/reach.d.ts +8 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +73 -24
- package/dist/react.d.ts +31 -20
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +13 -21
- package/dist/read-side.d.ts +16 -7
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +493 -102
- 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 +13 -3
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +49 -38
- package/dist/replica.d.ts +13 -6
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +143 -70
- package/dist/room-draft.d.ts +38 -9
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +134 -25
- package/dist/rows.d.ts +10 -13
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +19 -14
- package/dist/save.d.ts +32 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +390 -45
- package/dist/search.d.ts +52 -8
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +192 -47
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -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 +6 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -8
- package/dist/store.d.ts +89 -18
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +573 -200
- package/dist/turn.d.ts +7 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +51 -0
- package/dist/windows.d.ts +26 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +93 -0
- package/dist/wire.d.ts +157 -33
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +65 -31
- package/package.json +26 -14
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
package/dist/identity.js
CHANGED
|
@@ -10,8 +10,26 @@ 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
|
|
13
|
+
export function identityTime(identity) {
|
|
14
|
+
return Number.parseInt(identity.replaceAll('-', '').slice(0, 12), 16);
|
|
15
|
+
}
|
|
16
|
+
function randomIdentity() {
|
|
14
17
|
const bytes = new Uint8Array(16);
|
|
15
18
|
crypto.getRandomValues(bytes);
|
|
16
19
|
return [...bytes].map((byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
17
20
|
}
|
|
21
|
+
export function roomDraftRevision() {
|
|
22
|
+
return randomIdentity();
|
|
23
|
+
}
|
|
24
|
+
export function chatDraftRevision() {
|
|
25
|
+
return randomIdentity();
|
|
26
|
+
}
|
|
27
|
+
export function transferIdentity() {
|
|
28
|
+
return randomIdentity();
|
|
29
|
+
}
|
|
30
|
+
export function indexGeneration() {
|
|
31
|
+
return randomIdentity();
|
|
32
|
+
}
|
|
33
|
+
export function binaryLocalId() {
|
|
34
|
+
return randomIdentity();
|
|
35
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
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,
|
|
1
|
+
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryLinkResult, BinaryRequest, BinaryResult, ReferrerScope, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, DiscoveryScope, 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
|
-
export type { ChatDraft, ChatDraftSurface, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
3
|
+
export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
4
4
|
export type { ChatDraftFile, FileDeclaration } from './file.js';
|
|
5
|
-
export type { AppRoom, AppTypedSelection, ConnectionRefusal,
|
|
5
|
+
export type { AppRoom, AppTypedSelection, BinaryFileSurface, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult, } from './connection.js';
|
|
6
6
|
export type { Observation } from './observation.js';
|
|
7
|
-
export type { CallResult, QueueEntry, Submission } from './outcome.js';
|
|
8
|
-
export type {
|
|
7
|
+
export type { BinaryAnswer, BinaryLinkAnswer, CallResult, Failure, HistoryAnswer, Offline, QueueEntry, Submission, } from './outcome.js';
|
|
8
|
+
export type { BinaryFileRecord, BinaryReference } from './binary.js';
|
|
9
|
+
export type { RuntimeError } from './failure.js';
|
|
10
|
+
export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, TextParts, } from './room-draft.js';
|
|
9
11
|
export type { SaveRefusal } from './save.js';
|
|
10
|
-
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
|
+
export { departure } from './change.js';
|
|
14
|
+
export { partsAfter } from './room-draft.js';
|
|
15
|
+
export { SESSION_STARTED } from './conversation.js';
|
|
11
16
|
export { changeBatchIdentity } from './identity.js';
|
|
12
|
-
export type
|
|
17
|
+
export { attempts, identities, intentOf, type Answered, type Attempt, type Attempts, type Identities, } from './attempt.js';
|
|
18
|
+
export { expectedList, expecting, type ExpectedOf, type Expecting } from './expectation.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';
|
|
13
21
|
export type { AttentionEntry, SyncStatus } from './status.js';
|
|
14
|
-
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';
|
|
15
23
|
export type { MdType, ModelIdentity, ModelSnapshot, ModelState, ModelResult, TypesResult, ValidationReceipt, } from './model.js';
|
|
16
24
|
export type { OperationScopes, ReplicaAdmission, ScopedRefusal } from './adapter.js';
|
|
17
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,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,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,
|
|
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,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EAC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,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,YAAY,EACV,MAAM,EACN,QAAQ,EACR,WAAW,EACX,SAAS,EACT,aAAa,EACb,cAAc,EACd,MAAM,EACN,UAAU,EACV,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 +1,6 @@
|
|
|
1
|
+
export { departure } from './change.js';
|
|
2
|
+
export { partsAfter } from './room-draft.js';
|
|
3
|
+
export { SESSION_STARTED } from './conversation.js';
|
|
1
4
|
export { changeBatchIdentity } from './identity.js';
|
|
5
|
+
export { attempts, identities, intentOf, } from './attempt.js';
|
|
6
|
+
export { expectedList, expecting } from './expectation.js';
|
package/dist/memory.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
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 ListedConversation, type
|
|
2
|
+
import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveryScope, type DiscoveredRoom, type HeadChange, type ListedConversation, type Member, type ProviderLimit, type Retention, 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
|
-
|
|
10
|
+
binaryFiles?: Readonly<Record<string, BinaryFile>>;
|
|
11
|
+
blobs?: Readonly<Record<string, Blob>>;
|
|
11
12
|
};
|
|
12
13
|
export type MemoryConversation = {
|
|
13
14
|
conversation: string;
|
|
@@ -23,19 +24,25 @@ export type MemoryAdapterOptions = {
|
|
|
23
24
|
capabilities?: readonly Capability[];
|
|
24
25
|
providerLimits?: readonly ProviderLimit[];
|
|
25
26
|
retention?: Retention;
|
|
27
|
+
member?: Member;
|
|
26
28
|
unopened?: boolean;
|
|
29
|
+
exhaustiveDiscovery?: true;
|
|
27
30
|
};
|
|
28
31
|
export type MemoryAdapter = Adapter & {
|
|
29
32
|
setRooms(rooms: readonly MemoryRoom[]): void;
|
|
30
33
|
setConversations(conversations: readonly MemoryConversation[]): void;
|
|
31
34
|
script(operation: keyof Adapter, answer: unknown): void;
|
|
32
35
|
open(): void;
|
|
33
|
-
close(
|
|
36
|
+
close(closing?: {
|
|
37
|
+
revoked?: boolean;
|
|
38
|
+
lost?: boolean;
|
|
39
|
+
}): void;
|
|
34
40
|
expire(locators: readonly string[]): void;
|
|
35
41
|
notifyRoomVersion(notification: {
|
|
36
42
|
locator: string;
|
|
37
43
|
roomVersion: string;
|
|
38
44
|
}): void;
|
|
45
|
+
notifyAuthorityChanged(scope?: DiscoveryScope): void;
|
|
39
46
|
notifyConversation(event: ConversationEvent): void;
|
|
40
47
|
notifyServiceMode(mode: ServiceMode): void;
|
|
41
48
|
heldRooms(): readonly string[];
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],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I,CAAC;IAC1C,iBAAiB,CAAC,YAAY,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAChF,sBAAsB,CAAC,KAAK,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACrD,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,uBAAuB,IAAI,SAAS,MAAM,EAAE,CAAC;CAC9C,CAAC;AAiDF,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CA2frF"}
|
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) {
|
|
@@ -55,6 +55,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
55
55
|
const scripted = new Map();
|
|
56
56
|
const unsealed = new Map();
|
|
57
57
|
const sealed = new Set();
|
|
58
|
+
const sentTurns = new Map();
|
|
58
59
|
const historyPageSize = options.historyPageSize;
|
|
59
60
|
let held = [];
|
|
60
61
|
let expiring = [];
|
|
@@ -107,30 +108,35 @@ export function createMemoryAdapter(options = {}) {
|
|
|
107
108
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
|
-
function page(room,
|
|
111
|
+
function page(room, after) {
|
|
111
112
|
const paths = Object.keys(room.documents ?? {}).sort();
|
|
113
|
+
const opening = after === undefined;
|
|
114
|
+
const from = opening ? 0 : paths.filter((path) => path <= after).length;
|
|
112
115
|
const size = pageSize ?? paths.length;
|
|
113
116
|
const taken = paths.slice(from, from + size);
|
|
114
117
|
const next = from + taken.length;
|
|
115
|
-
const targets =
|
|
118
|
+
const targets = opening ? Object.keys(room.binaryFiles ?? {}) : [];
|
|
116
119
|
return {
|
|
117
120
|
kind: 'bootstrap',
|
|
118
121
|
roomVersion: room.roomVersion,
|
|
119
|
-
...(
|
|
122
|
+
...(opening ? { models: modelsOf(room) } : {}),
|
|
120
123
|
documents: named(room.documents ?? {}, taken),
|
|
121
|
-
revisions: named(room.revisions ?? {}, taken),
|
|
124
|
+
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
125
|
+
...(room.fileIds === undefined
|
|
126
|
+
? {}
|
|
127
|
+
: { fileIds: named(room.fileIds, [...taken, ...targets]) }),
|
|
122
128
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
123
|
-
|
|
124
|
-
...(
|
|
125
|
-
...(next < paths.length ? { pageToken: String(next) } : {}),
|
|
129
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
130
|
+
...(next < paths.length ? { pageToken: taken.at(-1) } : {}),
|
|
126
131
|
};
|
|
127
132
|
}
|
|
128
133
|
function advancement(room, from, at) {
|
|
129
134
|
const current = room.documents ?? {};
|
|
130
135
|
const previous = from.documents ?? {};
|
|
131
|
-
const currentTargets = new Set(room.
|
|
132
|
-
const previousTargets = new Set(from.
|
|
136
|
+
const currentTargets = new Set(Object.keys(room.binaryFiles ?? {}));
|
|
137
|
+
const previousTargets = new Set(Object.keys(from.binaryFiles ?? {}));
|
|
133
138
|
const headMoved = (path) => room.revisions?.[path] !== from.revisions?.[path] ||
|
|
139
|
+
room.fileIds?.[path] !== from.fileIds?.[path] ||
|
|
134
140
|
!sameChange(room.changes?.[path], from.changes?.[path]);
|
|
135
141
|
const changed = Object.keys(current)
|
|
136
142
|
.filter((path) => current[path] !== previous[path] || headMoved(path))
|
|
@@ -145,24 +151,24 @@ export function createMemoryAdapter(options = {}) {
|
|
|
145
151
|
const targets = opening
|
|
146
152
|
? [...currentTargets].filter((target) => !previousTargets.has(target) || headMoved(target))
|
|
147
153
|
: [];
|
|
148
|
-
const attachments = room.attachments ?? [];
|
|
149
|
-
const declared = opening && JSON.stringify(attachments) !== JSON.stringify(from.attachments ?? []);
|
|
150
154
|
const models = opening ? changedModels(room, from) : undefined;
|
|
151
155
|
return {
|
|
152
156
|
kind: 'net-advancement',
|
|
153
157
|
roomVersion: room.roomVersion,
|
|
154
158
|
...(models === undefined ? {} : { models }),
|
|
155
159
|
documents: named(current, taken),
|
|
156
|
-
revisions: named(room.revisions ?? {}, taken),
|
|
160
|
+
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
161
|
+
...(room.fileIds === undefined
|
|
162
|
+
? {}
|
|
163
|
+
: { fileIds: named(room.fileIds, [...taken, ...targets]) }),
|
|
157
164
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
158
|
-
|
|
165
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
159
166
|
removals: opening
|
|
160
167
|
? [
|
|
161
168
|
...Object.keys(previous).filter((path) => !(path in current) && !currentTargets.has(path)),
|
|
162
169
|
...[...previousTargets].filter((target) => !currentTargets.has(target) && !(target in current)),
|
|
163
170
|
].sort()
|
|
164
171
|
: [],
|
|
165
|
-
...(declared ? { attachments } : {}),
|
|
166
172
|
...(pageToken === undefined ? {} : { pageToken }),
|
|
167
173
|
};
|
|
168
174
|
}
|
|
@@ -183,7 +189,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
183
189
|
function historiesOf(input) {
|
|
184
190
|
const asked = input?.conversations;
|
|
185
191
|
if (!Array.isArray(asked))
|
|
186
|
-
return { kind: 'rejected', code: 'invalid_request', fields: {} };
|
|
192
|
+
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
187
193
|
const histories = [];
|
|
188
194
|
for (const entry of asked) {
|
|
189
195
|
const conversation = typeof entry.conversation === 'string' ? scripted.get(entry.conversation) : undefined;
|
|
@@ -211,21 +217,32 @@ export function createMemoryAdapter(options = {}) {
|
|
|
211
217
|
const named = typeof input.conversation === 'string' ? input.conversation : '';
|
|
212
218
|
const conversation = scripted.get(named);
|
|
213
219
|
if (conversation === undefined) {
|
|
214
|
-
return {
|
|
220
|
+
return {
|
|
221
|
+
kind: 'rejected',
|
|
222
|
+
code: 'unknown-conversation',
|
|
223
|
+
fields: { conversation: named },
|
|
224
|
+
retryable: false,
|
|
225
|
+
};
|
|
215
226
|
}
|
|
216
227
|
const outcome = conversation.outcomes?.[name];
|
|
217
228
|
if (outcome !== undefined)
|
|
218
229
|
return outcome;
|
|
219
230
|
if (name === 'conversation.send') {
|
|
231
|
+
const operation = typeof input.operation_id === 'string' ? input.operation_id : null;
|
|
232
|
+
const answered = operation === null ? undefined : sentTurns.get(operation);
|
|
233
|
+
if (answered !== undefined)
|
|
234
|
+
return { kind: 'action', result: { turn: answered } };
|
|
220
235
|
issued += 1;
|
|
221
236
|
const turn = `turn-${issued}`;
|
|
222
237
|
unsealed.set(turn, named);
|
|
238
|
+
if (operation !== null)
|
|
239
|
+
sentTurns.set(operation, turn);
|
|
223
240
|
return { kind: 'action', result: { turn } };
|
|
224
241
|
}
|
|
225
242
|
if (name === 'conversation.cancel') {
|
|
226
243
|
const turn = typeof input.turn === 'string' ? input.turn : '';
|
|
227
244
|
if (sealed.has(turn) || !unsealed.has(turn)) {
|
|
228
|
-
return { kind: 'rejected', code: 'turn-sealed', fields: { turn } };
|
|
245
|
+
return { kind: 'rejected', code: 'turn-sealed', fields: { turn }, retryable: false };
|
|
229
246
|
}
|
|
230
247
|
unsealed.delete(turn);
|
|
231
248
|
return { kind: 'action', result: { turn, cancelled: true } };
|
|
@@ -246,9 +263,11 @@ export function createMemoryAdapter(options = {}) {
|
|
|
246
263
|
capabilities,
|
|
247
264
|
providerLimits,
|
|
248
265
|
retention,
|
|
266
|
+
...(options.member === undefined ? {} : { member: options.member }),
|
|
249
267
|
};
|
|
250
268
|
}
|
|
251
269
|
return {
|
|
270
|
+
...(options.exhaustiveDiscovery === undefined ? {} : { exhaustiveDiscovery: true }),
|
|
252
271
|
setRooms(next) {
|
|
253
272
|
rooms = [...next];
|
|
254
273
|
retain(rooms);
|
|
@@ -261,9 +280,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
261
280
|
for (const observer of observers)
|
|
262
281
|
observer({ kind: 'opened' });
|
|
263
282
|
},
|
|
264
|
-
close(revoked = false) {
|
|
283
|
+
close({ revoked = false, lost = !revoked } = {}) {
|
|
265
284
|
for (const observer of observers)
|
|
266
|
-
observer({ kind: 'closed', revoked });
|
|
285
|
+
observer({ kind: 'closed', revoked, lost });
|
|
267
286
|
},
|
|
268
287
|
expire(locators) {
|
|
269
288
|
expiring = [...locators];
|
|
@@ -272,6 +291,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
272
291
|
for (const observer of observers)
|
|
273
292
|
observer({ kind: 'room-version', locator, roomVersion });
|
|
274
293
|
},
|
|
294
|
+
notifyAuthorityChanged(scope) {
|
|
295
|
+
for (const observer of observers) {
|
|
296
|
+
observer(scope === undefined
|
|
297
|
+
? { kind: 'authority-changed' }
|
|
298
|
+
: { kind: 'authority-changed', scope });
|
|
299
|
+
}
|
|
300
|
+
},
|
|
275
301
|
notifyConversation(event) {
|
|
276
302
|
if (event.kind === 'accepted-message') {
|
|
277
303
|
sealed.add(event.message.turn);
|
|
@@ -330,13 +356,21 @@ export function createMemoryAdapter(options = {}) {
|
|
|
330
356
|
}
|
|
331
357
|
});
|
|
332
358
|
},
|
|
359
|
+
reopen() {
|
|
360
|
+
queueMicrotask(() => {
|
|
361
|
+
for (const observer of observers) {
|
|
362
|
+
observer({ kind: 'closed', revoked: false, lost: false });
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
},
|
|
366
|
+
published() { },
|
|
333
367
|
observe(notify) {
|
|
334
368
|
observers.add(notify);
|
|
335
369
|
queueMicrotask(() => {
|
|
336
370
|
if (!observers.has(notify))
|
|
337
371
|
return;
|
|
338
372
|
if (options.unopened === true) {
|
|
339
|
-
notify({ kind: 'closed', revoked: false });
|
|
373
|
+
notify({ kind: 'closed', revoked: false, lost: true });
|
|
340
374
|
return;
|
|
341
375
|
}
|
|
342
376
|
announceList();
|
|
@@ -379,7 +413,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
379
413
|
if (room === undefined) {
|
|
380
414
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
381
415
|
}
|
|
382
|
-
return page(room, request.pageToken
|
|
416
|
+
return page(room, request.pageToken);
|
|
383
417
|
}, request).then((answer) => note(request.locator, answer));
|
|
384
418
|
},
|
|
385
419
|
async refresh(_authorization, request) {
|
|
@@ -412,7 +446,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
412
446
|
if (room === undefined) {
|
|
413
447
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
414
448
|
}
|
|
415
|
-
return {
|
|
449
|
+
return {
|
|
450
|
+
kind: 'rejected',
|
|
451
|
+
code: 'unscripted-mutation',
|
|
452
|
+
fields: {},
|
|
453
|
+
retryable: false,
|
|
454
|
+
affected: {},
|
|
455
|
+
};
|
|
416
456
|
}, request).then((answer) => note(request.locator, answer));
|
|
417
457
|
},
|
|
418
458
|
async history(_authorization, request) {
|
|
@@ -427,11 +467,38 @@ export function createMemoryAdapter(options = {}) {
|
|
|
427
467
|
};
|
|
428
468
|
}, request);
|
|
429
469
|
},
|
|
470
|
+
async binary(_authorization, request) {
|
|
471
|
+
return resolveScript(scripts.binary, () => {
|
|
472
|
+
if (request.kind === 'reference') {
|
|
473
|
+
return { kind: 'rejected', code: 'unscripted-binary', fields: {}, retryable: false };
|
|
474
|
+
}
|
|
475
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
476
|
+
if (room === undefined)
|
|
477
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
478
|
+
const blob = room.blobs?.[request.path];
|
|
479
|
+
return blob === undefined
|
|
480
|
+
? { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false }
|
|
481
|
+
: { kind: 'binary', blob };
|
|
482
|
+
}, request);
|
|
483
|
+
},
|
|
484
|
+
async link(_authorization, request) {
|
|
485
|
+
return resolveScript(scripts.link, () => ({ kind: 'rejected', code: 'unscripted-link', fields: {}, retryable: false }), request);
|
|
486
|
+
},
|
|
487
|
+
referrerScope(referrer) {
|
|
488
|
+
if (typeof referrer !== 'object' || referrer === null)
|
|
489
|
+
return null;
|
|
490
|
+
const { room, path, message } = referrer;
|
|
491
|
+
if (typeof message === 'string')
|
|
492
|
+
return { kind: 'conversations' };
|
|
493
|
+
if (typeof room !== 'string')
|
|
494
|
+
return null;
|
|
495
|
+
return { kind: 'room', locator: room, ...(typeof path === 'string' ? { path } : {}) };
|
|
496
|
+
},
|
|
430
497
|
async action(_authorization, request) {
|
|
431
498
|
return resolveScript(scripts.action, () => {
|
|
432
499
|
if (request.name.startsWith('conversation.'))
|
|
433
500
|
return conversationAction(request);
|
|
434
|
-
return { kind: 'rejected', code: 'unscripted-action', fields: {} };
|
|
501
|
+
return { kind: 'rejected', code: 'unscripted-action', fields: {}, retryable: false };
|
|
435
502
|
}, request).then((answer) => {
|
|
436
503
|
if (answer.kind === 'action' && answer.at !== undefined)
|
|
437
504
|
note(answer.at.locator, answer.at);
|
package/dist/model.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { Definition, ValueFacts, VerifiedModel } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { Open } from './open.js';
|
|
2
3
|
export type ModelIdentity = {
|
|
3
4
|
identity: string;
|
|
4
5
|
version: string;
|
|
5
6
|
};
|
|
6
7
|
export type ModelSnapshot = ModelIdentity & {
|
|
7
8
|
schema: string | null;
|
|
9
|
+
revision: string | null;
|
|
8
10
|
};
|
|
9
|
-
export type ModelUnavailableReason = 'not-readable' | 'revoked' | 'not-acquired' | 'invalid'
|
|
11
|
+
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired' | 'invalid'>;
|
|
10
12
|
export type ModelResult = {
|
|
11
13
|
kind: 'model';
|
|
12
14
|
snapshot: ModelSnapshot;
|
|
@@ -18,6 +20,8 @@ export type MdType = Definition;
|
|
|
18
20
|
export type ModelState = {
|
|
19
21
|
status: 'unavailable';
|
|
20
22
|
reason: ModelUnavailableReason;
|
|
23
|
+
schema?: string | null;
|
|
24
|
+
revision?: string | null;
|
|
21
25
|
} | {
|
|
22
26
|
status: 'current' | 'cached';
|
|
23
27
|
snapshot: ModelSnapshot;
|
|
@@ -25,24 +29,30 @@ export type ModelState = {
|
|
|
25
29
|
types: VerifiedModel['types'];
|
|
26
30
|
};
|
|
27
31
|
export type TypesResult = {
|
|
28
|
-
status: 'unavailable'
|
|
32
|
+
status: Open<'unavailable'>;
|
|
29
33
|
reason: ModelUnavailableReason;
|
|
34
|
+
types: null;
|
|
35
|
+
schema?: string | null;
|
|
36
|
+
revision?: string | null;
|
|
30
37
|
} | {
|
|
31
|
-
status: 'current' | 'cached'
|
|
38
|
+
status: Open<'current' | 'cached'>;
|
|
32
39
|
identity: string;
|
|
33
40
|
version: string;
|
|
34
41
|
verifiedWith: ModelIdentity;
|
|
35
42
|
types: readonly MdType[];
|
|
43
|
+
schema: string | null;
|
|
44
|
+
revision: string | null;
|
|
36
45
|
};
|
|
37
46
|
export type ValidationReceipt = {
|
|
38
47
|
identity: string;
|
|
39
48
|
version: string;
|
|
40
|
-
source: 'current' | 'cached'
|
|
49
|
+
source: Open<'current' | 'cached'>;
|
|
41
50
|
};
|
|
42
51
|
export declare const NO_MODEL: ModelState;
|
|
43
52
|
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
44
53
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
45
54
|
export declare function cached(state: ModelState): ModelState;
|
|
46
55
|
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
56
|
+
export declare function sameTyping(left: ModelState, right: ModelState): boolean;
|
|
47
57
|
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
48
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;
|
|
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,GAAG,IAAI,CAAA;CAAE,CAAC;AAC/F,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,cAAc,GAAG,SAAS,GAAG,cAAc,GAAG,SAAS,CAAC,CAAC;AACnG,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,MAAM,EAAE,sBAAsB,CAAA;CAAE,CAAC;AAClE,MAAM,MAAM,MAAM,GAAG,UAAU,CAAC;AAChC,MAAM,MAAM,UAAU,GAClB;IACE,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;C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AAa,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,12 +6,14 @@ 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,
|
|
13
13
|
version: state.snapshot.version,
|
|
14
14
|
verifiedWith: { ...state.verifiedWith },
|
|
15
|
+
schema: state.snapshot.schema,
|
|
16
|
+
revision: state.snapshot.revision,
|
|
15
17
|
types: structuredClone(Object.values(state.types).sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0)),
|
|
16
18
|
};
|
|
17
19
|
}
|
|
@@ -21,6 +23,15 @@ export function cached(state) {
|
|
|
21
23
|
export function sameModel(left, right) {
|
|
22
24
|
return left.identity === right.identity && left.version === right.version;
|
|
23
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
|
+
}
|
|
24
35
|
export function referenceField(facts) {
|
|
25
36
|
return facts?.reference !== undefined || facts?.items?.reference !== undefined;
|
|
26
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,19 @@ 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;
|
|
17
|
+
next?: string | null;
|
|
18
|
+
total?: number;
|
|
16
19
|
};
|
|
20
|
+
export type QueryMessage = KeyedResult | QueryChange;
|
|
17
21
|
export type Observed = {
|
|
18
22
|
observation: Observation<unknown>;
|
|
19
23
|
receive(message: unknown): void;
|
|
20
24
|
end(): void;
|
|
21
25
|
};
|
|
22
26
|
export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
|
|
23
|
-
export declare function
|
|
27
|
+
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
28
|
+
export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
|
|
24
29
|
export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
|
|
25
30
|
export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
26
31
|
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE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,CAwB9E;AAiBD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,QAAQ,CAkCnF;AAED,wBAAgB,MAAM,CACpB,KAAK,EAAE,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,KAAK,MAAM,IAAI,EAC1D,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAiB/B;AAED,wBAAgB,SAAS,CAAC,KAAK,SAAS,MAAM,EAC5C,KAAK,EAAE,CACL,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,SAAS,OAAO,EAAE,EACzB,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,KAChC,MAAM,IAAI,WAEA,KAAK,YAAY,OAAO,EAAE,KAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAQ1E"}
|
package/dist/observation.js
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
export function rowsOf(result) {
|
|
2
|
-
|
|
2
|
+
if ('groups' in result)
|
|
3
|
+
return result.groups;
|
|
4
|
+
return 'documents' in result ? result.documents : [];
|
|
3
5
|
}
|
|
4
|
-
export function
|
|
5
|
-
|
|
6
|
+
export function whole(message) {
|
|
7
|
+
return 'result' in message;
|
|
8
|
+
}
|
|
9
|
+
export function applied(keyed, message) {
|
|
10
|
+
if (whole(message))
|
|
11
|
+
return message;
|
|
12
|
+
const result = keyed.result;
|
|
13
|
+
if ('pending' in result)
|
|
14
|
+
return keyed;
|
|
15
|
+
const rows = rowsOf(result);
|
|
6
16
|
const byKey = new Map(keyed.keys.map((key, index) => [key, rows[index]]));
|
|
7
|
-
for (const key of
|
|
17
|
+
for (const key of message.removed)
|
|
8
18
|
byKey.delete(key);
|
|
9
|
-
for (const [key, row] of
|
|
19
|
+
for (const [key, row] of message.changed)
|
|
10
20
|
byKey.set(key, row);
|
|
11
|
-
const keys =
|
|
12
|
-
const
|
|
21
|
+
const keys = message.order ?? keyed.keys.filter((key) => byKey.has(key));
|
|
22
|
+
const kept = keys.map((key) => byKey.get(key));
|
|
23
|
+
const coverage = message.coverage ?? result.coverage;
|
|
24
|
+
const next = message.next === undefined ? result.next : (message.next ?? undefined);
|
|
25
|
+
const total = message.total ?? result.total;
|
|
26
|
+
const window = {
|
|
27
|
+
...(next === undefined ? {} : { next }),
|
|
28
|
+
...(total === undefined ? {} : { total }),
|
|
29
|
+
};
|
|
13
30
|
return {
|
|
14
|
-
result: 'groups' in
|
|
15
|
-
? { groups:
|
|
16
|
-
: { documents:
|
|
31
|
+
result: 'groups' in result
|
|
32
|
+
? { groups: kept, coverage, ...window }
|
|
33
|
+
: { documents: kept, coverage, ...window },
|
|
17
34
|
keys,
|
|
18
35
|
};
|
|
19
36
|
}
|
|
@@ -27,11 +44,11 @@ function keyedResult(first) {
|
|
|
27
44
|
},
|
|
28
45
|
};
|
|
29
46
|
}
|
|
30
|
-
function
|
|
47
|
+
function replaced(first) {
|
|
31
48
|
return { value: first, next: (message) => message };
|
|
32
49
|
}
|
|
33
50
|
export function observed(first, stop, keyed) {
|
|
34
|
-
const reducer = keyed ? keyedResult(first) :
|
|
51
|
+
const reducer = keyed ? keyedResult(first) : replaced(first);
|
|
35
52
|
let value = reducer.value;
|
|
36
53
|
let open = true;
|
|
37
54
|
const listeners = new Set();
|
package/dist/open.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../src/open.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,CAAC,KAAK,SAAS,MAAM,IAAI,KAAK,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC"}
|
package/dist/open.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|