@agentshouse/mdruntime 0.1.0-cf96c797c5fa8 → 0.1.0-cfac557170cf3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -15
- package/dist/adapter.d.ts +114 -33
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +5 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +38 -4
- package/dist/attempt.d.ts.map +1 -1
- package/dist/attempt.js +14 -1
- package/dist/binary.d.ts +0 -5
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +1 -1
- package/dist/bootstrap.d.ts +28 -9
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +178 -80
- package/dist/chain.d.ts +11 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +9 -14
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -63
- package/dist/change.d.ts +31 -1
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +10 -1
- package/dist/client.d.ts +24 -12
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +98 -11
- package/dist/collection.d.ts +12 -6
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +51 -76
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +773 -0
- package/dist/connection.d.ts +46 -16
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +3740 -837
- package/dist/conversation.d.ts +33 -12
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +662 -202
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/durability.d.ts +5 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +20 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +151 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/file.d.ts +2 -19
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +7 -122
- package/dist/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +370 -0
- package/dist/host.d.ts +15 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +134 -17
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +3 -0
- package/dist/index.d.ts +15 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/live.d.ts +22 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +124 -0
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +11 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +98 -28
- package/dist/messages.d.ts +28 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +90 -0
- package/dist/model.d.ts +10 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +17 -2
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +20 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +113 -12
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +49 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +40 -0
- package/dist/overlay.d.ts +3 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +100 -182
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/query.d.ts +66 -4
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +48 -7
- package/dist/reach.d.ts +18 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +225 -71
- package/dist/react.d.ts +8 -6
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -17
- package/dist/readiness.d.ts +63 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +33 -0
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +91 -0
- package/dist/recovery.d.ts +26 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +224 -0
- package/dist/refresh.d.ts +16 -15
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +113 -49
- package/dist/replica.d.ts +56 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +298 -151
- package/dist/room-draft.d.ts +34 -4
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +105 -31
- package/dist/rows.d.ts +37 -37
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +173 -104
- package/dist/save.d.ts +52 -9
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +539 -171
- package/dist/search.d.ts +39 -28
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +37 -105
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/shared.d.ts +16 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +431 -0
- package/dist/status.d.ts +9 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -1
- package/dist/store.d.ts +114 -75
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +342 -442
- package/dist/stored.d.ts +135 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +569 -0
- package/dist/tables.d.ts +352 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +621 -0
- package/dist/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +75 -0
- package/dist/validation.d.ts +30 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +162 -0
- package/dist/windows.d.ts +22 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +89 -0
- package/dist/wire.d.ts +168 -32
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +56 -31
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +156 -0
- package/package.json +27 -24
- package/AGENTS.md +0 -318
- package/dist/chat/acts.d.ts +0 -34
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/context.d.ts +0 -3
- package/dist/chat/context.d.ts.map +0 -1
- package/dist/chat/context.js +0 -10
- package/dist/chat/input.d.ts +0 -9
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -99
- package/dist/chat/kit.d.ts +0 -60
- package/dist/chat/kit.d.ts.map +0 -1
- package/dist/chat/kit.js +0 -123
- package/dist/chat/lasting.d.ts +0 -6
- package/dist/chat/lasting.d.ts.map +0 -1
- package/dist/chat/lasting.js +0 -19
- package/dist/chat/list.d.ts +0 -20
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -59
- package/dist/chat/markdown.d.ts +0 -19
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -187
- package/dist/chat/message.d.ts +0 -6
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -192
- package/dist/chat/messages.d.ts +0 -21
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -151
- package/dist/chat/name.d.ts +0 -6
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -11
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -17
- package/dist/chat/overlay.d.ts +0 -31
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -97
- package/dist/chat/parts.d.ts +0 -57
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -119
- package/dist/chat/process.d.ts +0 -20
- package/dist/chat/process.d.ts.map +0 -1
- package/dist/chat/process.js +0 -32
- package/dist/chat/provider.d.ts +0 -63
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -645
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -80
- package/dist/chat/questions.d.ts +0 -31
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/questions.js +0 -111
- package/dist/chat/read.d.ts +0 -5
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/read.js +0 -13
- package/dist/chat/ready.d.ts +0 -33
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -91
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -302
- package/dist/chat.d.ts +0 -14
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -8
- package/dist/read-side.d.ts +0 -18
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -440
package/dist/client.d.ts
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedRoomDraft, SaveResult } from './connection.js';
|
|
1
|
+
import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult } from './connection.js';
|
|
2
2
|
import type { Member, ServiceMode } from './adapter.js';
|
|
3
3
|
import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
4
4
|
import { type Observation } from './observation.js';
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult } from './query.js';
|
|
5
|
+
import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
|
|
6
|
+
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
|
|
8
7
|
import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
|
|
9
8
|
import type { SearchRequest, SearchResult } from './search.js';
|
|
9
|
+
import type { Readiness } from './readiness.js';
|
|
10
10
|
import type { SyncStatus } from './status.js';
|
|
11
11
|
import { type RuntimePort } from './wire.js';
|
|
12
12
|
export type MdRuntimeClient = {
|
|
13
13
|
rooms(): Promise<readonly AppRoom[]>;
|
|
14
14
|
query: {
|
|
15
|
-
(query: DocumentQuery): Promise<DocumentResult>;
|
|
16
|
-
(query: GroupQuery): Promise<GroupResult>;
|
|
15
|
+
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
16
|
+
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
17
17
|
};
|
|
18
18
|
search(request: SearchRequest): Promise<SearchResult>;
|
|
19
19
|
types(locator: string): Promise<RoomSchemas>;
|
|
20
20
|
roomDraft: {
|
|
21
21
|
list(): Promise<readonly RoomDraft[]>;
|
|
22
22
|
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
23
|
-
write(room: string, path: string, revision: string | null, parts: RoomDraftParts): Promise<RoomDraftWrite>;
|
|
23
|
+
write(room: string, path: string, revision: string | null, parts: RoomDraftParts, next?: string): Promise<RoomDraftWrite>;
|
|
24
24
|
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
25
25
|
};
|
|
26
26
|
save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
|
|
27
|
+
saveParts(room: string, parts: readonly SavedParts[]): Promise<SaveResult>;
|
|
27
28
|
presentation: {
|
|
28
29
|
read(): Promise<unknown>;
|
|
29
30
|
write(value: unknown): Promise<void>;
|
|
31
|
+
edit(members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
30
32
|
};
|
|
31
33
|
conversation: {
|
|
32
34
|
list(): Promise<readonly ConversationEntry[]>;
|
|
33
35
|
read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
|
|
34
36
|
create(input: unknown): Promise<CallResult>;
|
|
35
|
-
send(conversation: string): Promise<CallResult>;
|
|
37
|
+
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
36
38
|
answer(conversation: string, answer: unknown): Promise<CallResult>;
|
|
37
39
|
interrupt(conversation: string): Promise<CallResult>;
|
|
38
40
|
kill(conversation: string): Promise<CallResult>;
|
|
@@ -41,27 +43,33 @@ export type MdRuntimeClient = {
|
|
|
41
43
|
};
|
|
42
44
|
chatDraft: {
|
|
43
45
|
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
46
|
+
prepend(conversation: string, draft: ChatDraft): Promise<void>;
|
|
44
47
|
discard(conversation: string): Promise<void>;
|
|
45
48
|
};
|
|
46
49
|
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
50
|
+
resolve(room: string, path: string, destination: string): Promise<Resolution>;
|
|
47
51
|
binaryFile: {
|
|
48
52
|
read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
|
|
49
|
-
|
|
53
|
+
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
54
|
+
download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
|
|
50
55
|
};
|
|
51
56
|
call(name: string, input: unknown): Promise<CallResult>;
|
|
52
57
|
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
53
58
|
log(): Promise<string>;
|
|
54
59
|
persistence(): Promise<boolean>;
|
|
60
|
+
retry(): Promise<void>;
|
|
61
|
+
cleanUp(): Promise<number>;
|
|
55
62
|
observe: {
|
|
56
63
|
(topic: 'deployment-facts'): Promise<Observation<unknown>>;
|
|
57
64
|
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
65
|
+
(topic: 'readiness'): Promise<Observation<Readiness>>;
|
|
58
66
|
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
59
67
|
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
60
68
|
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
61
69
|
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
62
70
|
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
63
|
-
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult>>;
|
|
64
|
-
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult>>;
|
|
71
|
+
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
72
|
+
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
65
73
|
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
66
74
|
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
67
75
|
(topic: 'presentation'): Promise<Observation<unknown>>;
|
|
@@ -74,6 +82,10 @@ export type MdRuntimeClient = {
|
|
|
74
82
|
};
|
|
75
83
|
export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
|
|
76
84
|
export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
|
|
85
|
+
export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
|
|
86
|
+
export { roomDraftRevision } from './identity.js';
|
|
87
|
+
export { defineRoomMedia, ROOM_MEDIA } from './media.js';
|
|
77
88
|
export type { Observation } from './observation.js';
|
|
78
|
-
export type {
|
|
89
|
+
export type { Open } from './open.js';
|
|
90
|
+
export { unanswered, type RuntimePort, type WireMember } from './wire.js';
|
|
79
91
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,cAAc,EACd,UAAU,EACX,MAAM,i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AAmB,GAC3B,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAC1C,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAAC,CAAC;QAC7E,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAAC,CAAC;KACvE,CAAC;IACF,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B,CAAC;AAMF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,CAuSnE;AAID,wBAAgB,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAUxF;AAED,OAAO,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
+
import { shownBy } from './media.js';
|
|
1
2
|
import { observed } from './observation.js';
|
|
2
3
|
import { runtimeError } from './failure.js';
|
|
3
4
|
import { answer, AUTHORIZATION_ENDED, PORT_CLOSED, } from './wire.js';
|
|
5
|
+
// React renders an arrived value in a later task and opens what that render observes as it commits, so this many frames opening nothing mean the page drew what it observes.
|
|
6
|
+
const SETTLED_FRAMES = 2;
|
|
7
|
+
// 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.
|
|
8
|
+
const HANDED_COPY_MS = 60_000;
|
|
9
|
+
const PAGE = /\.html?$/iu;
|
|
10
|
+
const STARTED = { kind: 'started' };
|
|
11
|
+
const BLOCKED = {
|
|
12
|
+
kind: 'blocked',
|
|
13
|
+
code: 'popup-blocked',
|
|
14
|
+
fields: {},
|
|
15
|
+
retryable: true,
|
|
16
|
+
};
|
|
17
|
+
function handed(url, name) {
|
|
18
|
+
const anchor = document.createElement('a');
|
|
19
|
+
anchor.href = url;
|
|
20
|
+
anchor.download = name;
|
|
21
|
+
anchor.click();
|
|
22
|
+
}
|
|
4
23
|
function refused(refusal) {
|
|
5
24
|
return runtimeError(refusal.code, refusal.code, refusal.retryable);
|
|
6
25
|
}
|
|
@@ -131,6 +150,57 @@ export function connectMdRuntime(port) {
|
|
|
131
150
|
drawing?.();
|
|
132
151
|
});
|
|
133
152
|
}
|
|
153
|
+
function streamed(answer) {
|
|
154
|
+
if (answer.kind !== 'binary')
|
|
155
|
+
return answer;
|
|
156
|
+
const { file, byteLength, mediaType } = answer;
|
|
157
|
+
let part = 0;
|
|
158
|
+
let received = 0;
|
|
159
|
+
const stream = new ReadableStream({
|
|
160
|
+
async pull(controller) {
|
|
161
|
+
const bytes = await ask('binaryFile.part', [file, part]);
|
|
162
|
+
if (bytes === null) {
|
|
163
|
+
if (received === byteLength)
|
|
164
|
+
controller.close();
|
|
165
|
+
else
|
|
166
|
+
controller.error(runtimeError('binary-file-absent', 'The file ended early'));
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
part += 1;
|
|
170
|
+
received += bytes.byteLength;
|
|
171
|
+
controller.enqueue(bytes);
|
|
172
|
+
},
|
|
173
|
+
}, { highWaterMark: 0 });
|
|
174
|
+
return { kind: 'binary', stream, byteLength, mediaType };
|
|
175
|
+
}
|
|
176
|
+
async function download(room, path, revision) {
|
|
177
|
+
const tab = PAGE.test(path) ? globalThis.open('', '_blank') : null;
|
|
178
|
+
const linked = await ask('binaryFile.link', [room, path, revision]);
|
|
179
|
+
if (linked.kind === 'link' && PAGE.test(linked.name)) {
|
|
180
|
+
const away = tab ?? globalThis.open('', '_blank');
|
|
181
|
+
if (away === null)
|
|
182
|
+
return BLOCKED;
|
|
183
|
+
away.location.replace(linked.url);
|
|
184
|
+
return STARTED;
|
|
185
|
+
}
|
|
186
|
+
tab?.close();
|
|
187
|
+
if (linked.kind === 'link') {
|
|
188
|
+
handed(linked.url, linked.name);
|
|
189
|
+
return STARTED;
|
|
190
|
+
}
|
|
191
|
+
if (linked.kind !== 'absent')
|
|
192
|
+
return linked;
|
|
193
|
+
const read = streamed(await ask('binaryFile.read', [room, path, revision]));
|
|
194
|
+
if (read.kind !== 'binary')
|
|
195
|
+
return read;
|
|
196
|
+
const copy = await new Response(read.stream, {
|
|
197
|
+
headers: { 'content-type': read.mediaType },
|
|
198
|
+
}).blob();
|
|
199
|
+
const url = URL.createObjectURL(copy);
|
|
200
|
+
handed(url, path.slice(path.lastIndexOf('/') + 1));
|
|
201
|
+
setTimeout(() => URL.revokeObjectURL(url), HANDED_COPY_MS);
|
|
202
|
+
return STARTED;
|
|
203
|
+
}
|
|
134
204
|
function settled() {
|
|
135
205
|
if (settling !== null)
|
|
136
206
|
return settling;
|
|
@@ -141,21 +211,27 @@ export function connectMdRuntime(port) {
|
|
|
141
211
|
if (opening.size > 0)
|
|
142
212
|
return;
|
|
143
213
|
const at = moved;
|
|
144
|
-
|
|
214
|
+
const waited = (frames) => {
|
|
145
215
|
requestAnimationFrame(() => {
|
|
216
|
+
if (frames < SETTLED_FRAMES) {
|
|
217
|
+
waited(frames + 1);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
146
220
|
if (moved !== at || opening.size > 0)
|
|
147
221
|
return;
|
|
148
222
|
drawing = null;
|
|
149
223
|
resolve();
|
|
150
224
|
});
|
|
151
|
-
}
|
|
225
|
+
};
|
|
226
|
+
waited(1);
|
|
152
227
|
};
|
|
153
228
|
drawing = check;
|
|
154
229
|
check();
|
|
155
230
|
});
|
|
156
231
|
return settling;
|
|
157
232
|
}
|
|
158
|
-
|
|
233
|
+
const show = (room, path, revision) => ask('binaryFile.show', [room, path, revision]).then((shown) => streamed(shown));
|
|
234
|
+
return shownBy(show, {
|
|
159
235
|
rooms: () => ask('rooms', []),
|
|
160
236
|
query: ((query) => ask('query', [query])),
|
|
161
237
|
search: (request) => ask('search', [request]),
|
|
@@ -163,19 +239,21 @@ export function connectMdRuntime(port) {
|
|
|
163
239
|
roomDraft: {
|
|
164
240
|
list: () => ask('roomDraft.list', []),
|
|
165
241
|
read: (room, path) => ask('roomDraft.read', [room, path]),
|
|
166
|
-
write: (room, path, revision, parts) => ask('roomDraft.write', [room, path, revision, parts]),
|
|
242
|
+
write: (room, path, revision, parts, next) => ask('roomDraft.write', next === undefined ? [room, path, revision, parts] : [room, path, revision, parts, next]),
|
|
167
243
|
discard: (room, path, revision) => ask('roomDraft.discard', [room, path, revision]),
|
|
168
244
|
},
|
|
169
245
|
save: (room, roomDrafts) => ask('save', [room, roomDrafts]),
|
|
246
|
+
saveParts: (room, parts) => ask('saveParts', [room, parts]),
|
|
170
247
|
presentation: {
|
|
171
248
|
read: () => ask('presentation.read', []),
|
|
172
249
|
write: (value) => ask('presentation.write', [value]),
|
|
250
|
+
edit: (members) => ask('presentation.edit', [members]),
|
|
173
251
|
},
|
|
174
252
|
conversation: {
|
|
175
253
|
list: () => ask('conversation.list', []),
|
|
176
254
|
read: (conversation, options) => ask('conversation.read', [conversation, options]),
|
|
177
255
|
create: (input) => ask('conversation.create', [input]),
|
|
178
|
-
send: (conversation) => ask('conversation.send', [conversation]),
|
|
256
|
+
send: (conversation, operation, draft) => ask('conversation.send', [conversation, operation, draft]),
|
|
179
257
|
answer: (conversation, answer) => ask('conversation.answer', [conversation, answer]),
|
|
180
258
|
interrupt: (conversation) => ask('conversation.interrupt', [conversation]),
|
|
181
259
|
kill: (conversation) => ask('conversation.kill', [conversation]),
|
|
@@ -184,25 +262,34 @@ export function connectMdRuntime(port) {
|
|
|
184
262
|
},
|
|
185
263
|
chatDraft: {
|
|
186
264
|
write: (conversation, draft, revision) => ask('chatDraft.write', [conversation, draft, revision]),
|
|
265
|
+
prepend: (conversation, draft) => ask('chatDraft.prepend', [conversation, draft]),
|
|
187
266
|
discard: (conversation) => ask('chatDraft.discard', [conversation]),
|
|
188
267
|
},
|
|
189
268
|
history: (locator, path, query) => ask('history', [locator, path, query]),
|
|
269
|
+
resolve: (room, path, destination) => ask('resolve', [room, path, destination]),
|
|
190
270
|
binaryFile: {
|
|
191
|
-
read: (room, path, revision) => ask('binaryFile.read', [room, path, revision]),
|
|
192
|
-
|
|
271
|
+
read: (room, path, revision) => ask('binaryFile.read', [room, path, revision]).then((read) => streamed(read)),
|
|
272
|
+
attach: (room, file) => ask('binaryFile.attach', [room, file]),
|
|
273
|
+
download,
|
|
193
274
|
},
|
|
194
275
|
call: (name, input) => ask('call', [name, input]),
|
|
195
276
|
reached: (locator, roomVersion, path) => ask('reached', [locator, roomVersion, path]),
|
|
196
277
|
log: () => ask('log', []),
|
|
197
278
|
persistence: () => ask('persistence', []),
|
|
279
|
+
retry: () => ask('retry', []),
|
|
280
|
+
cleanUp: () => ask('cleanUp', []),
|
|
198
281
|
observe: ((topic, ...input) => watch(topic, input)),
|
|
199
282
|
reauthorize: () => ask('reauthorize', []),
|
|
200
283
|
settled,
|
|
201
|
-
};
|
|
284
|
+
});
|
|
202
285
|
}
|
|
203
286
|
const turns = new WeakMap();
|
|
204
287
|
export function inTurn(client, work) {
|
|
205
|
-
const
|
|
206
|
-
turns.set(client,
|
|
207
|
-
return
|
|
288
|
+
const turn = (turns.get(client) ?? Promise.resolve()).then(work);
|
|
289
|
+
turns.set(client, turn.then(() => undefined, () => undefined));
|
|
290
|
+
return turn;
|
|
208
291
|
}
|
|
292
|
+
export { chainedWindows } from './chain.js';
|
|
293
|
+
export { roomDraftRevision } from './identity.js';
|
|
294
|
+
export { defineRoomMedia, ROOM_MEDIA } from './media.js';
|
|
295
|
+
export { unanswered } from './wire.js';
|
package/dist/collection.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type Document
|
|
1
|
+
import { type Document } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { ModelState } from './model.js';
|
|
3
3
|
import type { MdModelIdentity } from './adapter.js';
|
|
4
|
+
import { type Paths } from './shared.js';
|
|
4
5
|
import type { Refused } from './transfer.js';
|
|
5
6
|
export declare const MD_MODEL: MdModelIdentity;
|
|
6
7
|
export type Collection = {
|
|
@@ -15,11 +16,16 @@ export type Composition = {
|
|
|
15
16
|
model: ModelState;
|
|
16
17
|
} | null;
|
|
17
18
|
};
|
|
19
|
+
export type Composed = {
|
|
20
|
+
readonly composition: Composition;
|
|
21
|
+
readonly fingerprint: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function composedOf(composition: Composition): Composed;
|
|
24
|
+
export declare function selected(composition: Composition, path: string): boolean;
|
|
18
25
|
export declare function governing(composition: Composition, path: string): ModelState;
|
|
19
|
-
export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function unreadable(text: Readonly<Record<string, string>>, previous?: Readonly<Record<string, string>>): Refused | null;
|
|
26
|
+
export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
|
|
27
|
+
export declare function documentsOf(collection: Collection): Generator<number, Iterable<readonly [string, Document]>, void>;
|
|
28
|
+
export declare function unreadable(text: Paths<string>, paths?: Iterable<string> | null): Generator<number, Refused | null, void>;
|
|
23
29
|
export declare function validRoot(root: unknown): root is string;
|
|
24
|
-
export declare function
|
|
30
|
+
export declare function available(composition: Composition): boolean;
|
|
25
31
|
//# sourceMappingURL=collection.d.ts.map
|
package/dist/collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection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U,CAI5E;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACtC,WAAW,EAAE,WAAW,GACvB,UAAU,CAcZ;AAED,wBAAiB,WAAW,CAC1B,UAAU,EAAE,UAAU,GACrB,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAQhE;AAED,wBAAiB,UAAU,CACzB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EACnB,KAAK,GAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAW,GACpC,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,IAAI,CAAC,CAazC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAEvD;AAED,wBAAgB,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAE3D"}
|
package/dist/collection.js
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
import { parse,
|
|
1
|
+
import { parse, VERSION } from '@agentshouse/mdmodel';
|
|
2
2
|
import { beneath, normalize } from './paths.js';
|
|
3
|
+
import { hashed } from './observation.js';
|
|
4
|
+
import { keysIn, sortedKeys } from './shared.js';
|
|
5
|
+
import { ROW_WEIGHT } from './turn.js';
|
|
3
6
|
export const MD_MODEL = { identity: '@agentshouse/mdmodel', version: VERSION };
|
|
4
|
-
const
|
|
5
|
-
function
|
|
7
|
+
const typesPrinted = new WeakMap();
|
|
8
|
+
function typesPrint(model) {
|
|
9
|
+
if (model.status === 'unavailable')
|
|
10
|
+
return '';
|
|
11
|
+
let print = typesPrinted.get(model.types);
|
|
12
|
+
if (print === undefined) {
|
|
13
|
+
print = hashed(JSON.stringify(model.types)).toString(36);
|
|
14
|
+
typesPrinted.set(model.types, print);
|
|
15
|
+
}
|
|
16
|
+
return print;
|
|
17
|
+
}
|
|
18
|
+
export function composedOf(composition) {
|
|
19
|
+
const { model, selection } = composition;
|
|
20
|
+
return {
|
|
21
|
+
composition,
|
|
22
|
+
fingerprint: JSON.stringify([
|
|
23
|
+
typesPrint(model),
|
|
24
|
+
selection === null ? null : [selection.roots, typesPrint(selection.model)],
|
|
25
|
+
]),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function selected(composition, path) {
|
|
6
29
|
return (composition.selection !== null &&
|
|
7
30
|
composition.selection.roots.some((root) => beneath(root, path)));
|
|
8
31
|
}
|
|
@@ -11,22 +34,14 @@ export function governing(composition, path) {
|
|
|
11
34
|
? composition.selection.model
|
|
12
35
|
: composition.model;
|
|
13
36
|
}
|
|
14
|
-
|
|
15
|
-
export function collectionOf(text, composition, previous) {
|
|
37
|
+
export function collectionOf(text, composition) {
|
|
16
38
|
const parsed = new Map();
|
|
17
|
-
|
|
18
|
-
for (const [path, held] of parsedIn.get(previous) ?? []) {
|
|
19
|
-
if (previous.text[path] === text[path])
|
|
20
|
-
parsed.set(path, held);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const collection = {
|
|
39
|
+
return {
|
|
24
40
|
text,
|
|
25
41
|
composition,
|
|
26
42
|
document(path) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return held ?? undefined;
|
|
43
|
+
if (parsed.has(path))
|
|
44
|
+
return parsed.get(path) ?? undefined;
|
|
30
45
|
const content = text[path];
|
|
31
46
|
if (content === undefined)
|
|
32
47
|
return undefined;
|
|
@@ -35,75 +50,35 @@ export function collectionOf(text, composition, previous) {
|
|
|
35
50
|
return read.ok ? read.document : undefined;
|
|
36
51
|
},
|
|
37
52
|
};
|
|
38
|
-
parsedIn.set(collection, parsed);
|
|
39
|
-
return collection;
|
|
40
|
-
}
|
|
41
|
-
export function passingDocument(collection, path) {
|
|
42
|
-
const held = parsedIn.get(collection)?.get(path);
|
|
43
|
-
if (held !== undefined)
|
|
44
|
-
return held ?? undefined;
|
|
45
|
-
const content = collection.text[path];
|
|
46
|
-
if (content === undefined)
|
|
47
|
-
return undefined;
|
|
48
|
-
const read = parse(content, path);
|
|
49
|
-
return read.ok ? read.document : undefined;
|
|
50
53
|
}
|
|
51
54
|
export function* documentsOf(collection) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
yield [path, held];
|
|
59
|
-
continue;
|
|
55
|
+
const paths = yield* sortedKeys(collection.text);
|
|
56
|
+
return (function* () {
|
|
57
|
+
for (const path of paths) {
|
|
58
|
+
const document = collection.document(path);
|
|
59
|
+
if (document !== undefined)
|
|
60
|
+
yield [path, document];
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
if (read.ok)
|
|
63
|
-
yield [path, read.document];
|
|
64
|
-
}
|
|
62
|
+
})();
|
|
65
63
|
}
|
|
66
|
-
export function unreadable(text,
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
export function* unreadable(text, paths = null) {
|
|
65
|
+
const named = paths ?? (yield* keysIn(text));
|
|
66
|
+
let least = null;
|
|
67
|
+
for (const path of named) {
|
|
68
|
+
const content = Object.hasOwn(text, path) ? text[path] : undefined;
|
|
69
|
+
if (content === undefined)
|
|
69
70
|
continue;
|
|
70
|
-
const read = parse(
|
|
71
|
-
if (!read.ok)
|
|
72
|
-
|
|
71
|
+
const read = parse(content, path);
|
|
72
|
+
if (!read.ok && (least === null || path < least.path)) {
|
|
73
|
+
least = { path, refused: { kind: 'refused', refusal: read.refusal } };
|
|
74
|
+
}
|
|
75
|
+
yield ROW_WEIGHT + content.length;
|
|
73
76
|
}
|
|
74
|
-
return null;
|
|
77
|
+
return least?.refused ?? null;
|
|
75
78
|
}
|
|
76
79
|
export function validRoot(root) {
|
|
77
80
|
return typeof root === 'string' && normalize(root) === root;
|
|
78
81
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
const typed = Object.entries(documents).find(([, content]) => {
|
|
82
|
-
const parsed = parse(content);
|
|
83
|
-
return parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any';
|
|
84
|
-
});
|
|
85
|
-
if (typed !== undefined)
|
|
86
|
-
return { verdict: 'refuse', rule: 'model-unavailable', file: typed[0] };
|
|
87
|
-
}
|
|
88
|
-
return validate(documents, { binaryTargets }, model.status === 'unavailable' ? NO_TYPES : { types: model.types });
|
|
89
|
-
}
|
|
90
|
-
export function validateCollection(text, binaryTargets, composition) {
|
|
91
|
-
const collection = {};
|
|
92
|
-
const selection = {};
|
|
93
|
-
for (const [path, content] of Object.entries(text)) {
|
|
94
|
-
if (selected(composition, path))
|
|
95
|
-
selection[path] = content;
|
|
96
|
-
else
|
|
97
|
-
collection[path] = content;
|
|
98
|
-
}
|
|
99
|
-
const verdicts = [
|
|
100
|
-
validateAgainst(collection, binaryTargets.filter((path) => !selected(composition, path)), composition.model),
|
|
101
|
-
];
|
|
102
|
-
if (composition.selection !== null) {
|
|
103
|
-
verdicts.push(validateAgainst(selection, binaryTargets.filter((path) => selected(composition, path)), composition.selection.model));
|
|
104
|
-
}
|
|
105
|
-
const refusals = verdicts.filter((verdict) => verdict.verdict === 'refuse');
|
|
106
|
-
if (refusals.length === 0)
|
|
107
|
-
return verdicts[0];
|
|
108
|
-
return refusals.find((refusal) => refusal.rule !== 'model-unavailable') ?? refusals[0];
|
|
82
|
+
export function available(composition) {
|
|
83
|
+
return composition.model.status !== 'unavailable';
|
|
109
84
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Plan, QueryRows } from './query.js';
|
|
2
|
+
import type { Connection, Value } from './tables.js';
|
|
3
|
+
export type QueryRoom = {
|
|
4
|
+
readonly locator: string;
|
|
5
|
+
readonly key: number;
|
|
6
|
+
};
|
|
7
|
+
export type Fragment = {
|
|
8
|
+
readonly sql: string;
|
|
9
|
+
readonly bind: readonly Value[];
|
|
10
|
+
};
|
|
11
|
+
export type QueryAnswer = QueryRows & {
|
|
12
|
+
readonly more?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function selected(connection: Connection, plan: Plan, rooms: readonly QueryRoom[]): Fragment;
|
|
15
|
+
export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
|
|
16
|
+
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAOV,IAAI,EAGJ,SAAS,EAIV,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,UAAU,EAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAU1D,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,KAAK,EAAE,CAAA;CAAE,CAAC;AAssBjF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA4TjE,wBAAgB,QAAQ,CACtB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,SAAS,EAAE,GAC1B,QAAQ,CAEV;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,MAAM,GAAE,MAAM,GAAG,IAAW,GAC3B,WAAW,CAUb"}
|