@agentshouse/mdruntime 0.1.0-cfbf80d8d4644 → 0.1.0-cfe148b32e3d8
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 +299 -214
- package/README.md +21 -10
- package/dist/adapter.d.ts +126 -29
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +4 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +28 -5
- 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 +18 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +36 -5
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +207 -46
- 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 -56
- package/dist/change.d.ts +45 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +34 -0
- 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/house.d.ts +25 -0
- package/dist/chat/house.d.ts.map +1 -0
- package/dist/chat/house.js +38 -0
- package/dist/chat/input.d.ts +11 -0
- package/dist/chat/input.d.ts.map +1 -0
- package/dist/chat/input.js +92 -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 +28 -0
- package/dist/chat/list.d.ts.map +1 -0
- package/dist/chat/list.js +103 -0
- package/dist/chat/markdown.d.ts +20 -0
- package/dist/chat/markdown.d.ts.map +1 -0
- package/dist/chat/markdown.js +229 -0
- package/dist/chat/message.d.ts +7 -0
- package/dist/chat/message.d.ts.map +1 -0
- package/dist/chat/message.js +254 -0
- package/dist/chat/messages.d.ts +35 -0
- package/dist/chat/messages.d.ts.map +1 -0
- package/dist/chat/messages.js +210 -0
- package/dist/chat/name.d.ts +7 -0
- package/dist/chat/name.d.ts.map +1 -0
- package/dist/chat/name.js +37 -0
- package/dist/chat/opened.d.ts +12 -0
- package/dist/chat/opened.d.ts.map +1 -0
- package/dist/chat/opened.js +19 -0
- package/dist/chat/overlay.d.ts +32 -0
- package/dist/chat/overlay.d.ts.map +1 -0
- package/dist/chat/overlay.js +103 -0
- package/dist/chat/parts.d.ts +58 -0
- package/dist/chat/parts.d.ts.map +1 -0
- package/dist/chat/parts.js +120 -0
- package/dist/chat/pieces.d.ts +62 -0
- package/dist/chat/pieces.d.ts.map +1 -0
- package/dist/chat/pieces.js +1110 -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 +70 -0
- package/dist/chat/provider.d.ts.map +1 -0
- package/dist/chat/provider.js +635 -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 +37 -0
- package/dist/chat/ready.d.ts.map +1 -0
- package/dist/chat/ready.js +93 -0
- package/dist/chat/room-file.d.ts +8 -0
- package/dist/chat/room-file.d.ts.map +1 -0
- package/dist/chat/room-file.js +72 -0
- package/dist/chat/steady.d.ts +3 -0
- package/dist/chat/steady.d.ts.map +1 -0
- package/dist/chat/steady.js +26 -0
- package/dist/chat/style.d.ts +4 -0
- package/dist/chat/style.d.ts.map +1 -0
- package/dist/chat/style.js +307 -0
- package/dist/chat.d.ts +15 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +8 -0
- package/dist/client.d.ts +33 -13
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +105 -16
- package/dist/collection.d.ts +9 -13
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +47 -56
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +721 -0
- package/dist/connection.d.ts +57 -18
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +3572 -640
- package/dist/conversation.d.ts +39 -12
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +552 -177
- 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 +9 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +19 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +151 -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/file.d.ts +2 -10
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -120
- package/dist/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +368 -0
- package/dist/host.d.ts +15 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +111 -20
- package/dist/identity.d.ts +4 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +16 -1
- package/dist/index.d.ts +21 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/live.d.ts +22 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +123 -0
- package/dist/memory.d.ts +12 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +97 -25
- 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 +14 -4
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +12 -1
- 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 +19 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +113 -12
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- 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 +62 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +67 -1
- package/dist/overlay.d.ts +15 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +136 -180
- package/dist/query.d.ts +65 -5
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +100 -26
- package/dist/reach.d.ts +11 -4
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +194 -57
- package/dist/react.d.ts +31 -19
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +13 -21
- package/dist/readiness.d.ts +68 -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 +100 -0
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +198 -0
- package/dist/refresh.d.ts +16 -8
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +93 -55
- package/dist/replica.d.ts +60 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +319 -153
- package/dist/room-draft.d.ts +40 -9
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +153 -37
- package/dist/rows.d.ts +30 -34
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +170 -81
- package/dist/save.d.ts +71 -4
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +815 -148
- package/dist/search.d.ts +41 -29
- 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 +6 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -8
- package/dist/store.d.ts +124 -58
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +359 -344
- package/dist/stored.d.ts +145 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +567 -0
- package/dist/tables.d.ts +342 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +576 -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 +169 -33
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +68 -31
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +150 -0
- package/package.json +33 -15
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.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 -377
package/dist/identity.js
CHANGED
|
@@ -10,8 +10,23 @@ 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 binaryLocalId() {
|
|
31
|
+
return randomIdentity();
|
|
32
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
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,
|
|
2
|
-
export type { Change, ChangeBatch, Precondition, WrittenBy } from './change.js';
|
|
3
|
-
export type { ChatDraft, ChatDraftSurface, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
4
|
-
export type {
|
|
5
|
-
export type { AppRoom, AppTypedSelection, ConnectionRefusal,
|
|
1
|
+
export type { AcceptedMessage, AcceptedRoom, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryLinkResult, BinaryRequest, BinaryResult, BootstrapInventory, 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
|
+
export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
4
|
+
export type { ChosenFile, FileDeclaration } from './file.js';
|
|
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, Resolution, Submission, } from './outcome.js';
|
|
8
|
+
export type { BinaryFileRecord } 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, MessagePart, SearchCoverage, SearchHits, SearchPending, SearchRequest, SearchResult, SearchUndeclared, Snippet, } from './search.js';
|
|
13
|
+
export { departure } from './change.js';
|
|
14
|
+
export { partsAfter } from './room-draft.js';
|
|
15
|
+
export { cutName, nameFrom, transliterated } from './name.js';
|
|
16
|
+
export { SESSION_STARTED } from './conversation.js';
|
|
11
17
|
export { changeBatchIdentity } from './identity.js';
|
|
12
|
-
export
|
|
18
|
+
export { ROW_WEIGHT, stepped } from './turn.js';
|
|
19
|
+
export { entriesIn, patching, sortedKeys } from './shared.js';
|
|
20
|
+
export { attempts, identities, intentOf, type Answered, type Attempt, type Attempts, type Identities, } from './attempt.js';
|
|
21
|
+
export { expectedList, expecting, type ExpectedOf, type Expecting } from './expectation.js';
|
|
22
|
+
export type { RuntimeShell, StorageEstimate } from './durability.js';
|
|
23
|
+
export type { CapacityCause, CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Installation, InstallationAmount, InstallationPause, InstallationStep, Persistence, Readiness, ReadinessStatus, RefusedRoom, RoomCoverage, RoomPreparation, SearchObligation, TargetCoverage, } from './readiness.js';
|
|
13
24
|
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';
|
|
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';
|
|
15
26
|
export type { MdType, ModelIdentity, ModelSnapshot, ModelState, ModelResult, TypesResult, ValidationReceipt, } from './model.js';
|
|
16
27
|
export type { OperationScopes, ReplicaAdmission, ScopedRefusal } from './adapter.js';
|
|
17
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,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"],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AAQ,EACR,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,UAAU,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC5F,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACrE,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,eAAe,EACf,WAAW,EACX,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,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 +1,9 @@
|
|
|
1
|
+
export { departure } from './change.js';
|
|
2
|
+
export { partsAfter } from './room-draft.js';
|
|
3
|
+
export { cutName, nameFrom, transliterated } from './name.js';
|
|
4
|
+
export { SESSION_STARTED } from './conversation.js';
|
|
1
5
|
export { changeBatchIdentity } from './identity.js';
|
|
6
|
+
export { ROW_WEIGHT, stepped } from './turn.js';
|
|
7
|
+
export { entriesIn, patching, sortedKeys } from './shared.js';
|
|
8
|
+
export { attempts, identities, intentOf, } from './attempt.js';
|
|
9
|
+
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;AAmCF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW,CAuFvD"}
|
package/dist/live.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
}
|
|
19
|
+
function affected(plan, set) {
|
|
20
|
+
if (set.rooms.some((locator) => reads(plan, locator)))
|
|
21
|
+
return true;
|
|
22
|
+
const paths = narrowed(plan) ? new Set(plan.paths) : null;
|
|
23
|
+
return set.documents.some(({ locator, path }) => reads(plan, locator) && (paths === null || path === null || paths.has(path)));
|
|
24
|
+
}
|
|
25
|
+
function shown(entry) {
|
|
26
|
+
const cover = entry.cover();
|
|
27
|
+
return JSON.stringify('pending' in cover ? cover : cover.coverage);
|
|
28
|
+
}
|
|
29
|
+
export function createLiveQueries(run) {
|
|
30
|
+
const entries = new Map();
|
|
31
|
+
let closed = false;
|
|
32
|
+
function deliver(entry, next) {
|
|
33
|
+
const previous = entry.digest;
|
|
34
|
+
entry.digest = digestOf(next);
|
|
35
|
+
entry.covered = JSON.stringify('pending' in next.result ? next.result : next.result.coverage);
|
|
36
|
+
const change = previous === undefined ? null : changeOf(previous, next);
|
|
37
|
+
if (change !== null) {
|
|
38
|
+
for (const listener of entry.ready)
|
|
39
|
+
listener(change);
|
|
40
|
+
}
|
|
41
|
+
for (const listener of entry.fresh) {
|
|
42
|
+
entry.ready.add(listener);
|
|
43
|
+
listener(next);
|
|
44
|
+
}
|
|
45
|
+
entry.fresh.clear();
|
|
46
|
+
}
|
|
47
|
+
function schedule(entry) {
|
|
48
|
+
if (closed || entry.listeners.size === 0)
|
|
49
|
+
return;
|
|
50
|
+
if (entry.running) {
|
|
51
|
+
entry.dirty = true;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
entry.running = true;
|
|
55
|
+
void (async () => {
|
|
56
|
+
try {
|
|
57
|
+
for (;;) {
|
|
58
|
+
entry.dirty = false;
|
|
59
|
+
const { current, ...next } = await run(entry.plan, entry.cover);
|
|
60
|
+
if (closed || entry.listeners.size === 0)
|
|
61
|
+
return;
|
|
62
|
+
deliver(entry, next);
|
|
63
|
+
if (!(entry.dirty && !current()) && shown(entry) === entry.covered)
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
entry.dirty = false;
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
entry.running = false;
|
|
72
|
+
}
|
|
73
|
+
})();
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
touched(set) {
|
|
77
|
+
for (const entry of entries.values()) {
|
|
78
|
+
if (affected(entry.plan, set))
|
|
79
|
+
schedule(entry);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
recover() {
|
|
83
|
+
for (const entry of entries.values()) {
|
|
84
|
+
if (entry.running)
|
|
85
|
+
continue;
|
|
86
|
+
if (entry.digest === undefined || shown(entry) !== entry.covered)
|
|
87
|
+
schedule(entry);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
watch(plan, identity, cover, listener) {
|
|
91
|
+
let entry = entries.get(identity);
|
|
92
|
+
if (entry === undefined) {
|
|
93
|
+
entry = {
|
|
94
|
+
plan,
|
|
95
|
+
cover,
|
|
96
|
+
listeners: new Set(),
|
|
97
|
+
fresh: new Set(),
|
|
98
|
+
ready: new Set(),
|
|
99
|
+
digest: undefined,
|
|
100
|
+
covered: '',
|
|
101
|
+
dirty: false,
|
|
102
|
+
running: false,
|
|
103
|
+
};
|
|
104
|
+
entries.set(identity, entry);
|
|
105
|
+
}
|
|
106
|
+
const held = entry;
|
|
107
|
+
held.listeners.add(listener);
|
|
108
|
+
held.fresh.add(listener);
|
|
109
|
+
schedule(held);
|
|
110
|
+
return () => {
|
|
111
|
+
held.listeners.delete(listener);
|
|
112
|
+
held.fresh.delete(listener);
|
|
113
|
+
held.ready.delete(listener);
|
|
114
|
+
if (held.listeners.size === 0 && entries.get(identity) === held)
|
|
115
|
+
entries.delete(identity);
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
close() {
|
|
119
|
+
closed = true;
|
|
120
|
+
entries.clear();
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
package/dist/memory.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
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
|
+
folders?: readonly string[];
|
|
12
|
+
blobs?: Readonly<Record<string, Blob>>;
|
|
11
13
|
};
|
|
12
14
|
export type MemoryConversation = {
|
|
13
15
|
conversation: string;
|
|
@@ -23,19 +25,25 @@ export type MemoryAdapterOptions = {
|
|
|
23
25
|
capabilities?: readonly Capability[];
|
|
24
26
|
providerLimits?: readonly ProviderLimit[];
|
|
25
27
|
retention?: Retention;
|
|
28
|
+
member?: Member;
|
|
26
29
|
unopened?: boolean;
|
|
30
|
+
exhaustiveDiscovery?: true;
|
|
27
31
|
};
|
|
28
32
|
export type MemoryAdapter = Adapter & {
|
|
29
33
|
setRooms(rooms: readonly MemoryRoom[]): void;
|
|
30
34
|
setConversations(conversations: readonly MemoryConversation[]): void;
|
|
31
35
|
script(operation: keyof Adapter, answer: unknown): void;
|
|
32
36
|
open(): void;
|
|
33
|
-
close(
|
|
37
|
+
close(closing?: {
|
|
38
|
+
revoked?: boolean;
|
|
39
|
+
lost?: boolean;
|
|
40
|
+
}): void;
|
|
34
41
|
expire(locators: readonly string[]): void;
|
|
35
42
|
notifyRoomVersion(notification: {
|
|
36
43
|
locator: string;
|
|
37
44
|
roomVersion: string;
|
|
38
45
|
}): void;
|
|
46
|
+
notifyAuthorityChanged(scope?: DiscoveryScope): void;
|
|
39
47
|
notifyConversation(event: ConversationEvent): void;
|
|
40
48
|
notifyServiceMode(mode: ServiceMode): void;
|
|
41
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,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,EAEZ,KAAK,UAAU,EAMf,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAItB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,UAAU,EAGf,KAAK,kBAAkB,EACvB,KAAK,MAAM,EAGX,KAAK,aAAa,EAGlB,KAAK,SAAS,EAGd,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAkBtB,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG;IACxC,KA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= {
|
|
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,46 @@ 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:
|
|
129
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
130
|
+
...(opening && room.folders !== undefined ? { folders: room.folders } : {}),
|
|
131
|
+
...(next < paths.length ? { pageToken: taken.at(-1) } : {}),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function foldersMoved(room, from) {
|
|
135
|
+
const now = new Set(room.folders ?? []);
|
|
136
|
+
const before = new Set(from.folders ?? []);
|
|
137
|
+
const folders = [...now].filter((folder) => !before.has(folder)).sort();
|
|
138
|
+
const folderRemovals = [...before].filter((folder) => !now.has(folder)).sort();
|
|
139
|
+
return {
|
|
140
|
+
...(folders.length === 0 ? {} : { folders }),
|
|
141
|
+
...(folderRemovals.length === 0 ? {} : { folderRemovals }),
|
|
126
142
|
};
|
|
127
143
|
}
|
|
128
144
|
function advancement(room, from, at) {
|
|
129
145
|
const current = room.documents ?? {};
|
|
130
146
|
const previous = from.documents ?? {};
|
|
131
|
-
const currentTargets = new Set(room.
|
|
132
|
-
const previousTargets = new Set(from.
|
|
147
|
+
const currentTargets = new Set(Object.keys(room.binaryFiles ?? {}));
|
|
148
|
+
const previousTargets = new Set(Object.keys(from.binaryFiles ?? {}));
|
|
133
149
|
const headMoved = (path) => room.revisions?.[path] !== from.revisions?.[path] ||
|
|
150
|
+
room.fileIds?.[path] !== from.fileIds?.[path] ||
|
|
134
151
|
!sameChange(room.changes?.[path], from.changes?.[path]);
|
|
135
152
|
const changed = Object.keys(current)
|
|
136
153
|
.filter((path) => current[path] !== previous[path] || headMoved(path))
|
|
@@ -145,24 +162,25 @@ export function createMemoryAdapter(options = {}) {
|
|
|
145
162
|
const targets = opening
|
|
146
163
|
? [...currentTargets].filter((target) => !previousTargets.has(target) || headMoved(target))
|
|
147
164
|
: [];
|
|
148
|
-
const attachments = room.attachments ?? [];
|
|
149
|
-
const declared = opening && JSON.stringify(attachments) !== JSON.stringify(from.attachments ?? []);
|
|
150
165
|
const models = opening ? changedModels(room, from) : undefined;
|
|
151
166
|
return {
|
|
152
167
|
kind: 'net-advancement',
|
|
153
168
|
roomVersion: room.roomVersion,
|
|
154
169
|
...(models === undefined ? {} : { models }),
|
|
155
170
|
documents: named(current, taken),
|
|
156
|
-
revisions: named(room.revisions ?? {}, taken),
|
|
171
|
+
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
172
|
+
...(room.fileIds === undefined
|
|
173
|
+
? {}
|
|
174
|
+
: { fileIds: named(room.fileIds, [...taken, ...targets]) }),
|
|
157
175
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
158
|
-
|
|
176
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
177
|
+
...(opening ? foldersMoved(room, from) : {}),
|
|
159
178
|
removals: opening
|
|
160
179
|
? [
|
|
161
180
|
...Object.keys(previous).filter((path) => !(path in current) && !currentTargets.has(path)),
|
|
162
181
|
...[...previousTargets].filter((target) => !currentTargets.has(target) && !(target in current)),
|
|
163
182
|
].sort()
|
|
164
183
|
: [],
|
|
165
|
-
...(declared ? { attachments } : {}),
|
|
166
184
|
...(pageToken === undefined ? {} : { pageToken }),
|
|
167
185
|
};
|
|
168
186
|
}
|
|
@@ -183,7 +201,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
183
201
|
function historiesOf(input) {
|
|
184
202
|
const asked = input?.conversations;
|
|
185
203
|
if (!Array.isArray(asked))
|
|
186
|
-
return { kind: 'rejected', code: 'invalid_request', fields: {} };
|
|
204
|
+
return { kind: 'rejected', code: 'invalid_request', fields: {}, retryable: false };
|
|
187
205
|
const histories = [];
|
|
188
206
|
for (const entry of asked) {
|
|
189
207
|
const conversation = typeof entry.conversation === 'string' ? scripted.get(entry.conversation) : undefined;
|
|
@@ -211,21 +229,32 @@ export function createMemoryAdapter(options = {}) {
|
|
|
211
229
|
const named = typeof input.conversation === 'string' ? input.conversation : '';
|
|
212
230
|
const conversation = scripted.get(named);
|
|
213
231
|
if (conversation === undefined) {
|
|
214
|
-
return {
|
|
232
|
+
return {
|
|
233
|
+
kind: 'rejected',
|
|
234
|
+
code: 'unknown-conversation',
|
|
235
|
+
fields: { conversation: named },
|
|
236
|
+
retryable: false,
|
|
237
|
+
};
|
|
215
238
|
}
|
|
216
239
|
const outcome = conversation.outcomes?.[name];
|
|
217
240
|
if (outcome !== undefined)
|
|
218
241
|
return outcome;
|
|
219
242
|
if (name === 'conversation.send') {
|
|
243
|
+
const operation = typeof input.operation_id === 'string' ? input.operation_id : null;
|
|
244
|
+
const answered = operation === null ? undefined : sentTurns.get(operation);
|
|
245
|
+
if (answered !== undefined)
|
|
246
|
+
return { kind: 'action', result: { turn: answered } };
|
|
220
247
|
issued += 1;
|
|
221
248
|
const turn = `turn-${issued}`;
|
|
222
249
|
unsealed.set(turn, named);
|
|
250
|
+
if (operation !== null)
|
|
251
|
+
sentTurns.set(operation, turn);
|
|
223
252
|
return { kind: 'action', result: { turn } };
|
|
224
253
|
}
|
|
225
254
|
if (name === 'conversation.cancel') {
|
|
226
255
|
const turn = typeof input.turn === 'string' ? input.turn : '';
|
|
227
256
|
if (sealed.has(turn) || !unsealed.has(turn)) {
|
|
228
|
-
return { kind: 'rejected', code: 'turn-sealed', fields: { turn } };
|
|
257
|
+
return { kind: 'rejected', code: 'turn-sealed', fields: { turn }, retryable: false };
|
|
229
258
|
}
|
|
230
259
|
unsealed.delete(turn);
|
|
231
260
|
return { kind: 'action', result: { turn, cancelled: true } };
|
|
@@ -246,9 +275,11 @@ export function createMemoryAdapter(options = {}) {
|
|
|
246
275
|
capabilities,
|
|
247
276
|
providerLimits,
|
|
248
277
|
retention,
|
|
278
|
+
...(options.member === undefined ? {} : { member: options.member }),
|
|
249
279
|
};
|
|
250
280
|
}
|
|
251
281
|
return {
|
|
282
|
+
...(options.exhaustiveDiscovery === undefined ? {} : { exhaustiveDiscovery: true }),
|
|
252
283
|
setRooms(next) {
|
|
253
284
|
rooms = [...next];
|
|
254
285
|
retain(rooms);
|
|
@@ -261,9 +292,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
261
292
|
for (const observer of observers)
|
|
262
293
|
observer({ kind: 'opened' });
|
|
263
294
|
},
|
|
264
|
-
close(revoked = false) {
|
|
295
|
+
close({ revoked = false, lost = !revoked } = {}) {
|
|
265
296
|
for (const observer of observers)
|
|
266
|
-
observer({ kind: 'closed', revoked });
|
|
297
|
+
observer({ kind: 'closed', revoked, lost });
|
|
267
298
|
},
|
|
268
299
|
expire(locators) {
|
|
269
300
|
expiring = [...locators];
|
|
@@ -272,6 +303,13 @@ export function createMemoryAdapter(options = {}) {
|
|
|
272
303
|
for (const observer of observers)
|
|
273
304
|
observer({ kind: 'room-version', locator, roomVersion });
|
|
274
305
|
},
|
|
306
|
+
notifyAuthorityChanged(scope) {
|
|
307
|
+
for (const observer of observers) {
|
|
308
|
+
observer(scope === undefined
|
|
309
|
+
? { kind: 'authority-changed' }
|
|
310
|
+
: { kind: 'authority-changed', scope });
|
|
311
|
+
}
|
|
312
|
+
},
|
|
275
313
|
notifyConversation(event) {
|
|
276
314
|
if (event.kind === 'accepted-message') {
|
|
277
315
|
sealed.add(event.message.turn);
|
|
@@ -330,13 +368,21 @@ export function createMemoryAdapter(options = {}) {
|
|
|
330
368
|
}
|
|
331
369
|
});
|
|
332
370
|
},
|
|
371
|
+
reopen() {
|
|
372
|
+
queueMicrotask(() => {
|
|
373
|
+
for (const observer of observers) {
|
|
374
|
+
observer({ kind: 'closed', revoked: false, lost: false });
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
},
|
|
378
|
+
published() { },
|
|
333
379
|
observe(notify) {
|
|
334
380
|
observers.add(notify);
|
|
335
381
|
queueMicrotask(() => {
|
|
336
382
|
if (!observers.has(notify))
|
|
337
383
|
return;
|
|
338
384
|
if (options.unopened === true) {
|
|
339
|
-
notify({ kind: 'closed', revoked: false });
|
|
385
|
+
notify({ kind: 'closed', revoked: false, lost: true });
|
|
340
386
|
return;
|
|
341
387
|
}
|
|
342
388
|
announceList();
|
|
@@ -379,7 +425,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
379
425
|
if (room === undefined) {
|
|
380
426
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
381
427
|
}
|
|
382
|
-
return page(room, request.pageToken
|
|
428
|
+
return page(room, request.pageToken);
|
|
383
429
|
}, request).then((answer) => note(request.locator, answer));
|
|
384
430
|
},
|
|
385
431
|
async refresh(_authorization, request) {
|
|
@@ -412,8 +458,20 @@ export function createMemoryAdapter(options = {}) {
|
|
|
412
458
|
if (room === undefined) {
|
|
413
459
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
414
460
|
}
|
|
415
|
-
return {
|
|
416
|
-
|
|
461
|
+
return {
|
|
462
|
+
kind: 'rejected',
|
|
463
|
+
code: 'unscripted-mutation',
|
|
464
|
+
fields: {},
|
|
465
|
+
retryable: false,
|
|
466
|
+
affected: {},
|
|
467
|
+
};
|
|
468
|
+
}, request).then((answer) => {
|
|
469
|
+
const destination = request.changeBatch.between?.destination.room;
|
|
470
|
+
if (answer.kind === 'accepted' && answer.destination !== undefined && destination) {
|
|
471
|
+
note(destination, answer.destination);
|
|
472
|
+
}
|
|
473
|
+
return note(request.locator, answer);
|
|
474
|
+
});
|
|
417
475
|
},
|
|
418
476
|
async history(_authorization, request) {
|
|
419
477
|
return resolveScript(scripts.history, () => {
|
|
@@ -427,11 +485,25 @@ export function createMemoryAdapter(options = {}) {
|
|
|
427
485
|
};
|
|
428
486
|
}, request);
|
|
429
487
|
},
|
|
488
|
+
async binary(_authorization, request) {
|
|
489
|
+
return resolveScript(scripts.binary, () => {
|
|
490
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
491
|
+
if (room === undefined)
|
|
492
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
493
|
+
const blob = room.blobs?.[request.path];
|
|
494
|
+
return blob === undefined
|
|
495
|
+
? { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false }
|
|
496
|
+
: { kind: 'binary', body: blob.stream(), mediaType: blob.type };
|
|
497
|
+
}, request);
|
|
498
|
+
},
|
|
499
|
+
async link(_authorization, request) {
|
|
500
|
+
return resolveScript(scripts.link, () => ({ kind: 'rejected', code: 'unscripted-link', fields: {}, retryable: false }), request);
|
|
501
|
+
},
|
|
430
502
|
async action(_authorization, request) {
|
|
431
503
|
return resolveScript(scripts.action, () => {
|
|
432
504
|
if (request.name.startsWith('conversation.'))
|
|
433
505
|
return conversationAction(request);
|
|
434
|
-
return { kind: 'rejected', code: 'unscripted-action', fields: {} };
|
|
506
|
+
return { kind: 'rejected', code: 'unscripted-action', fields: {}, retryable: false };
|
|
435
507
|
}, request).then((answer) => {
|
|
436
508
|
if (answer.kind === 'action' && answer.at !== undefined)
|
|
437
509
|
note(answer.at.locator, answer.at);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AcceptedMessage } from './adapter.js';
|
|
2
|
+
import type { Connection } from './tables.js';
|
|
3
|
+
export declare const MESSAGE_TABLES: readonly string[];
|
|
4
|
+
export type HeldConversation = {
|
|
5
|
+
readonly conversation: string;
|
|
6
|
+
readonly read: string | null | undefined;
|
|
7
|
+
readonly partial: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type MessageWindow = {
|
|
10
|
+
readonly messages: AcceptedMessage[];
|
|
11
|
+
readonly more: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type ConversationWrite = {
|
|
14
|
+
readonly conversation: string;
|
|
15
|
+
readonly messages: readonly AcceptedMessage[];
|
|
16
|
+
readonly read?: {
|
|
17
|
+
readonly at: string | null;
|
|
18
|
+
readonly partial: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare function heldConversations(connection: Connection): HeldConversation[];
|
|
22
|
+
export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
|
|
23
|
+
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null): MessageWindow;
|
|
24
|
+
export declare function messageCount(connection: Connection, conversation: string): number;
|
|
25
|
+
export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
|
|
26
|
+
export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
|
|
27
|
+
export declare function forgottenMessages(connection: Connection): void;
|
|
28
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAE1D,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAM3C,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAE7F,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;IAC9C,QAAQ,CAAC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CAC3E,CAAC;AAMF,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,gBAAgB,EAAE,CAmB5E;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,E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