@agentshouse/mdruntime 0.1.0-c0bed82db8d73 → 0.1.0-c0c0511ef12ee
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 +3 -2
- package/dist/acceptance.d.ts +6 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +385 -0
- package/dist/actions.d.ts +20 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +251 -0
- package/dist/adapter.d.ts +107 -71
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +4 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +35 -46
- package/dist/bootstrap.d.ts +16 -15
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +274 -131
- 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 +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/change.d.ts +1 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- package/dist/chat-types.d.ts +5 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +13 -0
- package/dist/client.d.ts +25 -10
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +56 -7
- package/dist/collection.d.ts +7 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +24 -19
- package/dist/compile.d.ts +6 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +287 -297
- package/dist/connection.d.ts +6 -141
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +103 -5016
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation-live.d.ts +136 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +248 -0
- package/dist/conversation-row.d.ts +33 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +53 -0
- package/dist/conversation.d.ts +41 -45
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +870 -786
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +175 -0
- package/dist/durability.d.ts +15 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +3 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +18 -8
- package/dist/figures.d.ts +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +197 -0
- package/dist/file.d.ts +2 -11
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +6 -4
- 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 +4 -7
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +33 -33
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +27 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/install.d.ts +56 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +554 -0
- package/dist/job.d.ts +33 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +54 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +268 -0
- package/dist/listing.d.ts +53 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +176 -0
- package/dist/live.d.ts +5 -4
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +61 -21
- package/dist/locks.d.ts +9 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +61 -0
- package/dist/log.d.ts +1 -0
- package/dist/log.d.ts.map +1 -1
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +61 -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 +13 -6
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +219 -91
- package/dist/messages.d.ts +27 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +103 -31
- package/dist/model.d.ts +8 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -18
- package/dist/models.d.ts +14 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +195 -0
- package/dist/observation.d.ts +3 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +15 -15
- package/dist/opened.js +3 -3
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +57 -0
- package/dist/outcome.d.ts +17 -6
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +19 -2
- package/dist/overlay.d.ts +1 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +11 -0
- package/dist/parts.d.ts +60 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +126 -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 +20 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +226 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +272 -0
- package/dist/query.d.ts +18 -208
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/questions.d.ts +34 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +122 -0
- package/dist/reach.d.ts +20 -11
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +206 -126
- package/dist/react.d.ts +10 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/read.d.ts +7 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +17 -0
- package/dist/readiness.d.ts +3 -18
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +4 -10
- package/dist/reads.d.ts +36 -10
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +157 -86
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +35 -1
- package/dist/refresh.d.ts +7 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +34 -10
- 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 +11 -12
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +56 -23
- package/dist/room-draft.d.ts +21 -7
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +101 -54
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +217 -0
- package/dist/rows.d.ts +18 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +45 -153
- package/dist/runtime.d.ts +43 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +7 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +31 -24
- package/dist/saves.d.ts +70 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +1005 -0
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -1
- package/dist/shared.d.ts +1 -7
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -105
- package/dist/shown.d.ts +31 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +292 -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 +20 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +77 -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/rooms.d.ts +44 -0
- package/dist/socket/rooms.d.ts.map +1 -0
- package/dist/socket/rooms.js +90 -0
- package/dist/socket/session.d.ts +38 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +23 -0
- package/dist/socket.d.ts +70 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +175 -0
- package/dist/source.d.ts +61 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +82 -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/fences.d.ts +16 -0
- package/dist/store/fences.d.ts.map +1 -0
- package/dist/store/fences.js +26 -0
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +34 -0
- package/dist/store/readiness.d.ts +10 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +52 -0
- package/dist/store/records.d.ts +212 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +431 -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/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 +105 -158
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +143 -401
- package/dist/stored.d.ts +66 -55
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +355 -273
- package/dist/surface.d.ts +88 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +223 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +532 -0
- package/dist/tables.d.ts +131 -69
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +221 -105
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +129 -0
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/validation.d.ts +3 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +42 -100
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +25 -9
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +9 -2
- package/package.json +2 -3
- package/AGENTS.md +0 -312
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -368
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -150
package/dist/opening.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { conversationsOpened } from './conversation.js';
|
|
2
|
+
import { detectStorageLoss, nextGeneration, refusedForSpace } from './durability.js';
|
|
3
|
+
import { sweep } from './install.js';
|
|
4
|
+
import { eraseFenced } from './lost.js';
|
|
5
|
+
import { prepare } from './preparation.js';
|
|
6
|
+
import { emitRooms, emitStorageLoss, statusShown } from './shown.js';
|
|
7
|
+
export async function open(runtime, opened) {
|
|
8
|
+
const { store, socket, journal, shell, conversations, build, usableWhenHeld } = runtime;
|
|
9
|
+
if (socket.closed())
|
|
10
|
+
throw new Error('runtime closed');
|
|
11
|
+
const interrupted = await opened.fences();
|
|
12
|
+
const kept = shell.generation;
|
|
13
|
+
const storedGeneration = await opened.generation();
|
|
14
|
+
const loss = detectStorageLoss(storedGeneration, kept);
|
|
15
|
+
const generation = nextGeneration(storedGeneration, kept);
|
|
16
|
+
if (generation !== storedGeneration)
|
|
17
|
+
await opened.rememberGeneration(generation);
|
|
18
|
+
if (generation !== kept)
|
|
19
|
+
await shell.keepGeneration(generation);
|
|
20
|
+
if (loss !== null) {
|
|
21
|
+
store.device.set({ storageLoss: loss });
|
|
22
|
+
emitStorageLoss(runtime);
|
|
23
|
+
}
|
|
24
|
+
const held = await opened.opened();
|
|
25
|
+
store.device.set({
|
|
26
|
+
heldWhenOpened: usableWhenHeld.length > 0 && (await opened.covering()).rooms.size > 0,
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
await opened.demote();
|
|
30
|
+
await store.ask({ kind: 'read.builds', build });
|
|
31
|
+
for (const key of held.orphans)
|
|
32
|
+
await opened.release(key);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (!refusedForSpace(error))
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
if (held.erasing || held.orphans.length > 0)
|
|
39
|
+
queueMicrotask(() => sweep(runtime));
|
|
40
|
+
await conversationsOpened(conversations, opened);
|
|
41
|
+
if (interrupted.length > 0) {
|
|
42
|
+
queueMicrotask(() => {
|
|
43
|
+
void eraseFenced(runtime, interrupted).catch(() => {
|
|
44
|
+
journal.record('erasure failed');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
statusShown(runtime);
|
|
49
|
+
prepare(runtime);
|
|
50
|
+
emitRooms(runtime);
|
|
51
|
+
void store
|
|
52
|
+
.exclusive(() => runtime.unpair(opened))
|
|
53
|
+
.catch(() => {
|
|
54
|
+
journal.record('unpair failed');
|
|
55
|
+
});
|
|
56
|
+
return opened;
|
|
57
|
+
}
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionResult, AdapterFailure, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
1
|
+
import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
3
|
import type { KeptBinary, KeptResult } from './opened.js';
|
|
4
4
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
@@ -13,7 +13,9 @@ export type CallResult = {
|
|
|
13
13
|
kind: 'action';
|
|
14
14
|
result: unknown;
|
|
15
15
|
at?: RoomVersionAt;
|
|
16
|
-
} | Refused<'rejected'>
|
|
16
|
+
} | (Refused<'rejected'> & {
|
|
17
|
+
reset?: string;
|
|
18
|
+
}) | Refused<'undeclared'> | Failure;
|
|
17
19
|
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
18
20
|
kind: Failure['kind'];
|
|
19
21
|
}> | Failure;
|
|
@@ -29,7 +31,17 @@ export type BinaryLinkAnswer = {
|
|
|
29
31
|
kind: 'link';
|
|
30
32
|
url: string;
|
|
31
33
|
name: string;
|
|
34
|
+
mediaType: string;
|
|
32
35
|
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
36
|
+
export type HeldShownAnswer = KeptBinary | BinaryLinkAnswer;
|
|
37
|
+
export type ShownAnswer = BinaryAnswer | BinaryLinkAnswer;
|
|
38
|
+
export type AttachAnswer = {
|
|
39
|
+
kind: 'attached';
|
|
40
|
+
path: string;
|
|
41
|
+
} | Offline | Refused<'rejected'> | Failure;
|
|
42
|
+
export type DownloadAnswer = {
|
|
43
|
+
kind: 'started';
|
|
44
|
+
} | Refused<'rejected'> | Refused<'absent'> | Refused<'blocked'> | Failure;
|
|
33
45
|
export type Resolution = {
|
|
34
46
|
readonly kind: 'document';
|
|
35
47
|
readonly room: string;
|
|
@@ -45,7 +57,8 @@ export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
|
45
57
|
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
46
58
|
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
47
59
|
export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
|
|
48
|
-
export declare function binaryLinkAnswer(result: BinaryLinkResult): BinaryLinkAnswer;
|
|
60
|
+
export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
|
|
61
|
+
export declare function attachAnswer(result: AttachResult): AttachAnswer;
|
|
49
62
|
export declare const ROOM_LOCKED = "room-locked";
|
|
50
63
|
export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
|
|
51
64
|
locator: string;
|
|
@@ -54,6 +67,7 @@ export type Offline = {
|
|
|
54
67
|
readonly kind: 'offline';
|
|
55
68
|
};
|
|
56
69
|
export declare const OFFLINE: Offline;
|
|
70
|
+
export declare function answeredResult(value: unknown): boolean;
|
|
57
71
|
export declare const UNCERTAIN: Failure;
|
|
58
72
|
export declare function undeclared(name: string): CallResult;
|
|
59
73
|
export declare function failure(result: AdapterFailure): Failure;
|
|
@@ -69,9 +83,6 @@ export type QueueEntry = {
|
|
|
69
83
|
readonly batch: ChangeBatch;
|
|
70
84
|
} & (Submission | {
|
|
71
85
|
readonly state: 'local';
|
|
72
|
-
} | {
|
|
73
|
-
readonly state: 'accepted';
|
|
74
|
-
readonly roomVersion: string;
|
|
75
86
|
});
|
|
76
87
|
export {};
|
|
77
88
|
//# sourceMappingURL=outcome.d.ts.map
|
package/dist/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAA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W,gBAAgB,CAAC;AAEzC,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAExF;AAED,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAEnD,eAAO,MAAM,OAAO,EAAE,OAA6B,CAAC;AAEpD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED,eAAO,MAAM,SAAS,EAAE,OAKvB,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAEnD;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAiBvD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAE7D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAIlE;AAED,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,WAAW,CAAA;CAAE,GAC3C;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GAAG,CACvD,UAAU,GACV;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAC9B,CAAC"}
|
package/dist/outcome.js
CHANGED
|
@@ -22,14 +22,31 @@ export function absentBinary(path) {
|
|
|
22
22
|
export function binaryAnswer(result) {
|
|
23
23
|
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const OCTET_STREAM = 'application/octet-stream';
|
|
26
|
+
export function binaryLinkAnswer(result, held) {
|
|
27
|
+
if (result.kind === 'link') {
|
|
28
|
+
return {
|
|
29
|
+
kind: 'link',
|
|
30
|
+
url: result.url,
|
|
31
|
+
name: result.name,
|
|
32
|
+
mediaType: result.mediaType ?? held ?? OCTET_STREAM,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return result.kind === 'rejected' ? result : failure(result);
|
|
36
|
+
}
|
|
37
|
+
export function attachAnswer(result) {
|
|
38
|
+
if (result.kind === 'attached')
|
|
39
|
+
return { kind: 'attached', path: result.path };
|
|
40
|
+
return result.kind === 'rejected' ? result : failure(result);
|
|
27
41
|
}
|
|
28
42
|
export const ROOM_LOCKED = 'room-locked';
|
|
29
43
|
export function lockedRoom(locator) {
|
|
30
44
|
return { kind: ROOM_LOCKED, locator, code: ROOM_LOCKED, fields: {}, retryable: true };
|
|
31
45
|
}
|
|
32
46
|
export const OFFLINE = { kind: 'offline' };
|
|
47
|
+
export function answeredResult(value) {
|
|
48
|
+
return typeof value === 'object' && value !== null && !('pending' in value);
|
|
49
|
+
}
|
|
33
50
|
export const UNCERTAIN = {
|
|
34
51
|
kind: 'transport-uncertainty',
|
|
35
52
|
code: 'transport-uncertainty',
|
package/dist/overlay.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ChangeBatch } from './change.js';
|
|
|
3
3
|
export type Heads = {
|
|
4
4
|
revisions: Readonly<Record<string, string>>;
|
|
5
5
|
fileIds: Readonly<Record<string, string>>;
|
|
6
|
+
created: Readonly<Record<string, string>>;
|
|
6
7
|
changes: Readonly<Record<string, HeadChange>>;
|
|
7
8
|
};
|
|
8
9
|
export type HeldBinary = ({
|
package/dist/overlay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EA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,EAAE,UAAU,CAAC,CAAC,GAC1C,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAE1C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAW/F;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAQ/F;AA6MD,wBAAiB,UAAU,CACzB,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,SAAS,CAAC,EAAE,MAAM,IAAI,GACrB,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAsChC"}
|
package/dist/overlay.js
CHANGED
|
@@ -125,16 +125,21 @@ function relocate(staged, from, to) {
|
|
|
125
125
|
function moveHead(heads, from, to) {
|
|
126
126
|
const revision = heads.revisions[from];
|
|
127
127
|
const fileId = heads.fileIds[from];
|
|
128
|
+
const created = heads.created[from];
|
|
128
129
|
const change = heads.changes[from];
|
|
129
130
|
delete heads.revisions[from];
|
|
130
131
|
delete heads.fileIds[from];
|
|
132
|
+
delete heads.created[from];
|
|
131
133
|
delete heads.changes[from];
|
|
132
134
|
delete heads.fileIds[to];
|
|
135
|
+
delete heads.created[to];
|
|
133
136
|
delete heads.changes[to];
|
|
134
137
|
if (revision !== undefined)
|
|
135
138
|
heads.revisions[to] = revision;
|
|
136
139
|
if (fileId !== undefined)
|
|
137
140
|
heads.fileIds[to] = fileId;
|
|
141
|
+
if (created !== undefined)
|
|
142
|
+
heads.created[to] = created;
|
|
138
143
|
if (change !== undefined)
|
|
139
144
|
heads.changes[to] = change;
|
|
140
145
|
}
|
|
@@ -142,6 +147,7 @@ function erase(staged, path) {
|
|
|
142
147
|
delete staged.documents[path];
|
|
143
148
|
delete staged.revisions[path];
|
|
144
149
|
delete staged.fileIds[path];
|
|
150
|
+
delete staged.created[path];
|
|
145
151
|
delete staged.changes[path];
|
|
146
152
|
delete staged.binaries[path];
|
|
147
153
|
}
|
|
@@ -150,6 +156,7 @@ function stage(staged, change) {
|
|
|
150
156
|
staged.documents[change.path] =
|
|
151
157
|
'content' in change ? change.content : compose(change.fields, change.sections);
|
|
152
158
|
delete staged.fileIds[change.path];
|
|
159
|
+
delete staged.created[change.path];
|
|
153
160
|
delete staged.changes[change.path];
|
|
154
161
|
return true;
|
|
155
162
|
}
|
|
@@ -194,6 +201,8 @@ function arrive(heads, change) {
|
|
|
194
201
|
heads.revisions[change.path] = change.revision;
|
|
195
202
|
if (change.fileId !== undefined)
|
|
196
203
|
heads.fileIds[change.path] = change.fileId;
|
|
204
|
+
if (change.created !== undefined)
|
|
205
|
+
heads.created[change.path] = change.created;
|
|
197
206
|
if (change.change !== undefined)
|
|
198
207
|
heads.changes[change.path] = change.change;
|
|
199
208
|
}
|
|
@@ -203,6 +212,7 @@ export function* overlaying(base, queue, unapplied) {
|
|
|
203
212
|
binaries: drafted(base.binaries),
|
|
204
213
|
revisions: drafted(base.revisions),
|
|
205
214
|
fileIds: drafted(base.fileIds),
|
|
215
|
+
created: drafted(base.created),
|
|
206
216
|
changes: drafted(base.changes),
|
|
207
217
|
};
|
|
208
218
|
for (const batch of queue) {
|
|
@@ -234,6 +244,7 @@ export function* overlaying(base, queue, unapplied) {
|
|
|
234
244
|
binaries: yield* settling(staged.binaries),
|
|
235
245
|
revisions: yield* settling(staged.revisions),
|
|
236
246
|
fileIds: yield* settling(staged.fileIds),
|
|
247
|
+
created: yield* settling(staged.created),
|
|
237
248
|
changes: yield* settling(staged.changes),
|
|
238
249
|
};
|
|
239
250
|
}
|
package/dist/parts.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { RunningSubagent, TurnContext } from './adapter.js';
|
|
2
|
+
import { type JobMarker, type OpenJob } from './job.js';
|
|
3
|
+
export type PlanStep = {
|
|
4
|
+
readonly content: string;
|
|
5
|
+
readonly status: string;
|
|
6
|
+
};
|
|
7
|
+
export type Marker = 'mode' | 'compaction' | 'retry' | 'model' | 'job';
|
|
8
|
+
export type Part = {
|
|
9
|
+
readonly type: 'text';
|
|
10
|
+
readonly text: string;
|
|
11
|
+
} | {
|
|
12
|
+
readonly type: 'reasoning';
|
|
13
|
+
readonly text: string;
|
|
14
|
+
} | {
|
|
15
|
+
readonly type: 'commands';
|
|
16
|
+
readonly count: number;
|
|
17
|
+
} | {
|
|
18
|
+
readonly type: 'subagent';
|
|
19
|
+
readonly description: string;
|
|
20
|
+
readonly done: boolean;
|
|
21
|
+
readonly result: string | null;
|
|
22
|
+
} | {
|
|
23
|
+
readonly type: 'message';
|
|
24
|
+
readonly command: string;
|
|
25
|
+
readonly target: string | null;
|
|
26
|
+
} | {
|
|
27
|
+
readonly type: 'image';
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly mediaType: string;
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: 'marker';
|
|
33
|
+
readonly marker: Marker;
|
|
34
|
+
readonly text: string;
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: 'plan';
|
|
37
|
+
readonly steps: readonly PlanStep[];
|
|
38
|
+
};
|
|
39
|
+
export declare function partsOf(raw: readonly unknown[]): readonly Part[];
|
|
40
|
+
export declare function contextIn(raw: unknown): TurnContext | null;
|
|
41
|
+
export declare function tokensIn(raw: unknown): number | null;
|
|
42
|
+
export type Turn = {
|
|
43
|
+
readonly turn: string;
|
|
44
|
+
readonly parts: readonly Part[];
|
|
45
|
+
readonly ended: boolean;
|
|
46
|
+
};
|
|
47
|
+
export type ChatWork = {
|
|
48
|
+
readonly kind: 'job' | 'schedule' | 'subagent';
|
|
49
|
+
readonly title: string;
|
|
50
|
+
readonly next: string | null;
|
|
51
|
+
readonly activity: string | null;
|
|
52
|
+
};
|
|
53
|
+
export declare function counted(count: number): string;
|
|
54
|
+
export declare function runningLine(raw: readonly unknown[]): string | null;
|
|
55
|
+
export declare function jobsOf(markers: readonly JobMarker[], turn: {
|
|
56
|
+
readonly started: string | null;
|
|
57
|
+
readonly parts: readonly unknown[];
|
|
58
|
+
} | null): readonly OpenJob[];
|
|
59
|
+
export declare function stillRunning(turns: readonly Turn[], subagents: readonly RunningSubagent[]): ReadonlyMap<string, readonly ChatWork[]>;
|
|
60
|
+
//# sourceMappingURL=parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../src/parts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAoC,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,UAAU,CAAC;AAG1F,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAEvE,MAAM,MAAM,IAAI,GACZ;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,C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IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,GAAG,IAAI,CASlE;AAED,wBAAgB,MAAM,CACpB,OAAO,EAAE,SAAS,SAAS,EAAE,EAC7B,IAAI,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,CAAA;CAAE,GAAG,IAAI,GACnF,SAAS,OAAO,EAAE,CAOpB;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,SAAS,EAAE,SAAS,eAAe,EAAE,GACpC,WAAW,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC,CA0C1C"}
|
package/dist/parts.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { closeLast, markerMoved, openJobs } from './job.js';
|
|
2
|
+
import { excerpt, list, record, text } from './read.js';
|
|
3
|
+
const MARKERS = ['mode', 'compaction', 'retry', 'model', 'job'];
|
|
4
|
+
function partOf(raw) {
|
|
5
|
+
const part = record(raw);
|
|
6
|
+
switch (text(part, 'type')) {
|
|
7
|
+
case 'text':
|
|
8
|
+
case 'reasoning': {
|
|
9
|
+
const said = text(part, 'text');
|
|
10
|
+
return said === null ? null : { type: part.type, text: said };
|
|
11
|
+
}
|
|
12
|
+
case 'commands':
|
|
13
|
+
return typeof part.count === 'number' ? { type: 'commands', count: part.count } : null;
|
|
14
|
+
case 'subagent':
|
|
15
|
+
return {
|
|
16
|
+
type: 'subagent',
|
|
17
|
+
description: text(part, 'description') ?? '',
|
|
18
|
+
done: part.status === 'done',
|
|
19
|
+
result: text(part, 'result'),
|
|
20
|
+
};
|
|
21
|
+
case 'message': {
|
|
22
|
+
const command = text(part, 'command');
|
|
23
|
+
return command === null ? null : { type: 'message', command, target: text(part, 'target') };
|
|
24
|
+
}
|
|
25
|
+
case 'image': {
|
|
26
|
+
const path = text(part, 'file');
|
|
27
|
+
const name = text(part, 'name');
|
|
28
|
+
return path === null || name === null
|
|
29
|
+
? null
|
|
30
|
+
: { type: 'image', path, name, mediaType: text(part, 'media_type') ?? '' };
|
|
31
|
+
}
|
|
32
|
+
case 'marker': {
|
|
33
|
+
const marker = text(part, 'marker');
|
|
34
|
+
return marker === null || !MARKERS.includes(marker)
|
|
35
|
+
? null
|
|
36
|
+
: { type: 'marker', marker: marker, text: text(part, 'text') ?? '' };
|
|
37
|
+
}
|
|
38
|
+
case 'plan':
|
|
39
|
+
return {
|
|
40
|
+
type: 'plan',
|
|
41
|
+
steps: list(part, 'entries').flatMap((entry) => {
|
|
42
|
+
const step = record(entry);
|
|
43
|
+
const content = text(step, 'content');
|
|
44
|
+
return content === null ? [] : [{ content, status: text(step, 'status') ?? '' }];
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
default:
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function partsOf(raw) {
|
|
52
|
+
return raw.flatMap((one) => partOf(one) ?? []);
|
|
53
|
+
}
|
|
54
|
+
export function contextIn(raw) {
|
|
55
|
+
const held = record(raw);
|
|
56
|
+
return typeof held.used === 'number' && typeof held.window === 'number' && held.window > 0
|
|
57
|
+
? { used: held.used, window: held.window }
|
|
58
|
+
: null;
|
|
59
|
+
}
|
|
60
|
+
const TOKEN_KINDS = ['input', 'output', 'cache_read', 'cache_write'];
|
|
61
|
+
export function tokensIn(raw) {
|
|
62
|
+
const held = record(raw);
|
|
63
|
+
const counts = TOKEN_KINDS.map((kind) => held[kind]);
|
|
64
|
+
return counts.every((count) => typeof count === 'number')
|
|
65
|
+
? counts.reduce((sum, count) => sum + count, 0)
|
|
66
|
+
: null;
|
|
67
|
+
}
|
|
68
|
+
export function counted(count) {
|
|
69
|
+
return count === 1 ? '1 command' : `${count} commands`;
|
|
70
|
+
}
|
|
71
|
+
export function runningLine(raw) {
|
|
72
|
+
const parts = partsOf(raw);
|
|
73
|
+
const note = [...parts].reverse().find((part) => part.type === 'text' && part.text.trim() !== '');
|
|
74
|
+
if (note?.type === 'text')
|
|
75
|
+
return excerpt(note.text);
|
|
76
|
+
const commands = parts.reduce((sum, part) => (part.type === 'commands' ? sum + part.count : sum), 0);
|
|
77
|
+
return commands === 0 ? null : counted(commands);
|
|
78
|
+
}
|
|
79
|
+
export function jobsOf(markers, turn) {
|
|
80
|
+
const running = (turn === null ? [] : partsOf(turn.parts)).flatMap((part) => part.type === 'marker' && part.marker === 'job'
|
|
81
|
+
? [{ said: part.text, at: turn?.started ?? null }]
|
|
82
|
+
: []);
|
|
83
|
+
return openJobs([...markers, ...running]);
|
|
84
|
+
}
|
|
85
|
+
export function stillRunning(turns, subagents) {
|
|
86
|
+
const open = [];
|
|
87
|
+
for (const { turn, parts, ended } of turns) {
|
|
88
|
+
for (const part of parts) {
|
|
89
|
+
if (part.type === 'subagent') {
|
|
90
|
+
const key = `subagent\u0000${part.description}`;
|
|
91
|
+
if (part.done)
|
|
92
|
+
closeLast(open, key);
|
|
93
|
+
else if (ended) {
|
|
94
|
+
open.push({
|
|
95
|
+
turn,
|
|
96
|
+
key,
|
|
97
|
+
work: { kind: 'subagent', title: part.description, next: null, activity: null },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (part.type !== 'marker' || part.marker !== 'job')
|
|
103
|
+
continue;
|
|
104
|
+
markerMoved(open, part.text, (job, key) => ended
|
|
105
|
+
? {
|
|
106
|
+
turn,
|
|
107
|
+
key,
|
|
108
|
+
work: {
|
|
109
|
+
kind: job.kind === 'started' ? 'job' : 'schedule',
|
|
110
|
+
title: job.label,
|
|
111
|
+
next: job.next,
|
|
112
|
+
activity: null,
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
: null);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const doing = [...subagents];
|
|
119
|
+
const under = new Map();
|
|
120
|
+
for (const { turn, work } of open) {
|
|
121
|
+
const at = work.kind === 'subagent' ? doing.findIndex((one) => one.description === work.title) : -1;
|
|
122
|
+
const shown = at === -1 ? work : { ...work, activity: doing.splice(at, 1)[0].activity };
|
|
123
|
+
under.set(turn, [...(under.get(turn) ?? []), shown]);
|
|
124
|
+
}
|
|
125
|
+
return under;
|
|
126
|
+
}
|
package/dist/paths.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare function normalize(path: string): string | null;
|
|
2
2
|
export declare function beneath(prefix: string, path: string): boolean;
|
|
3
3
|
export declare function covered(prefixes: readonly string[], path: string): boolean;
|
|
4
|
+
export declare function authoredAt(patterns: readonly string[], path: string): boolean;
|
|
5
|
+
export declare function ancestors(path: string): readonly string[];
|
|
4
6
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYrD;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAK1E;AAwBD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7E;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAGzD"}
|
package/dist/paths.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDocumentPath } from '@agentshouse/mdmodel';
|
|
1
2
|
export function normalize(path) {
|
|
2
3
|
const parts = [];
|
|
3
4
|
for (const part of path.split('/')) {
|
|
@@ -22,3 +23,28 @@ export function covered(prefixes, path) {
|
|
|
22
23
|
return normalized !== null && (normalized === '' || beneath(normalized, path));
|
|
23
24
|
});
|
|
24
25
|
}
|
|
26
|
+
function named(pattern, name) {
|
|
27
|
+
const star = pattern.indexOf('*');
|
|
28
|
+
if (star === -1)
|
|
29
|
+
return pattern === name;
|
|
30
|
+
const before = pattern.slice(0, star);
|
|
31
|
+
const after = pattern.slice(star + 1);
|
|
32
|
+
return (name.length > before.length + after.length && name.startsWith(before) && name.endsWith(after));
|
|
33
|
+
}
|
|
34
|
+
function matched(pattern, path) {
|
|
35
|
+
if (pattern === '/')
|
|
36
|
+
return isDocumentPath(path);
|
|
37
|
+
const wanted = pattern.split('/');
|
|
38
|
+
const names = path.split('/');
|
|
39
|
+
const open = wanted.at(-1) === '**';
|
|
40
|
+
const fixed = open ? wanted.slice(0, -1) : wanted;
|
|
41
|
+
return ((open ? names.length > fixed.length : names.length === fixed.length) &&
|
|
42
|
+
fixed.every((one, at) => named(one, names[at])));
|
|
43
|
+
}
|
|
44
|
+
export function authoredAt(patterns, path) {
|
|
45
|
+
return patterns.some((pattern) => matched(pattern, path));
|
|
46
|
+
}
|
|
47
|
+
export function ancestors(path) {
|
|
48
|
+
const parts = path.split('/');
|
|
49
|
+
return parts.slice(1).map((_, at) => parts.slice(0, at + 1).join('/'));
|
|
50
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PlanReach } from './query.js';
|
|
2
|
+
import { type PortReach } from './reach.js';
|
|
3
|
+
import { type CodeAvailability, type ConnectionAvailability, type Readiness } from './readiness.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
export type ReadinessPort = {
|
|
6
|
+
readonly target: string;
|
|
7
|
+
readonly code: CodeAvailability;
|
|
8
|
+
};
|
|
9
|
+
export type ReadinessWatch = {
|
|
10
|
+
readonly port: ReadinessPort;
|
|
11
|
+
readonly reach: PortReach | null;
|
|
12
|
+
readonly deliver: (readiness: Readiness) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare function prepare(runtime: Runtime, locators?: readonly string[]): void;
|
|
15
|
+
export declare function roomsOfReach(reach: PlanReach): ReadonlySet<string>;
|
|
16
|
+
export declare function connectionNow(runtime: Runtime): Promise<ConnectionAvailability>;
|
|
17
|
+
export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[]): Promise<void>;
|
|
18
|
+
export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
|
|
19
|
+
export declare function filled(runtime: Runtime): void;
|
|
20
|
+
//# sourceMappingURL=preparation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preparation.d.ts","sourceRoot":"","sources":["../src/preparation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAE3B,KAAK,SAAS,EAEf,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI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