@agentshouse/mdruntime 0.1.0-cc5745cd9af96 → 0.1.0-ccbe92df1c4f6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +96 -78
- package/README.md +9 -8
- package/dist/adapter.d.ts +40 -32
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +4 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +13 -3
- 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 +24 -6
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +148 -82
- 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 +6 -16
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -94
- package/dist/change.d.ts +31 -1
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +10 -1
- package/dist/chat/house.d.ts +25 -0
- package/dist/chat/house.d.ts.map +1 -0
- package/dist/chat/house.js +38 -0
- package/dist/chat/input.d.ts +3 -1
- package/dist/chat/input.d.ts.map +1 -1
- package/dist/chat/input.js +11 -18
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +1 -1
- package/dist/chat/markdown.d.ts +1 -2
- package/dist/chat/markdown.d.ts.map +1 -1
- package/dist/chat/markdown.js +2 -19
- package/dist/chat/message.d.ts.map +1 -1
- package/dist/chat/message.js +63 -11
- package/dist/chat/messages.d.ts +12 -1
- package/dist/chat/messages.d.ts.map +1 -1
- package/dist/chat/messages.js +36 -13
- package/dist/chat/name.d.ts +1 -0
- package/dist/chat/name.d.ts.map +1 -1
- package/dist/chat/name.js +1 -1
- package/dist/chat/opened.d.ts +1 -0
- package/dist/chat/opened.d.ts.map +1 -1
- package/dist/chat/opened.js +2 -0
- package/dist/chat/overlay.d.ts.map +1 -1
- package/dist/chat/overlay.js +1 -5
- package/dist/chat/parts.d.ts +1 -0
- package/dist/chat/parts.d.ts.map +1 -1
- package/dist/chat/parts.js +3 -2
- package/dist/chat/provider.d.ts +7 -1
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +75 -78
- package/dist/chat/ready.d.ts +4 -1
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +7 -5
- package/dist/chat/room-file.d.ts +8 -0
- package/dist/chat/room-file.d.ts.map +1 -0
- package/dist/chat/room-file.js +72 -0
- package/dist/chat/style.d.ts.map +1 -1
- package/dist/chat/style.js +5 -0
- package/dist/chat.d.ts +1 -0
- package/dist/chat.d.ts.map +1 -1
- package/dist/client.d.ts +6 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +28 -2
- package/dist/collection.d.ts +6 -20
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +30 -352
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +721 -0
- package/dist/connection.d.ts +13 -8
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +2179 -817
- package/dist/conversation.d.ts +5 -3
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +84 -65
- 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 +3 -5
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +3 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +18 -24
- package/dist/file.d.ts +2 -10
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -120
- package/dist/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +368 -0
- package/dist/host.d.ts +4 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +16 -8
- 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 +12 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/live.d.ts +22 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +123 -0
- package/dist/memory.d.ts +1 -0
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +20 -15
- package/dist/messages.d.ts +28 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +90 -0
- 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 +12 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +84 -0
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +28 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +22 -0
- package/dist/overlay.d.ts +1 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +22 -148
- package/dist/query.d.ts +5 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +13 -1
- package/dist/reach.d.ts +5 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +149 -61
- package/dist/readiness.d.ts +19 -9
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +2 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +4 -2
- package/dist/recovery.d.ts +2 -2
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +8 -7
- package/dist/refresh.d.ts +15 -14
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +112 -70
- package/dist/replica.d.ts +57 -39
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +275 -195
- package/dist/room-draft.d.ts +3 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +21 -13
- package/dist/rows.d.ts +29 -31
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +113 -69
- package/dist/save.d.ts +49 -14
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +352 -98
- package/dist/search.d.ts +11 -43
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +0 -213
- package/dist/shared.d.ts +4 -3
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +67 -34
- package/dist/store.d.ts +87 -94
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +314 -720
- package/dist/stored.d.ts +145 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +567 -0
- package/dist/tables.d.ts +344 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +580 -0
- package/dist/turn.d.ts +1 -1
- package/dist/turn.d.ts.map +1 -1
- package/dist/turn.js +31 -20
- 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 +2 -6
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +30 -34
- package/dist/wire.d.ts +13 -1
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +4 -1
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +150 -0
- package/package.json +11 -5
- package/dist/read-side.d.ts +0 -27
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -826
package/dist/conversation.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConversationAction, ConversationAgents, ConversationEvent, ConversationMessage, ConversationStream, ProcessCommand, SessionOption, TurnContext } from './adapter.js';
|
|
2
2
|
import { type ChangeSet } from './change-set.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type ChosenFile } from './file.js';
|
|
4
4
|
import type { Open } from './open.js';
|
|
5
5
|
import { type CallResult, type Offline } from './outcome.js';
|
|
6
6
|
import type { DocumentResult, PendingResult } from './query.js';
|
|
@@ -33,7 +33,6 @@ export type RunningTurn = {
|
|
|
33
33
|
};
|
|
34
34
|
export type ChatDraft = {
|
|
35
35
|
text: string;
|
|
36
|
-
files: readonly ChatDraftFile[];
|
|
37
36
|
};
|
|
38
37
|
export type ConversationOptions = {
|
|
39
38
|
limit?: number;
|
|
@@ -66,6 +65,7 @@ export type ConversationSurface = {
|
|
|
66
65
|
read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
|
|
67
66
|
create(input: unknown): Promise<CallResult>;
|
|
68
67
|
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
68
|
+
attach(room: string, file: ChosenFile): Promise<CallResult | Offline>;
|
|
69
69
|
answer(conversation: string, answer: unknown): Promise<CallResult>;
|
|
70
70
|
interrupt(conversation: string): Promise<CallResult>;
|
|
71
71
|
kill(conversation: string): Promise<CallResult>;
|
|
@@ -79,12 +79,13 @@ export type ChatDraftSurface = {
|
|
|
79
79
|
};
|
|
80
80
|
export type ConversationDependencies = {
|
|
81
81
|
agents(): ConversationAgents | undefined;
|
|
82
|
-
documents(agents: ConversationAgents): Promise<DocumentResult | PendingResult>;
|
|
82
|
+
documents(agents: ConversationAgents, after: string | undefined): Promise<DocumentResult | PendingResult>;
|
|
83
83
|
call(name: ConversationAction, input: unknown): Promise<CallResult>;
|
|
84
84
|
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
85
85
|
stream(): ConversationStream | undefined;
|
|
86
86
|
publish(set: ChangeSet): void;
|
|
87
87
|
online(): boolean;
|
|
88
|
+
full(): boolean;
|
|
88
89
|
closed(): boolean;
|
|
89
90
|
unanswered(): void;
|
|
90
91
|
expired(operation: string): boolean;
|
|
@@ -112,6 +113,7 @@ export type ConversationStore = {
|
|
|
112
113
|
};
|
|
113
114
|
export declare function unheldView(conversation: string): ConversationView;
|
|
114
115
|
export declare const SESSION_STARTED = "Session started";
|
|
116
|
+
export declare const HISTORY_CONVERSATIONS = 64;
|
|
115
117
|
export declare function newChat(agent: string): string;
|
|
116
118
|
export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
|
|
117
119
|
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EAEjB,mBAAmB,EACnB,kBAAkB,EAElB,cAAc,EACd,aAAa,EACb,WAAW,EAEZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyB,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EAEjB,mBAAmB,EACnB,kBAAkB,EAElB,cAAc,EACd,aAAa,EACb,WAAW,EAEZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGxE,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAW,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAkB,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGlG,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC,CAAC;AAEpE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IACjD,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AiB,CAm4BzF"}
|
package/dist/conversation.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { conversationChangeSet } from './change-set.js';
|
|
2
2
|
import { runtimeError } from './failure.js';
|
|
3
|
+
import { refusedForSpace } from './durability.js';
|
|
3
4
|
import { declaredFile } from './file.js';
|
|
4
5
|
import { changeBatchIdentity, chatDraftRevision } from './identity.js';
|
|
5
6
|
import { OFFLINE } from './outcome.js';
|
|
@@ -40,14 +41,17 @@ export function unheldView(conversation) {
|
|
|
40
41
|
}
|
|
41
42
|
export const SESSION_STARTED = 'Session started';
|
|
42
43
|
const NEW_CHAT = 'new:';
|
|
44
|
+
export const HISTORY_CONVERSATIONS = 64;
|
|
43
45
|
export function newChat(agent) {
|
|
44
46
|
return `${NEW_CHAT}${agent}`;
|
|
45
47
|
}
|
|
46
48
|
function creationOf(input) {
|
|
47
49
|
if (typeof input !== 'object' || input === null)
|
|
48
50
|
return null;
|
|
49
|
-
const { agent_id: agent, operation_id: operation } = input;
|
|
50
|
-
return typeof agent === 'string' && typeof operation === 'string'
|
|
51
|
+
const { agent_id: agent, operation_id: operation, replaces, } = input;
|
|
52
|
+
return typeof agent === 'string' && typeof operation === 'string' && replaces === undefined
|
|
53
|
+
? { agent, operation }
|
|
54
|
+
: null;
|
|
51
55
|
}
|
|
52
56
|
function startedTurn(turn, operation) {
|
|
53
57
|
if (operation.op === 'begin')
|
|
@@ -207,8 +211,14 @@ function askedOf(options) {
|
|
|
207
211
|
return { limit: capped(limit), after, before: beforeOf(after), total: total === true };
|
|
208
212
|
}
|
|
209
213
|
const EXPIRED = { kind: 'rejected', code: 'expired', fields: {}, retryable: false };
|
|
214
|
+
const DURABLE_WRITE = {
|
|
215
|
+
kind: 'rejected',
|
|
216
|
+
code: 'durable-write',
|
|
217
|
+
fields: {},
|
|
218
|
+
retryable: true,
|
|
219
|
+
};
|
|
210
220
|
function unwritten(draft) {
|
|
211
|
-
return draft.text === ''
|
|
221
|
+
return draft.text === '';
|
|
212
222
|
}
|
|
213
223
|
function pending(draft) {
|
|
214
224
|
return {
|
|
@@ -224,10 +234,7 @@ function withSubmitted(draft, submitted) {
|
|
|
224
234
|
return submitted.length === 0 ? unsent : { ...unsent, submitted };
|
|
225
235
|
}
|
|
226
236
|
function prepended(draft, said) {
|
|
227
|
-
return {
|
|
228
|
-
text: [said.text, draft.text].filter((one) => one !== '').join('\n'),
|
|
229
|
-
files: [...said.files, ...draft.files],
|
|
230
|
-
};
|
|
237
|
+
return { text: [said.text, draft.text].filter((one) => one !== '').join('\n') };
|
|
231
238
|
}
|
|
232
239
|
function returned(draft, submission, others) {
|
|
233
240
|
return withSubmitted({
|
|
@@ -283,7 +290,7 @@ export function createConversationStore(deps) {
|
|
|
283
290
|
deliveryUnknown: [...facts.deliveryUnknown],
|
|
284
291
|
chatDraft: draft === undefined || unwritten(draft)
|
|
285
292
|
? null
|
|
286
|
-
: { text: draft.text,
|
|
293
|
+
: { text: draft.text, revision: draft.revision },
|
|
287
294
|
};
|
|
288
295
|
}
|
|
289
296
|
function emit(conversation) {
|
|
@@ -325,9 +332,6 @@ export function createConversationStore(deps) {
|
|
|
325
332
|
}
|
|
326
333
|
}
|
|
327
334
|
}
|
|
328
|
-
function changesOf(conversation, arriving) {
|
|
329
|
-
return arriving.map(({ identity, text }) => ({ conversation, identity, text }));
|
|
330
|
-
}
|
|
331
335
|
function stateOf(conversation) {
|
|
332
336
|
const facts = liveOf(conversation);
|
|
333
337
|
if (facts.questions.length > 0)
|
|
@@ -385,23 +389,30 @@ export function createConversationStore(deps) {
|
|
|
385
389
|
const declaration = deps.agents();
|
|
386
390
|
if (declaration === undefined)
|
|
387
391
|
return;
|
|
388
|
-
const held = await deps.documents(declaration);
|
|
389
|
-
if ('pending' in held)
|
|
390
|
-
return;
|
|
391
|
-
const { documents } = held;
|
|
392
392
|
const names = new Map();
|
|
393
393
|
const retired = new Set();
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
394
|
+
let covered = null;
|
|
395
|
+
for (let after;;) {
|
|
396
|
+
const read = await deps.documents(declaration, after);
|
|
397
|
+
if ('pending' in read)
|
|
398
|
+
return;
|
|
399
|
+
const coverage = JSON.stringify(read.coverage);
|
|
400
|
+
if (covered !== null && coverage !== covered)
|
|
401
|
+
return readAgents();
|
|
402
|
+
covered = coverage;
|
|
403
|
+
for (const document of read.documents) {
|
|
404
|
+
const identity = document.fields?.[declaration.identity];
|
|
405
|
+
const name = document.fields?.[declaration.name];
|
|
406
|
+
if (typeof identity !== 'string' || typeof name !== 'string')
|
|
407
|
+
continue;
|
|
408
|
+
names.set(identity, name);
|
|
409
|
+
const ended = declaration.retired === undefined ? null : document.fields?.[declaration.retired];
|
|
410
|
+
if (ended !== undefined && ended !== null)
|
|
411
|
+
retired.add(identity);
|
|
412
|
+
}
|
|
413
|
+
if (read.next === undefined)
|
|
414
|
+
break;
|
|
415
|
+
after = read.next;
|
|
405
416
|
}
|
|
406
417
|
const named = JSON.stringify([...names]) !== JSON.stringify([...agentNames]);
|
|
407
418
|
if (!named && JSON.stringify([...retired]) === JSON.stringify([...retiredAgents]))
|
|
@@ -479,12 +490,6 @@ export function createConversationStore(deps) {
|
|
|
479
490
|
}
|
|
480
491
|
async function remove(leaving) {
|
|
481
492
|
await deps.durably(async (local) => {
|
|
482
|
-
const removed = [];
|
|
483
|
-
for (const conversation of leaving) {
|
|
484
|
-
for (const identity of await local.messageIdentities(conversation)) {
|
|
485
|
-
removed.push({ conversation, identity, text: null });
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
493
|
await local.dropConversations(leaving);
|
|
489
494
|
const changed = [];
|
|
490
495
|
for (const conversation of leaving) {
|
|
@@ -501,7 +506,7 @@ export function createConversationStore(deps) {
|
|
|
501
506
|
await slide(local, conversation, null);
|
|
502
507
|
}
|
|
503
508
|
if (changed.length > 0)
|
|
504
|
-
deps.publish(conversationChangeSet(
|
|
509
|
+
deps.publish(conversationChangeSet(changed));
|
|
505
510
|
});
|
|
506
511
|
}
|
|
507
512
|
function gap(conversation) {
|
|
@@ -527,16 +532,17 @@ export function createConversationStore(deps) {
|
|
|
527
532
|
reads.set(conversation, message.position);
|
|
528
533
|
sealTurns(conversation, new Set([message.turn]));
|
|
529
534
|
await slide(local, conversation, [message]);
|
|
530
|
-
deps.publish(conversationChangeSet(
|
|
535
|
+
deps.publish(conversationChangeSet([conversation]));
|
|
531
536
|
});
|
|
532
537
|
}
|
|
533
538
|
async function readHistories(conversations, ended) {
|
|
534
539
|
const generations = new Map(conversations.map((one) => [one, gaps.get(one) ?? 0]));
|
|
535
|
-
let
|
|
540
|
+
let waiting = conversations.map((conversation) => ({
|
|
536
541
|
conversation,
|
|
537
542
|
after: reads.get(conversation) ?? undefined,
|
|
538
543
|
}));
|
|
539
|
-
while (
|
|
544
|
+
while (waiting.length > 0) {
|
|
545
|
+
const asking = waiting.slice(0, HISTORY_CONVERSATIONS);
|
|
540
546
|
const result = await deps.call('conversation.history', {
|
|
541
547
|
conversations: asking.map(({ conversation, after }) => ({
|
|
542
548
|
conversation,
|
|
@@ -560,7 +566,7 @@ export function createConversationStore(deps) {
|
|
|
560
566
|
if (!following.some((next) => next.conversation === conversation))
|
|
561
567
|
ended(conversation);
|
|
562
568
|
}
|
|
563
|
-
|
|
569
|
+
waiting = [...waiting.slice(HISTORY_CONVERSATIONS), ...following];
|
|
564
570
|
}
|
|
565
571
|
return null;
|
|
566
572
|
}
|
|
@@ -603,7 +609,7 @@ export function createConversationStore(deps) {
|
|
|
603
609
|
behind.delete(conversation);
|
|
604
610
|
await slide(local, conversation, arriving);
|
|
605
611
|
if (arriving.length > 0 || sealing || whole) {
|
|
606
|
-
deps.publish(conversationChangeSet(
|
|
612
|
+
deps.publish(conversationChangeSet([conversation]));
|
|
607
613
|
}
|
|
608
614
|
});
|
|
609
615
|
}
|
|
@@ -652,7 +658,14 @@ export function createConversationStore(deps) {
|
|
|
652
658
|
if (arriving === null)
|
|
653
659
|
return;
|
|
654
660
|
if (replicated.has(conversation)) {
|
|
655
|
-
|
|
661
|
+
if (deps.full()) {
|
|
662
|
+
gap(conversation);
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
void keep(conversation, arriving).catch((error) => {
|
|
666
|
+
if (refusedForSpace(error))
|
|
667
|
+
gap(conversation);
|
|
668
|
+
});
|
|
656
669
|
return;
|
|
657
670
|
}
|
|
658
671
|
if (sealTurns(conversation, new Set([arriving.turn])))
|
|
@@ -687,7 +700,6 @@ export function createConversationStore(deps) {
|
|
|
687
700
|
const blank = {
|
|
688
701
|
conversation: from,
|
|
689
702
|
text: '',
|
|
690
|
-
files: [],
|
|
691
703
|
revision: chatDraftRevision(),
|
|
692
704
|
};
|
|
693
705
|
const { moves: _answered, ...unsent } = held ?? blank;
|
|
@@ -697,7 +709,7 @@ export function createConversationStore(deps) {
|
|
|
697
709
|
drafts.set(from, left);
|
|
698
710
|
for (const one of taken)
|
|
699
711
|
drafts.set(to, one);
|
|
700
|
-
deps.publish(conversationChangeSet([
|
|
712
|
+
deps.publish(conversationChangeSet([from, to]));
|
|
701
713
|
});
|
|
702
714
|
}
|
|
703
715
|
function withDraft(conversation, next) {
|
|
@@ -706,7 +718,7 @@ export function createConversationStore(deps) {
|
|
|
706
718
|
if (following === undefined)
|
|
707
719
|
return;
|
|
708
720
|
await kept(local, conversation, following);
|
|
709
|
-
deps.publish(conversationChangeSet([
|
|
721
|
+
deps.publish(conversationChangeSet([conversation]));
|
|
710
722
|
});
|
|
711
723
|
}
|
|
712
724
|
async function submitted(conversation, operation, draft) {
|
|
@@ -718,17 +730,12 @@ export function createConversationStore(deps) {
|
|
|
718
730
|
if (submission !== undefined)
|
|
719
731
|
return undefined;
|
|
720
732
|
const said = draft ?? current;
|
|
721
|
-
submission = {
|
|
722
|
-
operation,
|
|
723
|
-
text: said?.text ?? '',
|
|
724
|
-
files: [...(said?.files ?? [])],
|
|
725
|
-
turn: null,
|
|
726
|
-
};
|
|
733
|
+
submission = { operation, text: said?.text ?? '', turn: null };
|
|
727
734
|
return {
|
|
728
735
|
conversation,
|
|
729
736
|
...(draft === undefined || current === undefined
|
|
730
|
-
? { text: '',
|
|
731
|
-
: { text: current.text,
|
|
737
|
+
? { text: '', revision: chatDraftRevision() }
|
|
738
|
+
: { text: current.text, revision: current.revision }),
|
|
732
739
|
submitted: [...(current?.submitted ?? []), submission],
|
|
733
740
|
};
|
|
734
741
|
});
|
|
@@ -746,10 +753,8 @@ export function createConversationStore(deps) {
|
|
|
746
753
|
const dispatch = {};
|
|
747
754
|
sending.set(submission.operation, dispatch);
|
|
748
755
|
try {
|
|
749
|
-
const files = await Promise.all(submission.files.map(async (file) => ({ ...(await declaredFile(file)), blob: file.blob })));
|
|
750
756
|
const result = await invoke('conversation.send', conversation, {
|
|
751
757
|
text: submission.text,
|
|
752
|
-
files,
|
|
753
758
|
operation_id: submission.operation,
|
|
754
759
|
});
|
|
755
760
|
if (result.kind === 'revoked-authorization')
|
|
@@ -807,8 +812,17 @@ export function createConversationStore(deps) {
|
|
|
807
812
|
return result;
|
|
808
813
|
},
|
|
809
814
|
async send(conversation, operation = changeBatchIdentity(), draft) {
|
|
815
|
+
if (deps.full())
|
|
816
|
+
return DURABLE_WRITE;
|
|
810
817
|
if (deps.online()) {
|
|
811
|
-
const
|
|
818
|
+
const held = await submitted(conversation, operation, draft).catch((error) => {
|
|
819
|
+
if (refusedForSpace(error))
|
|
820
|
+
return null;
|
|
821
|
+
throw error;
|
|
822
|
+
});
|
|
823
|
+
if (held === null)
|
|
824
|
+
return DURABLE_WRITE;
|
|
825
|
+
const { submission, earlier } = held;
|
|
812
826
|
if (!earlier || !deps.expired(operation))
|
|
813
827
|
return dispatched(conversation, submission);
|
|
814
828
|
await forgotten(conversation, submission);
|
|
@@ -817,10 +831,19 @@ export function createConversationStore(deps) {
|
|
|
817
831
|
if (draft !== undefined) {
|
|
818
832
|
await withDraft(conversation, (current) => current?.submitted?.some((one) => one.operation === operation) === true
|
|
819
833
|
? undefined
|
|
820
|
-
: returned(current ?? { conversation, text: '',
|
|
834
|
+
: returned(current ?? { conversation, text: '', revision: '' }, { operation, ...draft, turn: null }, current?.submitted ?? []));
|
|
821
835
|
}
|
|
822
836
|
return OFFLINE;
|
|
823
837
|
},
|
|
838
|
+
async attach(room, file) {
|
|
839
|
+
if (!deps.online())
|
|
840
|
+
return OFFLINE;
|
|
841
|
+
return deps.call('conversation.attach', {
|
|
842
|
+
room,
|
|
843
|
+
...(await declaredFile(file)),
|
|
844
|
+
blob: file.blob,
|
|
845
|
+
});
|
|
846
|
+
},
|
|
824
847
|
answer(conversation, answer) {
|
|
825
848
|
return invoke('conversation.answer', conversation, { answer });
|
|
826
849
|
},
|
|
@@ -851,7 +874,6 @@ export function createConversationStore(deps) {
|
|
|
851
874
|
return withDraft(conversation, (current) => ({
|
|
852
875
|
conversation,
|
|
853
876
|
text: draft.text,
|
|
854
|
-
files: [...draft.files],
|
|
855
877
|
revision,
|
|
856
878
|
...(current === undefined ? {} : pending(current)),
|
|
857
879
|
}));
|
|
@@ -859,9 +881,7 @@ export function createConversationStore(deps) {
|
|
|
859
881
|
prepend(conversation, draft) {
|
|
860
882
|
return withDraft(conversation, (current) => ({
|
|
861
883
|
conversation,
|
|
862
|
-
...(current === undefined
|
|
863
|
-
? { text: draft.text, files: [...draft.files] }
|
|
864
|
-
: prepended(current, draft)),
|
|
884
|
+
...(current === undefined ? { text: draft.text } : prepended(current, draft)),
|
|
865
885
|
revision: chatDraftRevision(),
|
|
866
886
|
...(current === undefined ? {} : pending(current)),
|
|
867
887
|
}));
|
|
@@ -869,13 +889,7 @@ export function createConversationStore(deps) {
|
|
|
869
889
|
discard(conversation) {
|
|
870
890
|
return withDraft(conversation, (current) => current === undefined
|
|
871
891
|
? undefined
|
|
872
|
-
: {
|
|
873
|
-
conversation,
|
|
874
|
-
text: '',
|
|
875
|
-
files: [],
|
|
876
|
-
revision: chatDraftRevision(),
|
|
877
|
-
...pending(current),
|
|
878
|
-
});
|
|
892
|
+
: { conversation, text: '', revision: chatDraftRevision(), ...pending(current) });
|
|
879
893
|
},
|
|
880
894
|
};
|
|
881
895
|
return {
|
|
@@ -915,6 +929,11 @@ export function createConversationStore(deps) {
|
|
|
915
929
|
await remove(leaving);
|
|
916
930
|
},
|
|
917
931
|
async catchUp(progress) {
|
|
932
|
+
if (deps.full()) {
|
|
933
|
+
if (behind.size > 0)
|
|
934
|
+
progress.complete = false;
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
918
937
|
const owed = (conversation) => behind.has(conversation) && replicated.has(conversation);
|
|
919
938
|
const read = async (conversations) => {
|
|
920
939
|
if (conversations.length === 0 || deps.closed())
|
package/dist/digest.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../src/digest.ts"],"names":[],"mappings":"AA0EA,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IAChC,GAAG,IAAI,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,MAAM,IAAI,MAAM,CAoC/B;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAMxD"}
|
package/dist/digest.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { FILE_PART_BYTES } from './tables.js';
|
|
2
|
+
const ROUNDS = new Uint32Array([
|
|
3
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
4
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
5
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
6
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
7
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
8
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
9
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
10
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
11
|
+
]);
|
|
12
|
+
const INITIAL = [
|
|
13
|
+
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
|
|
14
|
+
];
|
|
15
|
+
const BLOCK = 64;
|
|
16
|
+
function rotated(value, by) {
|
|
17
|
+
return (value >>> by) | (value << (32 - by));
|
|
18
|
+
}
|
|
19
|
+
function compressed(state, words, bytes, at) {
|
|
20
|
+
for (let index = 0; index < 16; index += 1) {
|
|
21
|
+
const from = at + index * 4;
|
|
22
|
+
words[index] =
|
|
23
|
+
(bytes[from] << 24) | (bytes[from + 1] << 16) | (bytes[from + 2] << 8) | bytes[from + 3];
|
|
24
|
+
}
|
|
25
|
+
for (let index = 16; index < 64; index += 1) {
|
|
26
|
+
const early = words[index - 15];
|
|
27
|
+
const late = words[index - 2];
|
|
28
|
+
const lower = rotated(early, 7) ^ rotated(early, 18) ^ (early >>> 3);
|
|
29
|
+
const upper = rotated(late, 17) ^ rotated(late, 19) ^ (late >>> 10);
|
|
30
|
+
words[index] = (words[index - 16] + lower + words[index - 7] + upper) | 0;
|
|
31
|
+
}
|
|
32
|
+
let a = state[0];
|
|
33
|
+
let b = state[1];
|
|
34
|
+
let c = state[2];
|
|
35
|
+
let d = state[3];
|
|
36
|
+
let e = state[4];
|
|
37
|
+
let f = state[5];
|
|
38
|
+
let g = state[6];
|
|
39
|
+
let h = state[7];
|
|
40
|
+
for (let index = 0; index < 64; index += 1) {
|
|
41
|
+
const chosen = (e & f) ^ (~e & g);
|
|
42
|
+
const first = (h +
|
|
43
|
+
(rotated(e, 6) ^ rotated(e, 11) ^ rotated(e, 25)) +
|
|
44
|
+
chosen +
|
|
45
|
+
ROUNDS[index] +
|
|
46
|
+
words[index]) |
|
|
47
|
+
0;
|
|
48
|
+
const second = ((rotated(a, 2) ^ rotated(a, 13) ^ rotated(a, 22)) + ((a & b) ^ (a & c) ^ (b & c))) | 0;
|
|
49
|
+
h = g;
|
|
50
|
+
g = f;
|
|
51
|
+
f = e;
|
|
52
|
+
e = (d + first) | 0;
|
|
53
|
+
d = c;
|
|
54
|
+
c = b;
|
|
55
|
+
b = a;
|
|
56
|
+
a = (first + second) | 0;
|
|
57
|
+
}
|
|
58
|
+
state[0] += a;
|
|
59
|
+
state[1] += b;
|
|
60
|
+
state[2] += c;
|
|
61
|
+
state[3] += d;
|
|
62
|
+
state[4] += e;
|
|
63
|
+
state[5] += f;
|
|
64
|
+
state[6] += g;
|
|
65
|
+
state[7] += h;
|
|
66
|
+
}
|
|
67
|
+
export function digest() {
|
|
68
|
+
const state = new Uint32Array(INITIAL);
|
|
69
|
+
const words = new Uint32Array(64);
|
|
70
|
+
const pending = new Uint8Array(BLOCK);
|
|
71
|
+
let held = 0;
|
|
72
|
+
let size = 0;
|
|
73
|
+
return {
|
|
74
|
+
update(bytes) {
|
|
75
|
+
size += bytes.length;
|
|
76
|
+
let from = 0;
|
|
77
|
+
if (held > 0) {
|
|
78
|
+
const taken = Math.min(BLOCK - held, bytes.length);
|
|
79
|
+
pending.set(bytes.subarray(0, taken), held);
|
|
80
|
+
held += taken;
|
|
81
|
+
from = taken;
|
|
82
|
+
if (held < BLOCK)
|
|
83
|
+
return;
|
|
84
|
+
compressed(state, words, pending, 0);
|
|
85
|
+
held = 0;
|
|
86
|
+
}
|
|
87
|
+
for (; from + BLOCK <= bytes.length; from += BLOCK)
|
|
88
|
+
compressed(state, words, bytes, from);
|
|
89
|
+
pending.set(bytes.subarray(from), 0);
|
|
90
|
+
held = bytes.length - from;
|
|
91
|
+
},
|
|
92
|
+
hex() {
|
|
93
|
+
const bits = size * 8;
|
|
94
|
+
const tail = new Uint8Array(held < 56 ? BLOCK : BLOCK * 2);
|
|
95
|
+
tail.set(pending.subarray(0, held));
|
|
96
|
+
tail[held] = 0x80;
|
|
97
|
+
const length = new DataView(tail.buffer, tail.length - 8);
|
|
98
|
+
length.setUint32(0, Math.floor(bits / 0x1_0000_0000));
|
|
99
|
+
length.setUint32(4, bits >>> 0);
|
|
100
|
+
const final = new Uint32Array(state);
|
|
101
|
+
for (let from = 0; from < tail.length; from += BLOCK)
|
|
102
|
+
compressed(final, words, tail, from);
|
|
103
|
+
return [...final].map((word) => word.toString(16).padStart(8, '0')).join('');
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export async function sha256(blob) {
|
|
108
|
+
const hashed = digest();
|
|
109
|
+
for (let at = 0; at < blob.size; at += FILE_PART_BYTES) {
|
|
110
|
+
hashed.update(new Uint8Array(await blob.slice(at, at + FILE_PART_BYTES).arrayBuffer()));
|
|
111
|
+
}
|
|
112
|
+
return hashed.hex();
|
|
113
|
+
}
|
package/dist/durability.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import type { Persistence } from './readiness.js';
|
|
2
|
-
export type StorageEstimate = {
|
|
3
|
-
readonly usage: number;
|
|
4
|
-
readonly quota: number;
|
|
5
|
-
};
|
|
6
2
|
export type RuntimeShell = {
|
|
7
3
|
persistence: Persistence;
|
|
8
4
|
generation: string | null;
|
|
5
|
+
onScreen: boolean;
|
|
9
6
|
keepGeneration(value: string): void | Promise<void>;
|
|
10
7
|
dropGeneration(): void | Promise<void>;
|
|
11
|
-
|
|
8
|
+
cleanUp?(): Promise<number>;
|
|
12
9
|
};
|
|
10
|
+
export declare function refusedForSpace(error: unknown): boolean;
|
|
13
11
|
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
|
14
12
|
export declare function nextGeneration(stored: string | null, reported: string | null): string;
|
|
15
13
|
//# sourceMappingURL=durability.d.ts.map
|
package/dist/durability.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,cAAc,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAG/F;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGrF"}
|
package/dist/durability.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
const STORAGE_LOSS_CODE = 'storage-loss';
|
|
2
|
+
export function refusedForSpace(error) {
|
|
3
|
+
return (typeof error === 'object' &&
|
|
4
|
+
error !== null &&
|
|
5
|
+
error.name === 'QuotaExceededError');
|
|
6
|
+
}
|
|
2
7
|
export function detectStorageLoss(stored, reported) {
|
|
3
8
|
if (reported === null || reported === stored)
|
|
4
9
|
return null;
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { VerifiedModel } from '@agentshouse/mdmodel';
|
|
1
2
|
import { type QueryRows } from './query.js';
|
|
3
|
+
import type { Connection } from './tables.js';
|
|
2
4
|
export { QueryError } from './query.js';
|
|
3
5
|
export type EntryRoom = {
|
|
4
6
|
locator: string;
|
|
@@ -13,5 +15,5 @@ export declare function entryRefusal(template: unknown): string | null;
|
|
|
13
15
|
export type EntryScope = {
|
|
14
16
|
results(queries: Readonly<Record<string, unknown>>): Promise<Record<string, QueryRows>>;
|
|
15
17
|
};
|
|
16
|
-
export declare function entryScope(rooms: readonly EntryRoom[]): EntryScope;
|
|
18
|
+
export declare function entryScope(rooms: readonly EntryRoom[], roomTypes: VerifiedModel, connection: Connection): EntryScope;
|
|
17
19
|
//# sourceMappingURL=entry.d.ts.map
|
package/dist/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAK1D,OAAO,EAML,KAAK,SAAS,EAEf,MAAM,YAAY,CAAC;AAEpB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