@agentshouse/mdruntime 0.1.0-ccd098ff75bbf → 0.1.0-cce1d81ef3d6d
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/dist/adapter.d.ts +65 -48
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +18 -1
- package/dist/bootstrap.d.ts +9 -11
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +97 -85
- package/dist/client.d.ts +6 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +52 -6
- package/dist/collection.d.ts +5 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -17
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +65 -19
- package/dist/connection.d.ts +5 -4
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +925 -900
- package/dist/conversation.d.ts +11 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +204 -129
- package/dist/durability.d.ts +0 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +1 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +1 -1
- package/dist/file.d.ts +2 -11
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +6 -4
- package/dist/fulltext.d.ts.map +1 -1
- package/dist/fulltext.js +8 -6
- package/dist/host.d.ts +0 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +10 -11
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- 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 +8 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +174 -82
- package/dist/model.d.ts +6 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -9
- package/dist/observation.d.ts +1 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +1 -1
- package/dist/outcome.d.ts +13 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +16 -2
- 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 +6 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/reach.d.ts +8 -1
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +49 -22
- package/dist/readiness.d.ts +3 -15
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +4 -10
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +26 -0
- package/dist/refresh.d.ts +5 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +4 -4
- package/dist/replica.d.ts +2 -3
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +2 -5
- package/dist/room-draft.d.ts +17 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +40 -6
- package/dist/rows.d.ts +4 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +29 -20
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +11 -5
- package/dist/shared.d.ts +0 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +0 -10
- package/dist/status.d.ts +4 -3
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -1
- package/dist/store.d.ts +18 -32
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +25 -60
- package/dist/stored.d.ts +9 -24
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +207 -204
- package/dist/tables.d.ts +16 -45
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +7 -53
- 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 +35 -96
- package/dist/wire.d.ts +8 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -2
- package/dist/words.d.ts.map +1 -1
- package/dist/words.js +8 -2
- package/package.json +2 -2
- package/dist/reads.d.ts +0 -11
- package/dist/reads.d.ts.map +0 -1
- package/dist/reads.js +0 -100
package/dist/bootstrap.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { transferIdentity } from './identity.js';
|
|
2
2
|
import { advancement, pageEntries } from './refresh.js';
|
|
3
|
+
import { entriesIn } from './shared.js';
|
|
3
4
|
import { unconfirmed } from './transfer.js';
|
|
4
|
-
const NOTHING_DONE = { parts: 0, bytes: 0 };
|
|
5
|
-
const RESUMABLE = new Set([
|
|
6
|
-
'transport-uncertainty',
|
|
7
|
-
'retryable-refusal',
|
|
8
|
-
'unconfirmed',
|
|
9
|
-
]);
|
|
10
5
|
const NOTHING_PRIOR = () => Promise.resolve(new Map());
|
|
6
|
+
function textOf(page) {
|
|
7
|
+
let text = 0;
|
|
8
|
+
for (const [, content] of entriesIn(page.documents))
|
|
9
|
+
text += content.length;
|
|
10
|
+
return text;
|
|
11
|
+
}
|
|
11
12
|
async function pageOf(page) {
|
|
12
13
|
return {
|
|
13
14
|
entries: await pageEntries(page, [], page.roomVersion, NOTHING_PRIOR),
|
|
@@ -39,16 +40,15 @@ const NO_CONTENT = {
|
|
|
39
40
|
contents: () => Promise.resolve(new Map()),
|
|
40
41
|
};
|
|
41
42
|
export async function bootstrapRoom(adapter, authorization, room, held, builtIn, remodel, continuing, staging, reuse) {
|
|
42
|
-
|
|
43
|
-
const resumed = kept !== null && kept.selection === room.replica.selection ? kept : null;
|
|
44
|
-
if (kept !== null && resumed === null)
|
|
43
|
+
if (staging.held(room.locator) !== null)
|
|
45
44
|
await staging.abandon(room.locator);
|
|
46
|
-
const
|
|
45
|
+
const begun = (pool) => started(adapter, authorization, room, held, builtIn, remodel, continuing, staging, pool);
|
|
46
|
+
const first = await begun(reuse);
|
|
47
47
|
if (first.kind !== 'expired')
|
|
48
48
|
return first;
|
|
49
49
|
await staging.setAside(room.locator);
|
|
50
50
|
try {
|
|
51
|
-
const replacement = await
|
|
51
|
+
const replacement = await begun(heldTogether(reuse, first.held));
|
|
52
52
|
if (replacement.kind !== 'expired')
|
|
53
53
|
return replacement;
|
|
54
54
|
await staging.abandon(room.locator);
|
|
@@ -59,7 +59,12 @@ export async function bootstrapRoom(adapter, authorization, room, held, builtIn,
|
|
|
59
59
|
await staging.release(first.key);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
function dropped(ahead) {
|
|
63
|
+
void ahead?.fetched.then(({ next, written }) => {
|
|
64
|
+
written();
|
|
65
|
+
dropped(next);
|
|
66
|
+
}, () => { });
|
|
67
|
+
}
|
|
63
68
|
function compositionFor(room, models, builtIn) {
|
|
64
69
|
return {
|
|
65
70
|
model: models.collection,
|
|
@@ -68,65 +73,72 @@ function compositionFor(room, models, builtIn) {
|
|
|
68
73
|
: { roots: room.typedSelection.roots, model: builtIn },
|
|
69
74
|
};
|
|
70
75
|
}
|
|
71
|
-
async function
|
|
76
|
+
async function started(adapter, authorization, room, held, builtIn, remodel, continuing, staging, pool) {
|
|
77
|
+
let outcome;
|
|
78
|
+
try {
|
|
79
|
+
outcome = await bundle(adapter, authorization, room, held, builtIn, remodel, continuing, staging, pool);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
await staging.abandon(room.locator).catch(() => { });
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
if (outcome.kind !== 'staged' && outcome.kind !== 'expired') {
|
|
86
|
+
await staging.abandon(room.locator);
|
|
87
|
+
}
|
|
88
|
+
return outcome;
|
|
89
|
+
}
|
|
90
|
+
async function bundle(adapter, authorization, room, held, builtIn, remodel, continuing, staging, pool) {
|
|
72
91
|
const locator = room.locator;
|
|
73
92
|
const selection = room.replica.selection;
|
|
74
|
-
|
|
75
|
-
let lookups = kept === null ? 0 : RESUMED_LOOKUPS;
|
|
76
|
-
let ahead = null;
|
|
93
|
+
const ending = new AbortController();
|
|
77
94
|
const arriving = staging.arriving(locator);
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
const downloaded = await staging.turn(locator, 'downloading');
|
|
96
|
+
const asking = (token) => adapter.bootstrap(authorization, {
|
|
97
|
+
locator,
|
|
98
|
+
selection,
|
|
99
|
+
signal: ending.signal,
|
|
100
|
+
...(token === null
|
|
101
|
+
? { arriving: (bytes) => arriving.at(bytes) }
|
|
102
|
+
: { pageToken: token }),
|
|
103
|
+
...(pool === null ? {} : { held: pool }),
|
|
104
|
+
});
|
|
105
|
+
const fetching = (token) => {
|
|
106
|
+
const fetched = (async () => {
|
|
107
|
+
await staging.unqueued();
|
|
108
|
+
const page = continuing() ? await asking(token) : unconfirmed;
|
|
109
|
+
if (page.kind !== 'bootstrap')
|
|
110
|
+
return { page, next: null, written: () => { } };
|
|
111
|
+
const written = staging.queued(textOf(page));
|
|
112
|
+
const later = page.pageToken;
|
|
113
|
+
if (later === undefined) {
|
|
114
|
+
downloaded();
|
|
115
|
+
arriving.end();
|
|
116
|
+
}
|
|
117
|
+
return { page, written, next: later === undefined || !continuing() ? null : fetching(later) };
|
|
118
|
+
})();
|
|
119
|
+
fetched.catch(() => { });
|
|
120
|
+
return { fetched };
|
|
96
121
|
};
|
|
122
|
+
let transfer = null;
|
|
123
|
+
let ahead = fetching(null);
|
|
97
124
|
try {
|
|
98
|
-
while (
|
|
125
|
+
while (ahead !== null) {
|
|
99
126
|
if (!continuing())
|
|
100
127
|
return unconfirmed;
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
const fetched = ahead !== null && ahead.token === asked ? ahead : null;
|
|
104
|
-
if (ahead !== fetched)
|
|
105
|
-
ahead?.release();
|
|
106
|
-
ahead = null;
|
|
107
|
-
const turned = fetched?.release ??
|
|
108
|
-
(await staging.turn(locator, transfer === null ? 'listing' : 'downloading'));
|
|
128
|
+
const fetched = await ahead.fetched;
|
|
129
|
+
ahead = fetched.next;
|
|
109
130
|
try {
|
|
110
131
|
if (!continuing())
|
|
111
132
|
return unconfirmed;
|
|
112
|
-
const page =
|
|
133
|
+
const page = fetched.page;
|
|
113
134
|
if (page.kind === 'beyond-horizon') {
|
|
114
135
|
const key = transfer?.key ?? null;
|
|
115
136
|
return { kind: 'expired', held: key === null ? NO_CONTENT : staging.content(key), key };
|
|
116
137
|
}
|
|
117
|
-
if (page.kind !== 'bootstrap')
|
|
118
|
-
if (!RESUMABLE.has(page.kind))
|
|
119
|
-
await staging.abandon(locator);
|
|
138
|
+
if (page.kind !== 'bootstrap')
|
|
120
139
|
return page;
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
const spare = later === undefined || !continuing() ? null : staging.spare();
|
|
124
|
-
if (later !== undefined && spare !== null) {
|
|
125
|
-
const answer = asking(later);
|
|
126
|
-
answer.catch(() => { });
|
|
127
|
-
ahead = { token: later, page: answer, release: spare };
|
|
128
|
-
}
|
|
129
|
-
const next = {
|
|
140
|
+
const models = remodel(page.models, transfer?.models ?? held);
|
|
141
|
+
const staged = await staging.stage({
|
|
130
142
|
locator,
|
|
131
143
|
transfer: transfer?.transfer ?? transferIdentity(),
|
|
132
144
|
selection,
|
|
@@ -136,27 +148,31 @@ async function bundle(adapter, authorization, room, held, builtIn, remodel, cont
|
|
|
136
148
|
last: transfer !== null && !adapter.reached(locator, page.roomVersion, transfer.last)
|
|
137
149
|
? transfer.last
|
|
138
150
|
: page.roomVersion,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
inventory: page.inventory ?? transfer?.inventory ?? null,
|
|
142
|
-
done: transfer?.done ?? NOTHING_DONE,
|
|
143
|
-
models: remodel(page.models, transfer?.models ?? held),
|
|
151
|
+
done: { bytes: (transfer?.done.bytes ?? 0) + (page.bytes ?? 0) },
|
|
152
|
+
models,
|
|
144
153
|
key: transfer?.key ?? null,
|
|
145
|
-
};
|
|
146
|
-
const staged = await staging.stage(next, await pageOf(page), compositionFor(room, next.models, builtIn), page.received ?? null);
|
|
154
|
+
}, await pageOf(page), compositionFor(room, models, builtIn));
|
|
147
155
|
if (staged === null)
|
|
148
156
|
return unconfirmed;
|
|
149
157
|
transfer = staged;
|
|
150
158
|
}
|
|
151
159
|
finally {
|
|
152
|
-
|
|
160
|
+
fetched.written();
|
|
153
161
|
}
|
|
154
162
|
}
|
|
155
163
|
}
|
|
156
164
|
finally {
|
|
157
|
-
|
|
165
|
+
ending.abort();
|
|
166
|
+
downloaded();
|
|
158
167
|
arriving.end();
|
|
168
|
+
dropped(ahead);
|
|
159
169
|
}
|
|
170
|
+
if (transfer === null)
|
|
171
|
+
return unconfirmed;
|
|
172
|
+
const installed = transfer;
|
|
173
|
+
const composition = compositionFor(room, installed.models, builtIn);
|
|
174
|
+
if (!(await staging.derive(locator, installed.key, composition)))
|
|
175
|
+
return unconfirmed;
|
|
160
176
|
await staging.turn(locator, 'replaying');
|
|
161
177
|
if (!continuing())
|
|
162
178
|
return unconfirmed;
|
|
@@ -166,33 +182,29 @@ async function bundle(adapter, authorization, room, held, builtIn, remodel, cont
|
|
|
166
182
|
handle: room.handle,
|
|
167
183
|
operations: room.operations,
|
|
168
184
|
replica: room.replica,
|
|
169
|
-
model:
|
|
185
|
+
model: installed.models.collection,
|
|
170
186
|
typedSelection: room.typedSelection ?? null,
|
|
171
187
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
172
|
-
roomVersion:
|
|
173
|
-
transfer:
|
|
174
|
-
inventory:
|
|
175
|
-
key:
|
|
188
|
+
roomVersion: installed.from,
|
|
189
|
+
transfer: installed.transfer,
|
|
190
|
+
inventory: installed.done,
|
|
191
|
+
key: installed.key,
|
|
176
192
|
};
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
const reconciled = last ===
|
|
193
|
+
const last = installed.last;
|
|
194
|
+
const refresh = adapter.refresh;
|
|
195
|
+
const reconciled = last === installed.from &&
|
|
196
|
+
(staging.streamed || adapter.reached(locator, last, room.roomVersion))
|
|
180
197
|
? { kind: 'still-current' }
|
|
181
|
-
:
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (refused !== null) {
|
|
187
|
-
await staging.abandon(locator);
|
|
188
|
-
return refused;
|
|
189
|
-
}
|
|
190
|
-
return { kind: 'staged', record: result, refreshed };
|
|
198
|
+
: refresh === undefined
|
|
199
|
+
? unconfirmed
|
|
200
|
+
: await advancement(refresh, authorization, record, remodel, continuing, await staging.refreshing(locator, record.key, composition));
|
|
201
|
+
if (reconciled.kind === 'advanced') {
|
|
202
|
+
return { kind: 'staged', record: reconciled.record, refreshed: true };
|
|
191
203
|
}
|
|
204
|
+
if (reconciled.kind === 'still-current')
|
|
205
|
+
return { kind: 'staged', record, refreshed: false };
|
|
192
206
|
if (reconciled.kind === 'beyond-horizon') {
|
|
193
207
|
return { kind: 'expired', held: staging.content(record.key), key: record.key };
|
|
194
208
|
}
|
|
195
|
-
if (!RESUMABLE.has(reconciled.kind))
|
|
196
|
-
await staging.abandon(locator);
|
|
197
209
|
return reconciled;
|
|
198
210
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult } from './connection.js';
|
|
2
2
|
import type { Member, ServiceMode } from './adapter.js';
|
|
3
|
-
import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
3
|
+
import type { ChatDraft, ConversationAgent, ConversationAnswer, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
4
4
|
import { type Observation } from './observation.js';
|
|
5
|
-
import type {
|
|
6
|
-
import type { BinaryAnswer, BinaryLinkAnswer, CallResult, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
|
|
5
|
+
import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
|
|
7
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';
|
|
@@ -36,11 +35,9 @@ export type MdRuntimeClient = {
|
|
|
36
35
|
read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
|
|
37
36
|
create(input: unknown): Promise<CallResult>;
|
|
38
37
|
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
39
|
-
|
|
40
|
-
answer(conversation: string, answer: unknown): Promise<CallResult>;
|
|
38
|
+
answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
|
|
41
39
|
interrupt(conversation: string): Promise<CallResult>;
|
|
42
40
|
kill(conversation: string): Promise<CallResult>;
|
|
43
|
-
cancel(conversation: string, turn: string): Promise<CallResult>;
|
|
44
41
|
delete(conversation: string): Promise<CallResult>;
|
|
45
42
|
};
|
|
46
43
|
chatDraft: {
|
|
@@ -52,7 +49,8 @@ export type MdRuntimeClient = {
|
|
|
52
49
|
resolve(room: string, path: string, destination: string): Promise<Resolution>;
|
|
53
50
|
binaryFile: {
|
|
54
51
|
read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
|
|
55
|
-
|
|
52
|
+
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
53
|
+
download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
|
|
56
54
|
};
|
|
57
55
|
call(name: string, input: unknown): Promise<CallResult>;
|
|
58
56
|
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
@@ -85,6 +83,7 @@ export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
|
|
|
85
83
|
export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
|
|
86
84
|
export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
|
|
87
85
|
export { roomDraftRevision } from './identity.js';
|
|
86
|
+
export { defineRoomMedia, ROOM_MEDIA } from './media.js';
|
|
88
87
|
export type { Observation } from './observation.js';
|
|
89
88
|
export type { Open } from './open.js';
|
|
90
89
|
export { unanswered, type RuntimePort, type WireMember } from './wire.js';
|
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,UAAU,EACV,cAAc,EACd,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;
|
|
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,UAAU,EACV,cAAc,EACd,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAY,KAAK,WAAW,EAAiB,MAAM,kBAAkB,CAAC;AAE7E,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EAEZ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AY,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,8 +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';
|
|
4
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.
|
|
5
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
|
+
}
|
|
6
23
|
function refused(refusal) {
|
|
7
24
|
return runtimeError(refusal.code, refusal.code, refusal.retryable);
|
|
8
25
|
}
|
|
@@ -156,6 +173,34 @@ export function connectMdRuntime(port) {
|
|
|
156
173
|
}, { highWaterMark: 0 });
|
|
157
174
|
return { kind: 'binary', stream, byteLength, mediaType };
|
|
158
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
|
+
}
|
|
159
204
|
function settled() {
|
|
160
205
|
if (settling !== null)
|
|
161
206
|
return settling;
|
|
@@ -185,7 +230,8 @@ export function connectMdRuntime(port) {
|
|
|
185
230
|
});
|
|
186
231
|
return settling;
|
|
187
232
|
}
|
|
188
|
-
|
|
233
|
+
const show = (room, path, revision) => ask('binaryFile.show', [room, path, revision]).then((shown) => streamed(shown));
|
|
234
|
+
return shownBy(show, {
|
|
189
235
|
rooms: () => ask('rooms', []),
|
|
190
236
|
query: ((query) => ask('query', [query])),
|
|
191
237
|
search: (request) => ask('search', [request]),
|
|
@@ -208,11 +254,9 @@ export function connectMdRuntime(port) {
|
|
|
208
254
|
read: (conversation, options) => ask('conversation.read', [conversation, options]),
|
|
209
255
|
create: (input) => ask('conversation.create', [input]),
|
|
210
256
|
send: (conversation, operation, draft) => ask('conversation.send', [conversation, operation, draft]),
|
|
211
|
-
attach: (room, file) => ask('conversation.attach', [room, file]),
|
|
212
257
|
answer: (conversation, answer) => ask('conversation.answer', [conversation, answer]),
|
|
213
258
|
interrupt: (conversation) => ask('conversation.interrupt', [conversation]),
|
|
214
259
|
kill: (conversation) => ask('conversation.kill', [conversation]),
|
|
215
|
-
cancel: (conversation, turn) => ask('conversation.cancel', [conversation, turn]),
|
|
216
260
|
delete: (conversation) => ask('conversation.delete', [conversation]),
|
|
217
261
|
},
|
|
218
262
|
chatDraft: {
|
|
@@ -223,8 +267,9 @@ export function connectMdRuntime(port) {
|
|
|
223
267
|
history: (locator, path, query) => ask('history', [locator, path, query]),
|
|
224
268
|
resolve: (room, path, destination) => ask('resolve', [room, path, destination]),
|
|
225
269
|
binaryFile: {
|
|
226
|
-
read: (room, path, revision) => ask('binaryFile.read', [room, path, revision]).then(streamed),
|
|
227
|
-
|
|
270
|
+
read: (room, path, revision) => ask('binaryFile.read', [room, path, revision]).then((read) => streamed(read)),
|
|
271
|
+
attach: (room, file) => ask('binaryFile.attach', [room, file]),
|
|
272
|
+
download,
|
|
228
273
|
},
|
|
229
274
|
call: (name, input) => ask('call', [name, input]),
|
|
230
275
|
reached: (locator, roomVersion, path) => ask('reached', [locator, roomVersion, path]),
|
|
@@ -235,7 +280,7 @@ export function connectMdRuntime(port) {
|
|
|
235
280
|
observe: ((topic, ...input) => watch(topic, input)),
|
|
236
281
|
reauthorize: () => ask('reauthorize', []),
|
|
237
282
|
settled,
|
|
238
|
-
};
|
|
283
|
+
});
|
|
239
284
|
}
|
|
240
285
|
const turns = new WeakMap();
|
|
241
286
|
export function inTurn(client, work) {
|
|
@@ -245,4 +290,5 @@ export function inTurn(client, work) {
|
|
|
245
290
|
}
|
|
246
291
|
export { chainedWindows } from './chain.js';
|
|
247
292
|
export { roomDraftRevision } from './identity.js';
|
|
293
|
+
export { defineRoomMedia, ROOM_MEDIA } from './media.js';
|
|
248
294
|
export { unanswered } from './wire.js';
|
package/dist/collection.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
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';
|
|
5
|
-
import type { Refused } from './transfer.js';
|
|
6
4
|
export declare const MD_MODEL: MdModelIdentity;
|
|
7
5
|
export type Collection = {
|
|
8
6
|
text: Readonly<Record<string, string>>;
|
|
@@ -16,11 +14,15 @@ export type Composition = {
|
|
|
16
14
|
model: ModelState;
|
|
17
15
|
} | null;
|
|
18
16
|
};
|
|
17
|
+
export type Composed = {
|
|
18
|
+
readonly composition: Composition;
|
|
19
|
+
readonly fingerprint: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function composedOf(composition: Composition): Composed;
|
|
19
22
|
export declare function selected(composition: Composition, path: string): boolean;
|
|
20
23
|
export declare function governing(composition: Composition, path: string): ModelState;
|
|
21
24
|
export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
|
|
22
25
|
export declare function documentsOf(collection: Collection): Generator<number, Iterable<readonly [string, Document]>, void>;
|
|
23
|
-
export declare function unreadable(text: Paths<string>, paths?: Iterable<string> | null): Generator<number, Refused | null, void>;
|
|
24
26
|
export declare function validRoot(root: unknown): root is string;
|
|
25
27
|
export declare function available(composition: Composition): boolean;
|
|
26
28
|
//# sourceMappingURL=collection.d.ts.map
|
package/dist/collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection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CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAQhE;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,29 @@
|
|
|
1
1
|
import { parse, VERSION } from '@agentshouse/mdmodel';
|
|
2
2
|
import { beneath, normalize } from './paths.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { hashed } from './observation.js';
|
|
4
|
+
import { sortedKeys } from './shared.js';
|
|
5
5
|
export const MD_MODEL = { identity: '@agentshouse/mdmodel', version: VERSION };
|
|
6
|
+
const typesPrinted = new WeakMap();
|
|
7
|
+
function typesPrint(model) {
|
|
8
|
+
if (model.status === 'unavailable')
|
|
9
|
+
return '';
|
|
10
|
+
let print = typesPrinted.get(model.types);
|
|
11
|
+
if (print === undefined) {
|
|
12
|
+
print = hashed(JSON.stringify(model.types)).toString(36);
|
|
13
|
+
typesPrinted.set(model.types, print);
|
|
14
|
+
}
|
|
15
|
+
return print;
|
|
16
|
+
}
|
|
17
|
+
export function composedOf(composition) {
|
|
18
|
+
const { model, selection } = composition;
|
|
19
|
+
return {
|
|
20
|
+
composition,
|
|
21
|
+
fingerprint: JSON.stringify([
|
|
22
|
+
typesPrint(model),
|
|
23
|
+
selection === null ? null : [selection.roots, typesPrint(selection.model)],
|
|
24
|
+
]),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
6
27
|
export function selected(composition, path) {
|
|
7
28
|
return (composition.selection !== null &&
|
|
8
29
|
composition.selection.roots.some((root) => beneath(root, path)));
|
|
@@ -39,21 +60,6 @@ export function* documentsOf(collection) {
|
|
|
39
60
|
}
|
|
40
61
|
})();
|
|
41
62
|
}
|
|
42
|
-
export function* unreadable(text, paths = null) {
|
|
43
|
-
const named = paths ?? (yield* keysIn(text));
|
|
44
|
-
let least = null;
|
|
45
|
-
for (const path of named) {
|
|
46
|
-
const content = Object.hasOwn(text, path) ? text[path] : undefined;
|
|
47
|
-
if (content === undefined)
|
|
48
|
-
continue;
|
|
49
|
-
const read = parse(content, path);
|
|
50
|
-
if (!read.ok && (least === null || path < least.path)) {
|
|
51
|
-
least = { path, refused: { kind: 'refused', refusal: read.refusal } };
|
|
52
|
-
}
|
|
53
|
-
yield ROW_WEIGHT + content.length;
|
|
54
|
-
}
|
|
55
|
-
return least?.refused ?? null;
|
|
56
|
-
}
|
|
57
63
|
export function validRoot(root) {
|
|
58
64
|
return typeof root === 'string' && normalize(root) === root;
|
|
59
65
|
}
|
package/dist/compile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAOV,IAAI,
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAOV,IAAI,EAIJ,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;AAmtBjF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAqTjE,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"}
|