@agentshouse/mdruntime 0.1.0-cfcbb238a5fa0 → 0.1.0-cfcfcecad6596
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 +24 -19
- package/dist/acceptance.d.ts +3 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +328 -0
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +26 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +341 -0
- package/dist/adapter.d.ts +287 -127
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +6 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +35 -41
- package/dist/{binary.d.ts → attachment.d.ts} +8 -9
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +15 -0
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +347 -0
- package/dist/bootstrap.d.ts +30 -11
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +309 -113
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/chain.d.ts +12 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +67 -0
- package/dist/change-set.d.ts +13 -16
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +17 -89
- package/dist/change.d.ts +36 -1
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +17 -3
- package/dist/chat-types.d.ts +3 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +11 -0
- package/dist/client.d.ts +51 -27
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +95 -28
- package/dist/collection.d.ts +34 -21
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +58 -286
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts +19 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +755 -0
- package/dist/connection.d.ts +7 -132
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +113 -3468
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/{chat/context.js → context.js} +2 -5
- package/dist/conversation-live.d.ts +149 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +259 -0
- package/dist/conversation-row.d.ts +40 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +66 -0
- package/dist/conversation.d.ts +90 -51
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +1082 -759
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/discovery.d.ts +12 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +175 -0
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +21 -4
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +12 -0
- package/dist/entry.d.ts +29 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +121 -39
- package/dist/expectation.d.ts +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +8 -0
- package/dist/figures.d.ts +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +199 -0
- package/dist/file.d.ts +2 -19
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +8 -122
- package/dist/holdings.d.ts +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +25 -11
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +165 -56
- package/dist/house-query.d.ts +24 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +102 -0
- package/dist/identity.d.ts +1 -3
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -7
- package/dist/index.d.ts +49 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -5
- package/dist/install.d.ts +60 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +537 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +290 -0
- package/dist/listing.d.ts +60 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +168 -0
- package/dist/live.d.ts +39 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +223 -0
- package/dist/loaded.d.ts +7 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +46 -0
- package/dist/locks.d.ts +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +34 -0
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +49 -0
- package/dist/media.d.ts +24 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +365 -0
- package/dist/memory.d.ts +22 -8
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +321 -122
- package/dist/messages.d.ts +63 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +169 -0
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +15 -15
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +11 -22
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +153 -0
- package/dist/name.d.ts +3 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +118 -0
- package/dist/observation.d.ts +42 -10
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +266 -39
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +69 -0
- package/dist/outcome.d.ts +71 -10
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +75 -3
- package/dist/overlay.d.ts +24 -11
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +190 -180
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +6 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +36 -0
- package/dist/paths.d.ts +2 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +26 -0
- package/dist/preparation.d.ts +46 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +344 -0
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +231 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +330 -0
- package/dist/query.d.ts +27 -193
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -470
- package/dist/{chat/questions.d.ts → questions.d.ts} +6 -7
- package/dist/questions.d.ts.map +1 -0
- package/dist/{chat/questions.js → questions.js} +14 -8
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +480 -0
- package/dist/reach.d.ts +31 -11
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +444 -112
- package/dist/react.d.ts +22 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +35 -15
- package/dist/{chat/read.d.ts → read.d.ts} +2 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/{chat/read.js → read.js} +4 -0
- package/dist/readiness.d.ts +36 -21
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +20 -18
- package/dist/reads.d.ts +38 -10
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +174 -83
- package/dist/recovery.d.ts +6 -2
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +67 -9
- package/dist/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +18 -15
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +145 -60
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +55 -0
- package/dist/replica.d.ts +45 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +340 -200
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +56 -14
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +424 -127
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +222 -0
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +40 -30
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +73 -119
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +37 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +44 -48
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +751 -303
- package/dist/saves.d.ts +34 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +463 -0
- package/dist/search.d.ts +12 -82
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +10 -207
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +89 -5
- package/dist/selector.d.ts +3 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +22 -0
- package/dist/shared.d.ts +6 -7
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +75 -104
- package/dist/shown.d.ts +35 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +326 -0
- package/dist/socket/admission.d.ts +7 -0
- package/dist/socket/admission.d.ts.map +1 -0
- package/dist/socket/admission.js +39 -0
- package/dist/socket/answers.d.ts +6 -0
- package/dist/socket/answers.d.ts.map +1 -0
- package/dist/socket/answers.js +20 -0
- package/dist/socket/lanes.d.ts +28 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +103 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket/session.d.ts +41 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +26 -0
- package/dist/socket.d.ts +68 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +165 -0
- package/dist/source.d.ts +61 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +95 -0
- package/dist/status.d.ts +4 -5
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -7
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +40 -0
- package/dist/store/readiness.d.ts +11 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +68 -0
- package/dist/store/records.d.ts +234 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +474 -0
- package/dist/store/room-held.d.ts +8 -0
- package/dist/store/room-held.d.ts.map +1 -0
- package/dist/store/room-held.js +17 -0
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store/space.d.ts +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +41 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +56 -0
- package/dist/store/writes.d.ts +24 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +125 -0
- package/dist/store.d.ts +115 -149
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +166 -716
- package/dist/stored.d.ts +181 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +807 -0
- package/dist/surface.d.ts +94 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +255 -0
- package/dist/sync.d.ts +21 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +557 -0
- package/dist/tables.d.ts +388 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +506 -0
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +128 -0
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/turn.d.ts +5 -3
- package/dist/turn.d.ts.map +1 -1
- package/dist/turn.js +51 -21
- package/dist/validation.d.ts +31 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +144 -0
- package/dist/windows.d.ts +11 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +16 -0
- package/dist/wire.d.ts +113 -10
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +42 -12
- package/package.json +20 -20
- package/AGENTS.md +0 -299
- package/dist/acquisition.d.ts +0 -14
- package/dist/acquisition.d.ts.map +0 -1
- package/dist/acquisition.js +0 -24
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.js +0 -8
- package/dist/chat/acts.d.ts +0 -33
- 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/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 -61
- 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 -27
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -63
- package/dist/chat/markdown.d.ts +0 -20
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -188
- 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 -22
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -155
- 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 -629
- 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.map +0 -1
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/ready.d.ts +0 -34
- 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/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/log.d.ts +0 -5
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/read-side.d.ts +0 -25
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -642
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DiscoveredRoom, OperationScopes, PathRule, RoomDeclaration } from './adapter.js';
|
|
2
|
+
export type WriteRefusal = {
|
|
3
|
+
readonly code: 'room-root' | 'provider-owned-path' | 'invalid-path' | `${keyof OperationScopes}-grant`;
|
|
4
|
+
readonly path: string;
|
|
5
|
+
};
|
|
6
|
+
export type WriteRule = (path: string, needs: readonly (keyof OperationScopes)[]) => WriteRefusal | null;
|
|
7
|
+
export declare function declared({ locator: _locator, roomVersion: _roomVersion, ...declaration }: DiscoveredRoom): RoomDeclaration;
|
|
8
|
+
export declare function sameDeclaration(left: RoomDeclaration, right: RoomDeclaration): boolean;
|
|
9
|
+
export declare function writeRule({ operations, providerOwnedPaths, authoredPaths, }: Pick<RoomDeclaration, 'operations' | 'providerOwnedPaths' | 'authoredPaths'>, pathRule: PathRule, local: boolean): WriteRule;
|
|
10
|
+
//# sourceMappingURL=declaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../src/declaration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/F,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,EACT,WAAW,GACX,qBAAqB,GACrB,cAAc,GACd,GAAG,MAAM,eAAe,QAAQ,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,CACtB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,CAAC,MAAM,eAAe,CAAC,EAAE,KACtC,YAAY,GAAG,IAAI,CAAC;AAEzB,wBAAgB,QAAQ,CAAC,EACvB,OAAO,EAAE,QAAQ,EACjB,WAAW,EAAE,YAAY,EACzB,GAAG,WAAW,EACf,EAAE,cAAc,GAAG,eAAe,CAElC;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAEtF;AAED,wBAAgB,SAAS,CACvB,EACE,UAAU,EACV,kBAAkB,EAClB,aAAa,GACd,EAAE,IAAI,CAAC,eAAe,EAAE,YAAY,GAAG,oBAAoB,GAAG,eAAe,CAAC,EAC/E,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,OAAO,GACb,SAAS,CAYX"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { equalValue } from '@agentshouse/mdmodel';
|
|
2
|
+
import { documentAt, covered, normalize } from './paths.js';
|
|
3
|
+
export function declared({ locator: _locator, roomVersion: _roomVersion, ...declaration }) {
|
|
4
|
+
return declaration;
|
|
5
|
+
}
|
|
6
|
+
export function sameDeclaration(left, right) {
|
|
7
|
+
return equalValue(left, right);
|
|
8
|
+
}
|
|
9
|
+
export function writeRule({ operations, providerOwnedPaths, authoredPaths, }, pathRule, local) {
|
|
10
|
+
return (path, needs) => {
|
|
11
|
+
const normalized = normalize(path.normalize('NFC'));
|
|
12
|
+
if (normalized === null || normalized === '')
|
|
13
|
+
return { code: 'room-root', path };
|
|
14
|
+
if (covered(providerOwnedPaths, normalized) || !documentAt(authoredPaths, normalized)) {
|
|
15
|
+
return { code: 'provider-owned-path', path: normalized };
|
|
16
|
+
}
|
|
17
|
+
if (!pathRule(normalized))
|
|
18
|
+
return { code: 'invalid-path', path: normalized };
|
|
19
|
+
if (local)
|
|
20
|
+
return null;
|
|
21
|
+
const missing = needs.find((operation) => !covered(operations[operation], normalized));
|
|
22
|
+
return missing === undefined ? null : { code: `${missing}-grant`, path: normalized };
|
|
23
|
+
};
|
|
24
|
+
}
|
package/dist/digest.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../src/digest.ts"],"names":[],"mappings":"AA0EA,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IAChC,GAAG,IAAI,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,MAAM,IAAI,MAAM,CAoC/B;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAMxD"}
|
package/dist/digest.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { FILE_PART_BYTES } from './tables.js';
|
|
2
|
+
const ROUNDS = new Uint32Array([
|
|
3
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
4
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
5
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
6
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
7
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
8
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
9
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
10
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
11
|
+
]);
|
|
12
|
+
const INITIAL = [
|
|
13
|
+
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
|
|
14
|
+
];
|
|
15
|
+
const BLOCK = 64;
|
|
16
|
+
function rotated(value, by) {
|
|
17
|
+
return (value >>> by) | (value << (32 - by));
|
|
18
|
+
}
|
|
19
|
+
function compressed(state, words, bytes, at) {
|
|
20
|
+
for (let index = 0; index < 16; index += 1) {
|
|
21
|
+
const from = at + index * 4;
|
|
22
|
+
words[index] =
|
|
23
|
+
(bytes[from] << 24) | (bytes[from + 1] << 16) | (bytes[from + 2] << 8) | bytes[from + 3];
|
|
24
|
+
}
|
|
25
|
+
for (let index = 16; index < 64; index += 1) {
|
|
26
|
+
const early = words[index - 15];
|
|
27
|
+
const late = words[index - 2];
|
|
28
|
+
const lower = rotated(early, 7) ^ rotated(early, 18) ^ (early >>> 3);
|
|
29
|
+
const upper = rotated(late, 17) ^ rotated(late, 19) ^ (late >>> 10);
|
|
30
|
+
words[index] = (words[index - 16] + lower + words[index - 7] + upper) | 0;
|
|
31
|
+
}
|
|
32
|
+
let a = state[0];
|
|
33
|
+
let b = state[1];
|
|
34
|
+
let c = state[2];
|
|
35
|
+
let d = state[3];
|
|
36
|
+
let e = state[4];
|
|
37
|
+
let f = state[5];
|
|
38
|
+
let g = state[6];
|
|
39
|
+
let h = state[7];
|
|
40
|
+
for (let index = 0; index < 64; index += 1) {
|
|
41
|
+
const chosen = (e & f) ^ (~e & g);
|
|
42
|
+
const first = (h +
|
|
43
|
+
(rotated(e, 6) ^ rotated(e, 11) ^ rotated(e, 25)) +
|
|
44
|
+
chosen +
|
|
45
|
+
ROUNDS[index] +
|
|
46
|
+
words[index]) |
|
|
47
|
+
0;
|
|
48
|
+
const second = ((rotated(a, 2) ^ rotated(a, 13) ^ rotated(a, 22)) + ((a & b) ^ (a & c) ^ (b & c))) | 0;
|
|
49
|
+
h = g;
|
|
50
|
+
g = f;
|
|
51
|
+
f = e;
|
|
52
|
+
e = (d + first) | 0;
|
|
53
|
+
d = c;
|
|
54
|
+
c = b;
|
|
55
|
+
b = a;
|
|
56
|
+
a = (first + second) | 0;
|
|
57
|
+
}
|
|
58
|
+
state[0] += a;
|
|
59
|
+
state[1] += b;
|
|
60
|
+
state[2] += c;
|
|
61
|
+
state[3] += d;
|
|
62
|
+
state[4] += e;
|
|
63
|
+
state[5] += f;
|
|
64
|
+
state[6] += g;
|
|
65
|
+
state[7] += h;
|
|
66
|
+
}
|
|
67
|
+
export function digest() {
|
|
68
|
+
const state = new Uint32Array(INITIAL);
|
|
69
|
+
const words = new Uint32Array(64);
|
|
70
|
+
const pending = new Uint8Array(BLOCK);
|
|
71
|
+
let held = 0;
|
|
72
|
+
let size = 0;
|
|
73
|
+
return {
|
|
74
|
+
update(bytes) {
|
|
75
|
+
size += bytes.length;
|
|
76
|
+
let from = 0;
|
|
77
|
+
if (held > 0) {
|
|
78
|
+
const taken = Math.min(BLOCK - held, bytes.length);
|
|
79
|
+
pending.set(bytes.subarray(0, taken), held);
|
|
80
|
+
held += taken;
|
|
81
|
+
from = taken;
|
|
82
|
+
if (held < BLOCK)
|
|
83
|
+
return;
|
|
84
|
+
compressed(state, words, pending, 0);
|
|
85
|
+
held = 0;
|
|
86
|
+
}
|
|
87
|
+
for (; from + BLOCK <= bytes.length; from += BLOCK)
|
|
88
|
+
compressed(state, words, bytes, from);
|
|
89
|
+
pending.set(bytes.subarray(from), 0);
|
|
90
|
+
held = bytes.length - from;
|
|
91
|
+
},
|
|
92
|
+
hex() {
|
|
93
|
+
const bits = size * 8;
|
|
94
|
+
const tail = new Uint8Array(held < 56 ? BLOCK : BLOCK * 2);
|
|
95
|
+
tail.set(pending.subarray(0, held));
|
|
96
|
+
tail[held] = 0x80;
|
|
97
|
+
const length = new DataView(tail.buffer, tail.length - 8);
|
|
98
|
+
length.setUint32(0, Math.floor(bits / 0x1_0000_0000));
|
|
99
|
+
length.setUint32(4, bits >>> 0);
|
|
100
|
+
const final = new Uint32Array(state);
|
|
101
|
+
for (let from = 0; from < tail.length; from += BLOCK)
|
|
102
|
+
compressed(final, words, tail, from);
|
|
103
|
+
return [...final].map((word) => word.toString(16).padStart(8, '0')).join('');
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export async function sha256(blob) {
|
|
108
|
+
const hashed = digest();
|
|
109
|
+
for (let at = 0; at < blob.size; at += FILE_PART_BYTES) {
|
|
110
|
+
hashed.update(new Uint8Array(await blob.slice(at, at + FILE_PART_BYTES).arrayBuffer()));
|
|
111
|
+
}
|
|
112
|
+
return hashed.hex();
|
|
113
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Discovery, DiscoveredRoom, Member } from './adapter.js';
|
|
2
|
+
import type { Runtime } from './runtime.js';
|
|
3
|
+
import type { Live } from './socket.js';
|
|
4
|
+
import type { CycleProgress } from './status.js';
|
|
5
|
+
import type { RuntimeStore } from './store.js';
|
|
6
|
+
export declare function malformed(listed: readonly DiscoveredRoom[]): string | null;
|
|
7
|
+
export declare function applyDiscovery(runtime: Runtime, found: readonly DiscoveredRoom[], started: number, left?: readonly string[]): Promise<readonly DiscoveredRoom[]>;
|
|
8
|
+
export declare const DISCOVERY = "discovery";
|
|
9
|
+
export declare function signIn(runtime: Runtime, local: RuntimeStore, signedIn: Member | null): Promise<void>;
|
|
10
|
+
export declare function zoned(runtime: Runtime, local: RuntimeStore, zone: string | null): Promise<void>;
|
|
11
|
+
export declare function discoverRooms(runtime: Runtime, progress: CycleProgress, live: Live, found: Discovery | null): Promise<readonly DiscoveredRoom[] | null>;
|
|
12
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EACT,cAAc,EACd,MAAM,EAEP,MAAM,cAAc,CAAC;AAOtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAkB/C,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,GAAG,IAAI,CAsB1E;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GACvB,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAgDpC;AAUD,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC,wBAAsB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,iBAI1F;AAED,wBAAsB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,iBAIrF;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,OAAO,CAAC,SAAS,cAAc,EAAE,GAAG,IAAI,CAAC,CA2E3C"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { validRoot } from './collection.js';
|
|
2
|
+
import { lockedRooms, relocked } from './locks.js';
|
|
3
|
+
import { loseRooms } from './lost.js';
|
|
4
|
+
import { cachedModels } from './models.js';
|
|
5
|
+
import { beneath } from './paths.js';
|
|
6
|
+
import { refuse } from './refusal.js';
|
|
7
|
+
import { emitMember, emitRefusal, emitRooms, emitTimeZone, moveTo, transferring } from './shown.js';
|
|
8
|
+
function within(root, path) {
|
|
9
|
+
return root === '' || beneath(root, path);
|
|
10
|
+
}
|
|
11
|
+
function declaredSelection(room) {
|
|
12
|
+
const selection = room.typedSelection;
|
|
13
|
+
if (selection === null)
|
|
14
|
+
return true;
|
|
15
|
+
if (!Array.isArray(selection.roots) || selection.roots.length === 0)
|
|
16
|
+
return false;
|
|
17
|
+
return selection.roots.every((root, index) => validRoot(root) &&
|
|
18
|
+
root !== '' &&
|
|
19
|
+
selection.roots.every((other, at) => at === index || !within(other, root)));
|
|
20
|
+
}
|
|
21
|
+
export function malformed(listed) {
|
|
22
|
+
for (const room of listed) {
|
|
23
|
+
if (room.operations === undefined ||
|
|
24
|
+
!['write', 'erase'].every((operation) => Array.isArray(room.operations[operation]) &&
|
|
25
|
+
room.operations[operation].every((scope) => typeof scope === 'string')) ||
|
|
26
|
+
room.replica === undefined ||
|
|
27
|
+
typeof room.replica.selection !== 'string' ||
|
|
28
|
+
room.replica.selection.length === 0 ||
|
|
29
|
+
!['admitted', 'unavailable'].includes(room.replica.admission) ||
|
|
30
|
+
!['locked', 'open'].includes(room.replica.offline)) {
|
|
31
|
+
return `invalid model or replica declaration ${room.locator}`;
|
|
32
|
+
}
|
|
33
|
+
if (!declaredSelection(room))
|
|
34
|
+
return `invalid typed selection declaration ${room.locator}`;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
export async function applyDiscovery(runtime, found, started, left) {
|
|
39
|
+
const { store, socket, presence } = runtime;
|
|
40
|
+
if (found.length === 0 && !store.needed()) {
|
|
41
|
+
const listed = presence.list([], { whole: left === undefined, live: socket.isOpen() });
|
|
42
|
+
socket.session.set({ roomsListed: true });
|
|
43
|
+
emitRooms(runtime);
|
|
44
|
+
return listed;
|
|
45
|
+
}
|
|
46
|
+
const lockedBefore = await lockedRooms(runtime);
|
|
47
|
+
const local = await store.open();
|
|
48
|
+
const fenced = new Set(await local.fences());
|
|
49
|
+
const relisting = found
|
|
50
|
+
.map(({ locator }) => locator)
|
|
51
|
+
.filter((locator) => fenced.has(locator) && presence.liftable(locator, started));
|
|
52
|
+
const unfenced = relisting.length === 0
|
|
53
|
+
? new Set()
|
|
54
|
+
: await store.durably((held) => held.unfence(relisting));
|
|
55
|
+
const clear = found.filter(({ locator }) => !fenced.has(locator) || unfenced.has(locator));
|
|
56
|
+
for (const { locator } of clear)
|
|
57
|
+
presence.lift(locator, started, unfenced.has(locator));
|
|
58
|
+
const kept = await local.held();
|
|
59
|
+
await loseRooms(runtime, found
|
|
60
|
+
.filter((room) => room.replica.admission !== 'admitted' &&
|
|
61
|
+
(kept.held.has(room.locator) || store.installs.of(room.locator).transfer !== null))
|
|
62
|
+
.map((room) => room.locator));
|
|
63
|
+
const named = new Set(found.map((room) => room.locator));
|
|
64
|
+
await loseRooms(runtime, left ??
|
|
65
|
+
[
|
|
66
|
+
...new Set([
|
|
67
|
+
...presence.rooms().map(({ locator }) => locator),
|
|
68
|
+
...kept.held,
|
|
69
|
+
...store.installs.transferring(),
|
|
70
|
+
]),
|
|
71
|
+
].filter((locator) => !named.has(locator)));
|
|
72
|
+
const listed = presence.list(clear, { whole: left === undefined, live: socket.isOpen() });
|
|
73
|
+
socket.session.set({ roomsListed: true });
|
|
74
|
+
emitRooms(runtime);
|
|
75
|
+
await relocked(runtime, lockedBefore);
|
|
76
|
+
return listed;
|
|
77
|
+
}
|
|
78
|
+
async function asked({ socket }, authorized) {
|
|
79
|
+
try {
|
|
80
|
+
return (await socket.discover(authorized)) ?? { kind: 'transport-uncertainty' };
|
|
81
|
+
}
|
|
82
|
+
catch (failure) {
|
|
83
|
+
return { kind: 'transport-uncertainty', failure };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export const DISCOVERY = 'discovery';
|
|
87
|
+
export async function signIn(runtime, local, signedIn) {
|
|
88
|
+
if (JSON.stringify(signedIn) === JSON.stringify((await local.facts()).member))
|
|
89
|
+
return;
|
|
90
|
+
await local.fact('member', signedIn);
|
|
91
|
+
emitMember(runtime, signedIn);
|
|
92
|
+
}
|
|
93
|
+
export async function zoned(runtime, local, zone) {
|
|
94
|
+
if (zone === (await local.facts()).timeZone)
|
|
95
|
+
return;
|
|
96
|
+
await local.fact('timeZone', zone);
|
|
97
|
+
emitTimeZone(runtime, zone);
|
|
98
|
+
}
|
|
99
|
+
export async function discoverRooms(runtime, progress, live, found) {
|
|
100
|
+
const { store, socket } = runtime;
|
|
101
|
+
const { session } = socket;
|
|
102
|
+
const { closed, authorization } = session.now();
|
|
103
|
+
if (closed || authorization === undefined) {
|
|
104
|
+
socket.notifyReady();
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
moveTo(runtime, transferring(runtime));
|
|
108
|
+
const started = session.now().discoveries + 1;
|
|
109
|
+
session.set({ discoveries: started });
|
|
110
|
+
const result = found ?? (await asked(runtime, authorization));
|
|
111
|
+
if (result.kind === 'discovery')
|
|
112
|
+
session.set({ roomsNamed: true });
|
|
113
|
+
if (!live()) {
|
|
114
|
+
progress.complete = false;
|
|
115
|
+
socket.notifyReady();
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
if (result.kind === 'transport-uncertainty')
|
|
119
|
+
runtime.retries.uncertain('connection', DISCOVERY, result);
|
|
120
|
+
if (result.kind === 'discovery')
|
|
121
|
+
runtime.retries.succeeded('connection', DISCOVERY);
|
|
122
|
+
if (result.kind === 'transport-uncertainty') {
|
|
123
|
+
if (store.needed())
|
|
124
|
+
await cachedModels(runtime, await store.open());
|
|
125
|
+
progress.reachable = false;
|
|
126
|
+
progress.complete = false;
|
|
127
|
+
socket.notifyReady();
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
if (result.kind === 'contract-unavailable') {
|
|
131
|
+
await refuse(runtime, 'missing-required-guarantee', {
|
|
132
|
+
code: result.code,
|
|
133
|
+
fields: result.fields,
|
|
134
|
+
retryable: result.retryable,
|
|
135
|
+
});
|
|
136
|
+
socket.notifyReady();
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
if (result.kind === 'revoked-authorization') {
|
|
140
|
+
await refuse(runtime, 'revoked-authorization');
|
|
141
|
+
socket.notifyReady();
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const invalid = malformed(result.rooms);
|
|
145
|
+
if (invalid !== null) {
|
|
146
|
+
await refuse(runtime, 'missing-required-guarantee');
|
|
147
|
+
socket.notifyReady();
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
if (session.now().refusal !== null) {
|
|
151
|
+
session.set({ refusal: null });
|
|
152
|
+
emitRefusal(runtime);
|
|
153
|
+
}
|
|
154
|
+
const queriesOnly = result.queriesOnly ?? [];
|
|
155
|
+
if (!store.needed() && result.rooms.length === 0) {
|
|
156
|
+
session.set({ queriesOnly, unstored: result });
|
|
157
|
+
socket.notifyReady();
|
|
158
|
+
return applyDiscovery(runtime, result.rooms, started);
|
|
159
|
+
}
|
|
160
|
+
const local = await store.open();
|
|
161
|
+
const held = await local.facts();
|
|
162
|
+
if (JSON.stringify(result.providerLimits) !== JSON.stringify(held.providerLimits) ||
|
|
163
|
+
JSON.stringify(result.capabilities) !== JSON.stringify(held.capabilities)) {
|
|
164
|
+
await local.fact('providerLimits', result.providerLimits);
|
|
165
|
+
await local.fact('capabilities', result.capabilities);
|
|
166
|
+
}
|
|
167
|
+
if (JSON.stringify(queriesOnly) !== JSON.stringify(held.queriesOnly)) {
|
|
168
|
+
await local.fact('queriesOnly', queriesOnly);
|
|
169
|
+
}
|
|
170
|
+
session.set({ queriesOnly, unstored: null });
|
|
171
|
+
socket.notifyReady();
|
|
172
|
+
await signIn(runtime, local, result.member ?? null);
|
|
173
|
+
await zoned(runtime, local, result.timeZone ?? null);
|
|
174
|
+
return applyDiscovery(runtime, result.rooms, started);
|
|
175
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MdRuntimeClient } from './client.js';
|
|
2
|
+
import type { AttachmentLinkAnswer, DownloadAnswer } from './outcome.js';
|
|
3
|
+
export declare function handedCopy(copy: Blob, name: string): DownloadAnswer;
|
|
4
|
+
export declare function handedLink(path: string, link: () => Promise<AttachmentLinkAnswer>): Promise<DownloadAnswer>;
|
|
5
|
+
export declare function downloadAttachment(client: MdRuntimeClient, link: string): Promise<DownloadAnswer>;
|
|
6
|
+
//# sourceMappingURL=download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAuBzE,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAKnE;AAED,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAAC,cAAc,CAAC,CAazB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAEjG"}
|
package/dist/download.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { roomTarget } from '@agentshouse/mdmodel';
|
|
2
|
+
// A browser reads a download's address only after the click that hands it returns, so a copy's address is released a minute later.
|
|
3
|
+
const HANDED_COPY_MS = 60_000;
|
|
4
|
+
const PAGE = /\.html?$/iu;
|
|
5
|
+
const STARTED = { kind: 'started' };
|
|
6
|
+
const BLOCKED = {
|
|
7
|
+
kind: 'blocked',
|
|
8
|
+
code: 'popup-blocked',
|
|
9
|
+
fields: {},
|
|
10
|
+
retryable: true,
|
|
11
|
+
};
|
|
12
|
+
function handed(url, name) {
|
|
13
|
+
const anchor = document.createElement('a');
|
|
14
|
+
anchor.href = url;
|
|
15
|
+
anchor.download = name;
|
|
16
|
+
anchor.click();
|
|
17
|
+
}
|
|
18
|
+
export function handedCopy(copy, name) {
|
|
19
|
+
const url = URL.createObjectURL(copy);
|
|
20
|
+
handed(url, name);
|
|
21
|
+
setTimeout(() => URL.revokeObjectURL(url), HANDED_COPY_MS);
|
|
22
|
+
return STARTED;
|
|
23
|
+
}
|
|
24
|
+
export async function handedLink(path, link) {
|
|
25
|
+
const tab = PAGE.test(path) ? globalThis.open('', '_blank') : null;
|
|
26
|
+
const linked = await link();
|
|
27
|
+
if (linked.kind === 'link' && PAGE.test(linked.name)) {
|
|
28
|
+
const away = tab ?? globalThis.open('', '_blank');
|
|
29
|
+
if (away === null)
|
|
30
|
+
return BLOCKED;
|
|
31
|
+
away.location.replace(linked.url);
|
|
32
|
+
return STARTED;
|
|
33
|
+
}
|
|
34
|
+
tab?.close();
|
|
35
|
+
if (linked.kind !== 'link')
|
|
36
|
+
return linked;
|
|
37
|
+
handed(linked.url, linked.name);
|
|
38
|
+
return STARTED;
|
|
39
|
+
}
|
|
40
|
+
export function downloadAttachment(client, link) {
|
|
41
|
+
return handedLink(roomTarget(link)?.path ?? link, () => client.conversation.attachment(link));
|
|
42
|
+
}
|
package/dist/durability.d.ts
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import type { Persistence } from './readiness.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { RetriedFailure, Step } from './retried.js';
|
|
3
|
+
export type UnsentKind = 'pending-change' | 'call' | 'room-draft' | 'chat-draft';
|
|
4
|
+
export type UnsentWork = {
|
|
5
|
+
readonly kind: UnsentKind;
|
|
6
|
+
readonly count: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function leftToSend(unsent: readonly UnsentWork[]): boolean;
|
|
9
|
+
export type AppCode = {
|
|
10
|
+
readonly running: number;
|
|
11
|
+
readonly older: number;
|
|
12
|
+
};
|
|
13
|
+
export type HeldCode = {
|
|
14
|
+
readonly house: number | null;
|
|
15
|
+
readonly apps: readonly string[];
|
|
5
16
|
};
|
|
6
17
|
export type RuntimeShell = {
|
|
7
18
|
persistence: Persistence;
|
|
8
19
|
generation: string | null;
|
|
9
20
|
keepGeneration(value: string): void | Promise<void>;
|
|
10
21
|
dropGeneration(): void | Promise<void>;
|
|
11
|
-
|
|
22
|
+
cleanUp?(): Promise<number>;
|
|
23
|
+
measure?(measured: (app: string, code: AppCode | null) => void): Promise<HeldCode>;
|
|
24
|
+
reset(): Promise<void>;
|
|
25
|
+
retried?(failure: RetriedFailure): void;
|
|
26
|
+
succeeded?(step: Step): void;
|
|
12
27
|
};
|
|
28
|
+
export declare function refusedForSpace(error: unknown): boolean;
|
|
13
29
|
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
|
30
|
+
export declare function lossStated(persistence: Persistence, loss: string | null): string | null;
|
|
14
31
|
export declare function nextGeneration(stored: string | null, reported: string | null): string;
|
|
15
32
|
//# sourceMappingURL=durability.d.ts.map
|
package/dist/durability.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMzD,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,MAAM,GAAG,YAAY,GAAG,YAAY,CAAC;AAEjF,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,GAAG,OAAO,CAEjE;AAED,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3F,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,cAAc,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IACxC,SAAS,CAAC,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAG/F;AAED,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAEvF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGrF"}
|
package/dist/durability.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
const STORAGE_LOSS_CODE = 'storage-loss';
|
|
2
|
+
const VISIT_LOSS_CODE = 'visit';
|
|
3
|
+
export function leftToSend(unsent) {
|
|
4
|
+
return unsent.some(({ kind }) => kind === 'pending-change' || kind === 'call');
|
|
5
|
+
}
|
|
6
|
+
export function refusedForSpace(error) {
|
|
7
|
+
return (typeof error === 'object' &&
|
|
8
|
+
error !== null &&
|
|
9
|
+
error.name === 'QuotaExceededError');
|
|
10
|
+
}
|
|
2
11
|
export function detectStorageLoss(stored, reported) {
|
|
3
12
|
if (reported === null || reported === stored)
|
|
4
13
|
return null;
|
|
5
14
|
return STORAGE_LOSS_CODE;
|
|
6
15
|
}
|
|
16
|
+
export function lossStated(persistence, loss) {
|
|
17
|
+
return persistence === 'memory' ? VISIT_LOSS_CODE : loss;
|
|
18
|
+
}
|
|
7
19
|
export function nextGeneration(stored, reported) {
|
|
8
20
|
if (stored !== null && (reported === null || reported === stored))
|
|
9
21
|
return stored;
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
|
+
import { type VerifiedModel } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { Attachment, HeadChange } from './adapter.js';
|
|
3
|
+
import type { ChangeBatch } from './change.js';
|
|
4
|
+
import { type Written } from './overlay.js';
|
|
1
5
|
import { type QueryRows } from './query.js';
|
|
2
|
-
|
|
6
|
+
import { type ValuedEntry } from './stored.js';
|
|
7
|
+
import type { Connection } from './tables.js';
|
|
8
|
+
export { QueryError } from '@agentshouse/mdmodel';
|
|
9
|
+
export { documentKey, pathOfKey } from './rows.js';
|
|
10
|
+
export type { ValuedEntry } from './stored.js';
|
|
11
|
+
export type EntryArea = {
|
|
12
|
+
readonly path: string;
|
|
13
|
+
readonly open: readonly string[];
|
|
14
|
+
};
|
|
3
15
|
export type EntryRoom = {
|
|
4
16
|
locator: string;
|
|
17
|
+
handle?: string;
|
|
18
|
+
readable?: readonly string[];
|
|
19
|
+
areas?: readonly EntryArea[];
|
|
5
20
|
schema: string | null;
|
|
6
21
|
documents: Readonly<Record<string, string>>;
|
|
22
|
+
revisions?: Readonly<Record<string, string>>;
|
|
23
|
+
fileIds?: Readonly<Record<string, string>>;
|
|
24
|
+
created?: Readonly<Record<string, string>>;
|
|
25
|
+
changes?: Readonly<Record<string, HeadChange>>;
|
|
26
|
+
attachments?: Readonly<Record<string, Attachment>>;
|
|
7
27
|
};
|
|
8
28
|
export type EntryArguments = Readonly<Record<string, string>>;
|
|
9
29
|
export type EntryParameterKind = 'string' | 'integer' | 'number' | 'boolean';
|
|
@@ -13,5 +33,12 @@ export declare function entryRefusal(template: unknown): string | null;
|
|
|
13
33
|
export type EntryScope = {
|
|
14
34
|
results(queries: Readonly<Record<string, unknown>>): Promise<Record<string, QueryRows>>;
|
|
15
35
|
};
|
|
16
|
-
export
|
|
36
|
+
export type CountedRoom = {
|
|
37
|
+
locator: string;
|
|
38
|
+
schema: string | null;
|
|
39
|
+
documents: readonly ValuedEntry[];
|
|
40
|
+
};
|
|
41
|
+
export declare function writtenIn(room: EntryRoom, roomTypes: VerifiedModel, batch: ChangeBatch): Written;
|
|
42
|
+
export declare function entryScope(rooms: readonly EntryRoom[], roomTypes: VerifiedModel, connection: Connection, followed?: readonly EntryRoom[]): EntryScope;
|
|
43
|
+
export declare function countScope(room: CountedRoom, roomTypes: VerifiedModel, connection: Connection): EntryScope;
|
|
17
44
|
//# sourceMappingURL=entry.d.ts.map
|
package/dist/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"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"}
|