@agentshouse/mdruntime 0.1.0-cede5a74284be → 0.1.0-cefbc8bb8a1c0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -15
- package/dist/adapter.d.ts +114 -33
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +5 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +38 -4
- package/dist/attempt.d.ts.map +1 -1
- package/dist/attempt.js +14 -1
- package/dist/binary.d.ts +0 -5
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +1 -1
- package/dist/bootstrap.d.ts +28 -9
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +185 -80
- package/dist/chain.d.ts +11 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +9 -14
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -63
- package/dist/change.d.ts +31 -1
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +10 -1
- package/dist/client.d.ts +24 -12
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +98 -11
- package/dist/collection.d.ts +12 -6
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +51 -76
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +773 -0
- package/dist/connection.d.ts +46 -16
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +3740 -837
- package/dist/conversation.d.ts +33 -12
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +662 -202
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/durability.d.ts +5 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +20 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +151 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/file.d.ts +2 -19
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +7 -122
- package/dist/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +370 -0
- package/dist/host.d.ts +15 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +134 -17
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +3 -0
- package/dist/index.d.ts +15 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/live.d.ts +22 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +124 -0
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +11 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +98 -28
- package/dist/messages.d.ts +28 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +90 -0
- package/dist/model.d.ts +10 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +17 -2
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +20 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +113 -12
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +49 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +40 -0
- package/dist/overlay.d.ts +3 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +100 -182
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/query.d.ts +66 -4
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +48 -7
- package/dist/reach.d.ts +18 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +225 -71
- package/dist/react.d.ts +8 -6
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -17
- package/dist/readiness.d.ts +63 -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 +91 -0
- package/dist/recovery.d.ts +26 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +224 -0
- package/dist/refresh.d.ts +16 -15
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +113 -49
- package/dist/replica.d.ts +56 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +298 -151
- package/dist/room-draft.d.ts +34 -4
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +105 -31
- package/dist/rows.d.ts +37 -37
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +173 -104
- package/dist/save.d.ts +52 -9
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +539 -171
- package/dist/search.d.ts +39 -28
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +37 -105
- 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 +16 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +431 -0
- package/dist/status.d.ts +9 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -1
- package/dist/store.d.ts +114 -75
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +342 -442
- package/dist/stored.d.ts +135 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +580 -0
- package/dist/tables.d.ts +352 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +621 -0
- package/dist/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +75 -0
- package/dist/validation.d.ts +30 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +162 -0
- package/dist/windows.d.ts +22 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +89 -0
- package/dist/wire.d.ts +168 -32
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +56 -31
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +156 -0
- package/package.json +22 -19
- package/AGENTS.md +0 -318
- package/dist/chat/acts.d.ts +0 -34
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/context.d.ts +0 -3
- package/dist/chat/context.d.ts.map +0 -1
- package/dist/chat/context.js +0 -10
- package/dist/chat/input.d.ts +0 -9
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -99
- package/dist/chat/kit.d.ts +0 -60
- package/dist/chat/kit.d.ts.map +0 -1
- package/dist/chat/kit.js +0 -123
- package/dist/chat/lasting.d.ts +0 -6
- package/dist/chat/lasting.d.ts.map +0 -1
- package/dist/chat/lasting.js +0 -19
- package/dist/chat/list.d.ts +0 -20
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -59
- package/dist/chat/markdown.d.ts +0 -19
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -187
- package/dist/chat/message.d.ts +0 -6
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -192
- package/dist/chat/messages.d.ts +0 -21
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -151
- package/dist/chat/name.d.ts +0 -6
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -11
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -17
- package/dist/chat/overlay.d.ts +0 -31
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -97
- package/dist/chat/parts.d.ts +0 -57
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -119
- package/dist/chat/process.d.ts +0 -20
- package/dist/chat/process.d.ts.map +0 -1
- package/dist/chat/process.js +0 -32
- package/dist/chat/provider.d.ts +0 -63
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -645
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -80
- package/dist/chat/questions.d.ts +0 -31
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/questions.js +0 -111
- package/dist/chat/read.d.ts +0 -5
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/read.js +0 -13
- package/dist/chat/ready.d.ts +0 -33
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -91
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -302
- package/dist/chat.d.ts +0 -14
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -8
- package/dist/read-side.d.ts +0 -18
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -440
package/dist/identity.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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;
|
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,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);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryRequest, BinaryResult,
|
|
2
|
-
export type { Change, ChangeBatch, Precondition, WrittenBy } from './change.js';
|
|
1
|
+
export type { AcceptedMessage, AcceptedRoom, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, AttachRequest, AttachResult, Authorization, BinaryFile, BinaryLinkResult, BinaryRequest, BinaryResult, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, DiscoveryScope, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldContent, HeldFile, HeldRevisions, 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
|
+
export type { Change, ChangeBatch, Precondition, RoomMove, WrittenBy } from './change.js';
|
|
3
3
|
export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
4
|
-
export type {
|
|
5
|
-
export type { AppRoom, AppTypedSelection, BinaryFileSurface, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedRoomDraft, SaveResult, } from './connection.js';
|
|
4
|
+
export type { AppRoom, AppTypedSelection, BinaryFileSurface, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult, } from './connection.js';
|
|
6
5
|
export type { Observation } from './observation.js';
|
|
7
|
-
export type { BinaryAnswer, CallResult, Failure, HistoryAnswer, QueueEntry, Submission, } from './outcome.js';
|
|
8
|
-
export type { BinaryFileRecord
|
|
6
|
+
export type { AttachAnswer, BinaryAnswer, BinaryLinkAnswer, CallResult, DownloadAnswer, Failure, HistoryAnswer, Offline, QueueEntry, Resolution, Submission, } from './outcome.js';
|
|
7
|
+
export type { BinaryFileRecord } from './binary.js';
|
|
9
8
|
export type { RuntimeError } from './failure.js';
|
|
10
|
-
export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, } from './room-draft.js';
|
|
9
|
+
export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, TextParts, } from './room-draft.js';
|
|
11
10
|
export type { SaveRefusal } from './save.js';
|
|
12
|
-
export type { DocumentHit, DocumentPart, MessageHit, SearchRequest, SearchResult, } from './search.js';
|
|
11
|
+
export type { DocumentHit, DocumentPart, MessageHit, MessagePart, SearchCoverage, SearchHits, SearchPending, SearchRequest, SearchResult, SearchUndeclared, Snippet, } from './search.js';
|
|
13
12
|
export { departure } from './change.js';
|
|
13
|
+
export { partsAfter, partsChanges } from './room-draft.js';
|
|
14
|
+
export { cutName, nameFrom, transliterated } from './name.js';
|
|
15
|
+
export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
|
|
14
16
|
export { changeBatchIdentity } from './identity.js';
|
|
17
|
+
export { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
18
|
+
export { untilAnswered } from './recovery.js';
|
|
19
|
+
export { entriesIn, patching, sortedKeys } from './shared.js';
|
|
15
20
|
export { attempts, identities, intentOf, type Answered, type Attempt, type Attempts, type Identities, } from './attempt.js';
|
|
16
21
|
export { expectedList, expecting, type ExpectedOf, type Expecting } from './expectation.js';
|
|
17
22
|
export type { RuntimeShell } from './durability.js';
|
|
23
|
+
export type { CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Installation, InstallationAmount, InstallationPause, InstallationStep, Persistence, Readiness, ReadinessStatus, RefusedRoom, RoomCoverage, RoomPreparation, SearchObligation, Space, TargetCoverage, } from './readiness.js';
|
|
18
24
|
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';
|
|
25
|
+
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
26
|
export type { MdType, ModelIdentity, ModelSnapshot, ModelState, ModelResult, TypesResult, ValidationReceipt, } from './model.js';
|
|
21
27
|
export type { OperationScopes, ReplicaAdmission, ScopedRefusal } from './adapter.js';
|
|
22
28
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,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,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,WAAW,E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YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,KAAK,EACL,cAAc,GACf,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,4 +1,10 @@
|
|
|
1
1
|
export { departure } from './change.js';
|
|
2
|
+
export { partsAfter, partsChanges } from './room-draft.js';
|
|
3
|
+
export { cutName, nameFrom, transliterated } from './name.js';
|
|
4
|
+
export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
|
|
2
5
|
export { changeBatchIdentity } from './identity.js';
|
|
6
|
+
export { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
7
|
+
export { untilAnswered } from './recovery.js';
|
|
8
|
+
export { entriesIn, patching, sortedKeys } from './shared.js';
|
|
3
9
|
export { attempts, identities, intentOf, } from './attempt.js';
|
|
4
10
|
export { expectedList, expecting } from './expectation.js';
|
package/dist/live.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ChangeSet } from './change-set.js';
|
|
2
|
+
import { type KeyedResult, type QueryMessage } from './observation.js';
|
|
3
|
+
import type { PendingResult, Plan, QueryCoverage } from './query.js';
|
|
4
|
+
import type { QueryRoom } from './tables.js';
|
|
5
|
+
export type Cover = {
|
|
6
|
+
coverage: QueryCoverage;
|
|
7
|
+
rooms: readonly QueryRoom[];
|
|
8
|
+
} | PendingResult;
|
|
9
|
+
export type Ran = KeyedResult & {
|
|
10
|
+
readonly current: () => boolean;
|
|
11
|
+
};
|
|
12
|
+
export type Run = (plan: Plan, cover: () => Cover) => Promise<Ran>;
|
|
13
|
+
type Listener = (message: QueryMessage) => void;
|
|
14
|
+
export type LiveQueries = {
|
|
15
|
+
touched(set: ChangeSet): void;
|
|
16
|
+
recover(): void;
|
|
17
|
+
watch(plan: Plan, identity: string, cover: () => Cover, deliver: Listener): () => void;
|
|
18
|
+
close(): void;
|
|
19
|
+
};
|
|
20
|
+
export declare function createLiveQueries(run: Run): LiveQueries;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=live.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAA;CAAE,GAAG,aAAa,CAAC;AAE7F,MAAM,MAAM,GAAG,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEnE,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;AAchD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,IAAI,CAAC;IACvF,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAoCF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW,CAuFvD"}
|
package/dist/live.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { changeOf, digestOf, } from './observation.js';
|
|
2
|
+
import { roomOfKey } from './rows.js';
|
|
3
|
+
function narrowed(plan) {
|
|
4
|
+
return (plan.paths !== null &&
|
|
5
|
+
plan.hop === null &&
|
|
6
|
+
plan.backlinks === null &&
|
|
7
|
+
!(plan.shape.kind === 'documents' && plan.shape.backlinks));
|
|
8
|
+
}
|
|
9
|
+
function reads(plan, locator) {
|
|
10
|
+
if (plan.locked.includes(locator))
|
|
11
|
+
return false;
|
|
12
|
+
if (plan.rooms !== null && !plan.rooms.includes(locator))
|
|
13
|
+
return false;
|
|
14
|
+
if (plan.reach === null)
|
|
15
|
+
return true;
|
|
16
|
+
return (plan.reach.rooms.includes(locator) ||
|
|
17
|
+
plan.reach.documents.some((document) => roomOfKey(document) === locator) ||
|
|
18
|
+
plan.reach.areas.some((area) => area.room === locator && area.types.length > 0));
|
|
19
|
+
}
|
|
20
|
+
function affected(plan, set) {
|
|
21
|
+
if (set.rooms.some((locator) => reads(plan, locator)))
|
|
22
|
+
return true;
|
|
23
|
+
const paths = narrowed(plan) ? new Set(plan.paths) : null;
|
|
24
|
+
return set.documents.some(({ locator, path }) => reads(plan, locator) && (paths === null || path === null || paths.has(path)));
|
|
25
|
+
}
|
|
26
|
+
function shown(entry) {
|
|
27
|
+
const cover = entry.cover();
|
|
28
|
+
return JSON.stringify('pending' in cover ? cover : cover.coverage);
|
|
29
|
+
}
|
|
30
|
+
export function createLiveQueries(run) {
|
|
31
|
+
const entries = new Map();
|
|
32
|
+
let closed = false;
|
|
33
|
+
function deliver(entry, next) {
|
|
34
|
+
const previous = entry.digest;
|
|
35
|
+
entry.digest = digestOf(next);
|
|
36
|
+
entry.covered = JSON.stringify('pending' in next.result ? next.result : next.result.coverage);
|
|
37
|
+
const change = previous === undefined ? null : changeOf(previous, next);
|
|
38
|
+
if (change !== null) {
|
|
39
|
+
for (const listener of entry.ready)
|
|
40
|
+
listener(change);
|
|
41
|
+
}
|
|
42
|
+
for (const listener of entry.fresh) {
|
|
43
|
+
entry.ready.add(listener);
|
|
44
|
+
listener(next);
|
|
45
|
+
}
|
|
46
|
+
entry.fresh.clear();
|
|
47
|
+
}
|
|
48
|
+
function schedule(entry) {
|
|
49
|
+
if (closed || entry.listeners.size === 0)
|
|
50
|
+
return;
|
|
51
|
+
if (entry.running) {
|
|
52
|
+
entry.dirty = true;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
entry.running = true;
|
|
56
|
+
void (async () => {
|
|
57
|
+
try {
|
|
58
|
+
for (;;) {
|
|
59
|
+
entry.dirty = false;
|
|
60
|
+
const { current, ...next } = await run(entry.plan, entry.cover);
|
|
61
|
+
if (closed || entry.listeners.size === 0)
|
|
62
|
+
return;
|
|
63
|
+
deliver(entry, next);
|
|
64
|
+
if (!(entry.dirty && !current()) && shown(entry) === entry.covered)
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
entry.dirty = false;
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
entry.running = false;
|
|
73
|
+
}
|
|
74
|
+
})();
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
touched(set) {
|
|
78
|
+
for (const entry of entries.values()) {
|
|
79
|
+
if (affected(entry.plan, set))
|
|
80
|
+
schedule(entry);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
recover() {
|
|
84
|
+
for (const entry of entries.values()) {
|
|
85
|
+
if (entry.running)
|
|
86
|
+
continue;
|
|
87
|
+
if (entry.digest === undefined || shown(entry) !== entry.covered)
|
|
88
|
+
schedule(entry);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
watch(plan, identity, cover, listener) {
|
|
92
|
+
let entry = entries.get(identity);
|
|
93
|
+
if (entry === undefined) {
|
|
94
|
+
entry = {
|
|
95
|
+
plan,
|
|
96
|
+
cover,
|
|
97
|
+
listeners: new Set(),
|
|
98
|
+
fresh: new Set(),
|
|
99
|
+
ready: new Set(),
|
|
100
|
+
digest: undefined,
|
|
101
|
+
covered: '',
|
|
102
|
+
dirty: false,
|
|
103
|
+
running: false,
|
|
104
|
+
};
|
|
105
|
+
entries.set(identity, entry);
|
|
106
|
+
}
|
|
107
|
+
const held = entry;
|
|
108
|
+
held.listeners.add(listener);
|
|
109
|
+
held.fresh.add(listener);
|
|
110
|
+
schedule(held);
|
|
111
|
+
return () => {
|
|
112
|
+
held.listeners.delete(listener);
|
|
113
|
+
held.fresh.delete(listener);
|
|
114
|
+
held.ready.delete(listener);
|
|
115
|
+
if (held.listeners.size === 0 && entries.get(identity) === held)
|
|
116
|
+
entries.delete(identity);
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
close() {
|
|
120
|
+
closed = true;
|
|
121
|
+
entries.clear();
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
package/dist/media.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MdRuntimeClient } from './client.js';
|
|
2
|
+
import { type ShownAnswer } from './outcome.js';
|
|
3
|
+
export declare const ROOM_MEDIA = "room-media";
|
|
4
|
+
type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
|
|
5
|
+
export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
|
|
6
|
+
export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient, registry?: CustomElementRegistry): void;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3D,eAAO,MAAM,UAAU,eAAe,CAAC;AAwBvC,KAAK,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAIpF,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,GAAG,eAAe,CAG5E;AAsBD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,EAClD,QAAQ,GAAE,qBAAsC,GAC/C,IAAI,CA0LN"}
|
package/dist/media.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { UNCERTAIN } from './outcome.js';
|
|
2
|
+
export const ROOM_MEDIA = 'room-media';
|
|
3
|
+
const ATTRIBUTES = ['room', 'path', 'revision', 'width', 'height', 'alt'];
|
|
4
|
+
const LOADING = new Set(['room', 'path', 'revision']);
|
|
5
|
+
const NEARING = '600px 0px';
|
|
6
|
+
const RELINKS = 2;
|
|
7
|
+
// The Room's stream brings a file seconds after the text that links it, minutes after on a first open, and a page's reach of its Rooms settles seconds after it opens, so a file not shown yet is asked for again every three seconds.
|
|
8
|
+
const UNSHOWN_MS = 3_000;
|
|
9
|
+
const SHAPE = '16 / 9';
|
|
10
|
+
const STYLE = `:host{display:block}
|
|
11
|
+
[part=box]{position:relative;overflow:hidden}
|
|
12
|
+
[part=box]>img,[part=box]>video,[part=box]>audio{display:block;width:100%;height:100%;object-fit:contain}
|
|
13
|
+
[part=box]>slot{display:flex;align-items:center;justify-content:center;width:100%;height:100%;text-align:center}`;
|
|
14
|
+
const shows = new WeakMap();
|
|
15
|
+
export function shownBy(show, client) {
|
|
16
|
+
shows.set(client, show);
|
|
17
|
+
return client;
|
|
18
|
+
}
|
|
19
|
+
function ratioOf(width, height) {
|
|
20
|
+
const across = Number(width);
|
|
21
|
+
const down = Number(height);
|
|
22
|
+
return Number.isFinite(across) && Number.isFinite(down) && across > 0 && down > 0
|
|
23
|
+
? `${across} / ${down}`
|
|
24
|
+
: SHAPE;
|
|
25
|
+
}
|
|
26
|
+
function refusedForGood(shown) {
|
|
27
|
+
if (shown.kind === 'revoked-authorization')
|
|
28
|
+
return true;
|
|
29
|
+
return (shown.kind === 'rejected' || shown.kind === 'scoped-refusal') && !shown.retryable;
|
|
30
|
+
}
|
|
31
|
+
function drawnFor(mediaType) {
|
|
32
|
+
if (mediaType.startsWith('image/'))
|
|
33
|
+
return 'img';
|
|
34
|
+
if (mediaType.startsWith('video/'))
|
|
35
|
+
return 'video';
|
|
36
|
+
if (mediaType.startsWith('audio/'))
|
|
37
|
+
return 'audio';
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
export function defineRoomMedia(client, registry = customElements) {
|
|
41
|
+
if (registry.get(ROOM_MEDIA) !== undefined)
|
|
42
|
+
return;
|
|
43
|
+
const connected = Promise.resolve(client);
|
|
44
|
+
class RoomMedia extends HTMLElement {
|
|
45
|
+
static observedAttributes = ATTRIBUTES;
|
|
46
|
+
#root = this.attachShadow({ mode: 'open' });
|
|
47
|
+
#box = document.createElement('div');
|
|
48
|
+
#fallback = document.createElement('slot');
|
|
49
|
+
#watching = null;
|
|
50
|
+
#near = false;
|
|
51
|
+
#asked = 0;
|
|
52
|
+
#shown = null;
|
|
53
|
+
#drawn = null;
|
|
54
|
+
#loaded = false;
|
|
55
|
+
#relinked = 0;
|
|
56
|
+
constructor() {
|
|
57
|
+
super();
|
|
58
|
+
this.#box.setAttribute('part', 'box');
|
|
59
|
+
this.#root.append(Object.assign(document.createElement('style'), { textContent: STYLE }), this.#box);
|
|
60
|
+
this.#shape();
|
|
61
|
+
}
|
|
62
|
+
connectedCallback() {
|
|
63
|
+
this.#label();
|
|
64
|
+
this.#watching ??= new IntersectionObserver((seen) => {
|
|
65
|
+
if (!seen.some((entry) => entry.isIntersecting) || this.#near)
|
|
66
|
+
return;
|
|
67
|
+
this.#near = true;
|
|
68
|
+
void this.#load();
|
|
69
|
+
}, { rootMargin: NEARING });
|
|
70
|
+
this.#watching.observe(this);
|
|
71
|
+
}
|
|
72
|
+
disconnectedCallback() {
|
|
73
|
+
this.#watching?.disconnect();
|
|
74
|
+
this.#watching = null;
|
|
75
|
+
this.#near = false;
|
|
76
|
+
this.#asked += 1;
|
|
77
|
+
this.#show(null);
|
|
78
|
+
}
|
|
79
|
+
attributeChangedCallback(name, before, after) {
|
|
80
|
+
if (before === after)
|
|
81
|
+
return;
|
|
82
|
+
this.#shape();
|
|
83
|
+
if (this.isConnected)
|
|
84
|
+
this.#label();
|
|
85
|
+
if (!LOADING.has(name) || !this.#near)
|
|
86
|
+
return;
|
|
87
|
+
this.#relinked = 0;
|
|
88
|
+
void this.#load();
|
|
89
|
+
}
|
|
90
|
+
#shape() {
|
|
91
|
+
this.#box.style.aspectRatio = ratioOf(this.getAttribute('width'), this.getAttribute('height'));
|
|
92
|
+
}
|
|
93
|
+
#label() {
|
|
94
|
+
const alt = this.getAttribute('alt') ?? '';
|
|
95
|
+
const drawn = this.#drawn;
|
|
96
|
+
if (drawn instanceof HTMLMediaElement) {
|
|
97
|
+
this.removeAttribute('role');
|
|
98
|
+
this.removeAttribute('aria-label');
|
|
99
|
+
drawn.setAttribute('aria-label', alt);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
this.setAttribute('role', 'img');
|
|
103
|
+
this.setAttribute('aria-label', alt);
|
|
104
|
+
if (drawn !== null)
|
|
105
|
+
drawn.alt = '';
|
|
106
|
+
}
|
|
107
|
+
async #load() {
|
|
108
|
+
const asked = (this.#asked += 1);
|
|
109
|
+
this.#loaded = false;
|
|
110
|
+
const room = this.getAttribute('room');
|
|
111
|
+
const path = this.getAttribute('path');
|
|
112
|
+
const revision = this.getAttribute('revision') ?? undefined;
|
|
113
|
+
if (room === null || path === null) {
|
|
114
|
+
this.#unreadable();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const show = shows.get(await connected);
|
|
118
|
+
const shown = show === undefined ? null : await show(room, path, revision).catch(() => UNCERTAIN);
|
|
119
|
+
if (asked !== this.#asked)
|
|
120
|
+
return;
|
|
121
|
+
if (shown?.kind === 'link') {
|
|
122
|
+
this.#draw({ url: shown.url, copy: false }, shown.mediaType);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (shown?.kind !== 'binary') {
|
|
126
|
+
if (shown === null || refusedForGood(shown))
|
|
127
|
+
this.#unreadable();
|
|
128
|
+
else
|
|
129
|
+
this.#unshown(asked);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const copy = await new Response(shown.stream, {
|
|
133
|
+
headers: { 'content-type': shown.mediaType },
|
|
134
|
+
})
|
|
135
|
+
.blob()
|
|
136
|
+
.catch(() => null);
|
|
137
|
+
if (asked !== this.#asked)
|
|
138
|
+
return;
|
|
139
|
+
if (copy === null)
|
|
140
|
+
this.#unshown(asked);
|
|
141
|
+
else
|
|
142
|
+
this.#draw({ url: URL.createObjectURL(copy), copy: true }, shown.mediaType);
|
|
143
|
+
}
|
|
144
|
+
#unshown(asked) {
|
|
145
|
+
this.#unreadable();
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
if (asked === this.#asked && this.#near)
|
|
148
|
+
void this.#load();
|
|
149
|
+
}, UNSHOWN_MS);
|
|
150
|
+
}
|
|
151
|
+
#show(shown, content = null) {
|
|
152
|
+
if (this.#shown?.copy === true)
|
|
153
|
+
URL.revokeObjectURL(this.#shown.url);
|
|
154
|
+
this.#shown = shown;
|
|
155
|
+
if (content !== this.#drawn)
|
|
156
|
+
this.#drawn = null;
|
|
157
|
+
if (content === null)
|
|
158
|
+
this.#box.replaceChildren();
|
|
159
|
+
else if (content.parentNode !== this.#box)
|
|
160
|
+
this.#box.replaceChildren(content);
|
|
161
|
+
this.#label();
|
|
162
|
+
}
|
|
163
|
+
#unreadable() {
|
|
164
|
+
this.#show(null, this.#fallback);
|
|
165
|
+
}
|
|
166
|
+
#draw(shown, mediaType) {
|
|
167
|
+
const tag = drawnFor(mediaType);
|
|
168
|
+
if (tag === null) {
|
|
169
|
+
if (shown.copy)
|
|
170
|
+
URL.revokeObjectURL(shown.url);
|
|
171
|
+
this.#unreadable();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const kept = this.#drawn?.localName === tag ? this.#drawn : null;
|
|
175
|
+
const drawn = kept ?? document.createElement(tag);
|
|
176
|
+
if (kept === null) {
|
|
177
|
+
if (drawn instanceof HTMLImageElement)
|
|
178
|
+
drawn.decoding = 'async';
|
|
179
|
+
if (drawn instanceof HTMLMediaElement) {
|
|
180
|
+
drawn.controls = true;
|
|
181
|
+
drawn.preload = 'metadata';
|
|
182
|
+
if (drawn instanceof HTMLVideoElement)
|
|
183
|
+
drawn.playsInline = true;
|
|
184
|
+
}
|
|
185
|
+
drawn.addEventListener(drawn instanceof HTMLImageElement ? 'load' : 'loadedmetadata', () => {
|
|
186
|
+
if (drawn !== this.#drawn)
|
|
187
|
+
return;
|
|
188
|
+
this.#loaded = true;
|
|
189
|
+
this.#relinked = 0;
|
|
190
|
+
});
|
|
191
|
+
drawn.addEventListener('error', () => this.#failed(drawn));
|
|
192
|
+
}
|
|
193
|
+
this.#drawn = drawn;
|
|
194
|
+
this.#show(shown, drawn);
|
|
195
|
+
drawn.src = shown.url;
|
|
196
|
+
}
|
|
197
|
+
#failed(drawn) {
|
|
198
|
+
if (drawn !== this.#drawn)
|
|
199
|
+
return;
|
|
200
|
+
if (this.#shown?.copy !== false || !this.#loaded || this.#relinked >= RELINKS) {
|
|
201
|
+
this.#unreadable();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
this.#relinked += 1;
|
|
205
|
+
if (drawn instanceof HTMLMediaElement) {
|
|
206
|
+
const at = drawn.currentTime;
|
|
207
|
+
const playing = !drawn.paused;
|
|
208
|
+
drawn.addEventListener('loadedmetadata', () => {
|
|
209
|
+
drawn.currentTime = at;
|
|
210
|
+
if (playing)
|
|
211
|
+
void drawn.play().catch(() => undefined);
|
|
212
|
+
}, { once: true });
|
|
213
|
+
}
|
|
214
|
+
void this.#load();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
registry.define(ROOM_MEDIA, RoomMedia);
|
|
218
|
+
}
|
package/dist/memory.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
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 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
|
-
selectionModel?: ModelResult;
|
|
6
5
|
documents?: Readonly<Record<string, string>>;
|
|
7
6
|
revisions?: Readonly<Record<string, string>>;
|
|
7
|
+
fileIds?: Readonly<Record<string, string>>;
|
|
8
8
|
changes?: Readonly<Record<string, HeadChange>>;
|
|
9
9
|
binaryFiles?: Readonly<Record<string, BinaryFile>>;
|
|
10
|
+
folders?: readonly string[];
|
|
10
11
|
blobs?: Readonly<Record<string, Blob>>;
|
|
11
12
|
};
|
|
12
13
|
export type MemoryConversation = {
|
|
13
14
|
conversation: string;
|
|
14
|
-
listed?: Omit<ListedConversation, 'conversation'>;
|
|
15
|
+
listed?: Omit<ListedConversation, 'conversation' | 'newest'>;
|
|
15
16
|
messages?: readonly AcceptedMessage[];
|
|
16
17
|
outcomes?: Partial<Record<ConversationAction, ActionResult>>;
|
|
17
18
|
};
|
|
@@ -25,18 +26,24 @@ export type MemoryAdapterOptions = {
|
|
|
25
26
|
retention?: Retention;
|
|
26
27
|
member?: Member;
|
|
27
28
|
unopened?: boolean;
|
|
29
|
+
exhaustiveDiscovery?: true;
|
|
30
|
+
roomTypes?: string;
|
|
28
31
|
};
|
|
29
32
|
export type MemoryAdapter = Adapter & {
|
|
30
33
|
setRooms(rooms: readonly MemoryRoom[]): void;
|
|
31
34
|
setConversations(conversations: readonly MemoryConversation[]): void;
|
|
32
35
|
script(operation: keyof Adapter, answer: unknown): void;
|
|
33
36
|
open(): void;
|
|
34
|
-
close(
|
|
37
|
+
close(closing?: {
|
|
38
|
+
revoked?: boolean;
|
|
39
|
+
lost?: boolean;
|
|
40
|
+
}): void;
|
|
35
41
|
expire(locators: readonly string[]): void;
|
|
36
42
|
notifyRoomVersion(notification: {
|
|
37
43
|
locator: string;
|
|
38
44
|
roomVersion: string;
|
|
39
45
|
}): void;
|
|
46
|
+
notifyAuthorityChanged(scope?: DiscoveryScope): void;
|
|
40
47
|
notifyConversation(event: ConversationEvent): void;
|
|
41
48
|
notifyServiceMode(mode: ServiceMode): void;
|
|
42
49
|
heldRooms(): readonly string[];
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,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