@agentshouse/mdruntime 0.1.0-cc7671cc3f267 → 0.1.0-cc848d4e7543e
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/actions.d.ts.map +1 -1
- package/dist/actions.js +10 -2
- package/dist/adapter.d.ts +27 -7
- package/dist/adapter.d.ts.map +1 -1
- package/dist/binary.d.ts +4 -0
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +9 -2
- package/dist/chat-types.js +2 -2
- package/dist/client.d.ts +5 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -6
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +3 -3
- package/dist/conversation-live.d.ts +2 -3
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +2 -2
- package/dist/conversation.d.ts +2 -3
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +29 -17
- package/dist/declaration.js +1 -1
- package/dist/discovery.d.ts +1 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +21 -3
- package/dist/entry.d.ts +9 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +45 -27
- package/dist/host.d.ts +6 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +23 -6
- package/dist/house-query.d.ts +7 -10
- package/dist/house-query.d.ts.map +1 -1
- package/dist/house-query.js +20 -7
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +21 -13
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +2 -0
- package/dist/media.d.ts +5 -6
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +77 -21
- package/dist/messages.d.ts +6 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +10 -1
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +18 -2
- package/dist/outcome.d.ts +11 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/parts.d.ts +3 -1
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -7
- package/dist/preparation.d.ts +10 -5
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +78 -48
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +3 -1
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +2 -1
- package/dist/reach.d.ts +9 -9
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +42 -18
- package/dist/readiness.d.ts +14 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +16 -7
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +5 -2
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +6 -4
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +22 -2
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +17 -4
- package/dist/socket/session.d.ts +4 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/store/records.d.ts +4 -1
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +2 -0
- package/dist/store.d.ts +2 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +4 -1
- package/dist/stored.d.ts +8 -1
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +108 -23
- package/dist/surface.d.ts +2 -2
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +5 -4
- package/dist/sync.d.ts +2 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +25 -17
- package/dist/wire.d.ts +4 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +5 -5
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -8,9 +8,11 @@ export { FIGURES_DAY_MS } from './figures.js';
|
|
|
8
8
|
export { departure } from './change.js';
|
|
9
9
|
export { definitionsIn, selected } from './collection.js';
|
|
10
10
|
export { lineEnded, partsAfter, partsChanges } from './room-draft.js';
|
|
11
|
-
export { cutName, nameFrom
|
|
12
|
-
export { HISTORY_CONVERSATIONS } from './conversation.js';
|
|
11
|
+
export { cutName, nameFrom } from './name.js';
|
|
12
|
+
export { HISTORY_CONVERSATIONS, newChat } from './conversation.js';
|
|
13
13
|
export { contextFigure } from './context.js';
|
|
14
|
+
export { runningWords } from './running.js';
|
|
15
|
+
export { turnLine, WORKING } from './parts.js';
|
|
14
16
|
export { changeBatchIdentity } from './identity.js';
|
|
15
17
|
export { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
16
18
|
export { authoredAt, covered } from './paths.js';
|
package/dist/lifecycle.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export declare function scheduleCurrency(runtime: Runtime): void;
|
|
|
3
3
|
export declare function spaceFreed(runtime: Runtime): void;
|
|
4
4
|
export declare function close({ store, socket, presence, conversations, recovery, liveQueries, figures, }: Runtime): void;
|
|
5
5
|
export declare function stop(runtime: Runtime): Promise<void>;
|
|
6
|
-
export declare function start(runtime: Runtime, signal: AbortSignal | undefined): void;
|
|
6
|
+
export declare function start(runtime: Runtime, signal: AbortSignal | undefined, onNeed: boolean): void;
|
|
7
7
|
//# sourceMappingURL=lifecycle.d.ts.map
|
package/dist/lifecycle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AA6O5C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,QAOhD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,QAQ1C;AAED,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,WAAW,EACX,OAAO,GACR,EAAE,OAAO,QAST;AAED,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,iBAS1C;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,QAwCvF"}
|
package/dist/lifecycle.js
CHANGED
|
@@ -16,9 +16,11 @@ function closing(runtime, opened) {
|
|
|
16
16
|
return socket.lanes.task(OPENING_LANE, async (live) => {
|
|
17
17
|
if (!live())
|
|
18
18
|
return;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if (store.needed()) {
|
|
20
|
+
const local = await store.open();
|
|
21
|
+
if (!opened && !socket.isOpen())
|
|
22
|
+
await cachedModels(runtime, local);
|
|
23
|
+
}
|
|
22
24
|
await rest(runtime, null, live);
|
|
23
25
|
});
|
|
24
26
|
}
|
|
@@ -96,6 +98,16 @@ function caughtUpRooms(runtime, expired) {
|
|
|
96
98
|
session.set({ underway: null });
|
|
97
99
|
socket.named();
|
|
98
100
|
const cycle = progress ?? { complete: true, reachable: true };
|
|
101
|
+
if (!store.needed()) {
|
|
102
|
+
return socket.lanes.task(OPENING_LANE, async (live) => {
|
|
103
|
+
if (!live())
|
|
104
|
+
return;
|
|
105
|
+
if (progress === null)
|
|
106
|
+
await rest(runtime, cycle, live);
|
|
107
|
+
else
|
|
108
|
+
await finishOpening(runtime, progress, live);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
99
111
|
replaced(store, expired);
|
|
100
112
|
const among = progress === null ? expired : null;
|
|
101
113
|
const installing = store.installs.underway(among);
|
|
@@ -223,7 +235,7 @@ export async function stop(runtime) {
|
|
|
223
235
|
await store.written();
|
|
224
236
|
close(runtime);
|
|
225
237
|
}
|
|
226
|
-
export function start(runtime, signal) {
|
|
238
|
+
export function start(runtime, signal, onNeed) {
|
|
227
239
|
const { store, socket, presence, conversations, lastAnswers, recovery } = runtime;
|
|
228
240
|
const closeRuntime = () => close(runtime);
|
|
229
241
|
socket.observeServiceMode((mode) => signalled(runtime, mode));
|
|
@@ -267,16 +279,12 @@ export function start(runtime, signal) {
|
|
|
267
279
|
else
|
|
268
280
|
void applyRoom(runtime, event);
|
|
269
281
|
});
|
|
270
|
-
|
|
271
|
-
.open()
|
|
272
|
-
.then(async (local) => {
|
|
273
|
-
if ((await local.facts()).capabilities.length > 0)
|
|
282
|
+
if (!onNeed) {
|
|
283
|
+
void store.open().catch((error) => {
|
|
274
284
|
socket.readyFromStore();
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
uncaught(error);
|
|
279
|
-
});
|
|
285
|
+
uncaught(error);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
280
288
|
if (!socket.streamed)
|
|
281
289
|
void runtime.discover();
|
|
282
290
|
}
|
package/dist/locks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locks.d.ts","sourceRoot":"","sources":["../src/locks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,wBAAsB,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE5F;AAED,wBAAsB,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"locks.d.ts","sourceRoot":"","sources":["../src/locks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,wBAAsB,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE5F;AAED,wBAAsB,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAI1F;AAED,wBAAsB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,iBAKzE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,QAU9C;AAED,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAE7E"}
|
package/dist/locks.js
CHANGED
|
@@ -4,6 +4,8 @@ export async function locked({ store, presence }, locator) {
|
|
|
4
4
|
return presence.locked(locator, async () => (await store.open()).offline(locator));
|
|
5
5
|
}
|
|
6
6
|
export async function lockedRooms({ store, presence }) {
|
|
7
|
+
if (!store.needed())
|
|
8
|
+
return [];
|
|
7
9
|
const { rooms, locking } = await store.covering();
|
|
8
10
|
return presence.lockedAmong(rooms, locking);
|
|
9
11
|
}
|
package/dist/media.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import type { MdRuntimeClient } from './client.js';
|
|
2
|
-
import { type DownloadAnswer
|
|
2
|
+
import { type DownloadAnswer } from './outcome.js';
|
|
3
3
|
export declare const ROOM_MEDIA = "room-media";
|
|
4
4
|
export declare const KEYED_MEDIA = "ahc-attachment";
|
|
5
5
|
export declare const MEDIA = "room-media, ahc-attachment";
|
|
6
6
|
export declare const DIAGRAM = "md-diagram";
|
|
7
7
|
export declare const VIEWING = "ahc-viewer";
|
|
8
|
-
type
|
|
9
|
-
export type MediaAt = {
|
|
10
|
-
readonly link: string;
|
|
11
|
-
} | {
|
|
8
|
+
type RoomAt = {
|
|
12
9
|
readonly room: string;
|
|
13
10
|
readonly path: string;
|
|
14
11
|
readonly revision: string | undefined;
|
|
15
12
|
};
|
|
16
|
-
export
|
|
13
|
+
export type MediaAt = {
|
|
14
|
+
readonly link: string;
|
|
15
|
+
} | RoomAt;
|
|
17
16
|
export declare function mediaAt(media: Element): MediaAt | null;
|
|
18
17
|
export declare function mediaTag(at: MediaAt): string;
|
|
19
18
|
export declare function downloadAt(client: MdRuntimeClient, at: MediaAt): Promise<DownloadAnswer>;
|
package/dist/media.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAqB,KAAK,cAAc,EAAoB,MAAM,cAAc,CAAC;AAGxF,eAAO,MAAM,UAAU,eAAe,CAAC;AAEvC,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAE5C,eAAO,MAAM,KAAK,+BAAkC,CAAC;AAMrD,eAAO,MAAM,OAAO,eAAe,CAAC;AAEpC,eAAO,MAAM,OAAO,eAAe,CAAC;AAkCpC,KAAK,MAAM,GAAG;IACZ,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC;AAEzD,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAUtD;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,CAE5C;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAIxF;AAsDD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAElD;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAMlD;AA0CD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAEtE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,GAAG,IAAI,CA+NxF"}
|
package/dist/media.js
CHANGED
|
@@ -25,11 +25,6 @@ const STYLE = `:host{display:block}
|
|
|
25
25
|
[part=box]>slot{display:flex;align-items:center;justify-content:center;width:100%;height:100%;text-align:center}
|
|
26
26
|
[part=play]{position:absolute;top:50%;left:50%;width:56px;height:56px;margin:-28px 0 0 -28px;border-radius:50%;background:rgb(0 0 0/.6);pointer-events:none}
|
|
27
27
|
[part=play]::before{content:"";position:absolute;top:18px;left:22px;border-style:solid;border-width:10px 0 10px 16px;border-color:transparent transparent transparent #fff}`;
|
|
28
|
-
const shows = new WeakMap();
|
|
29
|
-
export function shownBy(show, client) {
|
|
30
|
-
shows.set(client, show);
|
|
31
|
-
return client;
|
|
32
|
-
}
|
|
33
28
|
export function mediaAt(media) {
|
|
34
29
|
if (media.localName === KEYED_MEDIA) {
|
|
35
30
|
const link = media.getAttribute('link');
|
|
@@ -52,17 +47,37 @@ export function downloadAt(client, at) {
|
|
|
52
47
|
function shownAt(client, at) {
|
|
53
48
|
if (at === null)
|
|
54
49
|
return null;
|
|
55
|
-
if ('link' in at)
|
|
56
|
-
return client.conversation
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
if ('link' in at) {
|
|
51
|
+
return client.conversation
|
|
52
|
+
.attachment(at.link)
|
|
53
|
+
.then((shown) => (shown.kind === 'link' ? { ...shown, copies: [] } : shown));
|
|
54
|
+
}
|
|
55
|
+
return client.binaryFile.show(at.room, at.path, at.revision);
|
|
59
56
|
}
|
|
60
57
|
function ratioOf(width, height) {
|
|
61
58
|
const across = Number(width);
|
|
62
59
|
const down = Number(height);
|
|
63
60
|
return Number.isFinite(across) && Number.isFinite(down) && across > 0 && down > 0
|
|
64
61
|
? `${across} / ${down}`
|
|
65
|
-
:
|
|
62
|
+
: null;
|
|
63
|
+
}
|
|
64
|
+
function ownRatio(found, at) {
|
|
65
|
+
const record = 'documents' in found ? found.documents[0]?.binaryFile : undefined;
|
|
66
|
+
if (record?.state !== 'accepted' ||
|
|
67
|
+
(at.revision !== undefined && record.revision !== at.revision)) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return ratioOf(record.width, record.height);
|
|
71
|
+
}
|
|
72
|
+
function offered(drawn, box, copies) {
|
|
73
|
+
if (copies.length === 0) {
|
|
74
|
+
drawn.removeAttribute('srcset');
|
|
75
|
+
drawn.removeAttribute('sizes');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const across = Math.ceil(box.getBoundingClientRect().width);
|
|
79
|
+
drawn.sizes = across > 0 ? `${across}px` : '100vw';
|
|
80
|
+
drawn.srcset = copies.map(({ url, width }) => `${url} ${width}w`).join(', ');
|
|
66
81
|
}
|
|
67
82
|
function refusedForGood(shown) {
|
|
68
83
|
if (shown.kind === 'revoked-authorization')
|
|
@@ -88,14 +103,25 @@ export function viewable(element) {
|
|
|
88
103
|
return false;
|
|
89
104
|
return (rendered(element) || (element.shadowRoot?.querySelector('[part=box] > video') ?? null) !== null);
|
|
90
105
|
}
|
|
91
|
-
function viewed(client, opener, alone) {
|
|
92
|
-
void loaded(client.buildFile, VIEWER).then((file) =>
|
|
93
|
-
opener
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
function viewed(client, opener, alone, taken = () => true) {
|
|
107
|
+
void loaded(client.buildFile, VIEWER).then((file) => {
|
|
108
|
+
if (!opener.isConnected || !taken())
|
|
109
|
+
return;
|
|
110
|
+
file?.openViewer({
|
|
111
|
+
opener,
|
|
112
|
+
alone,
|
|
113
|
+
download: (at) => void downloadAt(client, at),
|
|
114
|
+
});
|
|
115
|
+
});
|
|
97
116
|
}
|
|
98
117
|
function pressed(client) {
|
|
118
|
+
let latest = null;
|
|
119
|
+
const taken = (opener) => () => {
|
|
120
|
+
if (latest !== opener)
|
|
121
|
+
return false;
|
|
122
|
+
latest = null;
|
|
123
|
+
return true;
|
|
124
|
+
};
|
|
99
125
|
return (event) => {
|
|
100
126
|
if (event.defaultPrevented || event.detail > 1)
|
|
101
127
|
return;
|
|
@@ -104,7 +130,8 @@ function pressed(client) {
|
|
|
104
130
|
continue;
|
|
105
131
|
if (viewable(node)) {
|
|
106
132
|
event.preventDefault();
|
|
107
|
-
|
|
133
|
+
latest = node;
|
|
134
|
+
void client.then((one) => viewed(one, node, !rendered(node), taken(node)));
|
|
108
135
|
return;
|
|
109
136
|
}
|
|
110
137
|
if (node.matches(PRESSED_ELSEWHERE))
|
|
@@ -133,6 +160,8 @@ export function defineRoomMedia(client) {
|
|
|
133
160
|
#drawn = null;
|
|
134
161
|
#loaded = false;
|
|
135
162
|
#relinked = 0;
|
|
163
|
+
#own = null;
|
|
164
|
+
#measuring = null;
|
|
136
165
|
constructor() {
|
|
137
166
|
super();
|
|
138
167
|
this.#box.setAttribute('part', 'box');
|
|
@@ -149,17 +178,21 @@ export function defineRoomMedia(client) {
|
|
|
149
178
|
void this.#load();
|
|
150
179
|
}, { rootMargin: NEARING });
|
|
151
180
|
this.#watching.observe(this);
|
|
181
|
+
this.#measure();
|
|
152
182
|
}
|
|
153
183
|
disconnectedCallback() {
|
|
154
184
|
this.#watching?.disconnect();
|
|
155
185
|
this.#watching = null;
|
|
156
186
|
this.#near = false;
|
|
157
187
|
this.#asked += 1;
|
|
188
|
+
this.#measure();
|
|
158
189
|
this.#show(null);
|
|
159
190
|
}
|
|
160
191
|
attributeChangedCallback(name, before, after) {
|
|
161
192
|
if (before === after)
|
|
162
193
|
return;
|
|
194
|
+
if (LOADING.has(name))
|
|
195
|
+
this.#measure();
|
|
163
196
|
this.#shape();
|
|
164
197
|
if (this.isConnected)
|
|
165
198
|
this.#label();
|
|
@@ -169,7 +202,28 @@ export function defineRoomMedia(client) {
|
|
|
169
202
|
void this.#load();
|
|
170
203
|
}
|
|
171
204
|
#shape() {
|
|
172
|
-
this.#box.style.aspectRatio =
|
|
205
|
+
this.#box.style.aspectRatio =
|
|
206
|
+
ratioOf(this.getAttribute('width'), this.getAttribute('height')) ?? this.#own ?? SHAPE;
|
|
207
|
+
}
|
|
208
|
+
#measure() {
|
|
209
|
+
void this.#measuring?.then((measured) => measured.close(), () => undefined);
|
|
210
|
+
this.#measuring = null;
|
|
211
|
+
this.#own = null;
|
|
212
|
+
const at = mediaAt(this);
|
|
213
|
+
if (this.#watching === null || at === null || 'link' in at)
|
|
214
|
+
return;
|
|
215
|
+
const measuring = connected.then((one) => one.observe('query', { rooms: [at.room], paths: [at.path], select: {} }));
|
|
216
|
+
this.#measuring = measuring;
|
|
217
|
+
void measuring.then((measured) => {
|
|
218
|
+
const heard = () => {
|
|
219
|
+
if (this.#measuring !== measuring)
|
|
220
|
+
return;
|
|
221
|
+
this.#own = ownRatio(measured.current(), at);
|
|
222
|
+
this.#shape();
|
|
223
|
+
};
|
|
224
|
+
measured.subscribe(heard);
|
|
225
|
+
heard();
|
|
226
|
+
}, () => undefined);
|
|
173
227
|
}
|
|
174
228
|
#label() {
|
|
175
229
|
const alt = this.getAttribute('alt') ?? '';
|
|
@@ -193,7 +247,7 @@ export function defineRoomMedia(client) {
|
|
|
193
247
|
if (asked !== this.#asked)
|
|
194
248
|
return;
|
|
195
249
|
if (shown?.kind === 'link') {
|
|
196
|
-
this.#draw({ url: shown.url, copy: false }, shown.mediaType);
|
|
250
|
+
this.#draw({ url: shown.url, copy: false }, shown.mediaType, shown.copies);
|
|
197
251
|
return;
|
|
198
252
|
}
|
|
199
253
|
if (shown?.kind !== 'binary') {
|
|
@@ -209,7 +263,7 @@ export function defineRoomMedia(client) {
|
|
|
209
263
|
if (copy === null)
|
|
210
264
|
this.#unshown(asked);
|
|
211
265
|
else
|
|
212
|
-
this.#draw({ url: URL.createObjectURL(copy), copy: true }, shown.mediaType);
|
|
266
|
+
this.#draw({ url: URL.createObjectURL(copy), copy: true }, shown.mediaType, []);
|
|
213
267
|
}
|
|
214
268
|
#unshown(asked) {
|
|
215
269
|
this.#unreadable();
|
|
@@ -235,7 +289,7 @@ export function defineRoomMedia(client) {
|
|
|
235
289
|
#unreadable() {
|
|
236
290
|
this.#show(null, this.#fallback);
|
|
237
291
|
}
|
|
238
|
-
#draw(shown, mediaType) {
|
|
292
|
+
#draw(shown, mediaType, copies) {
|
|
239
293
|
const tag = drawnFor(mediaType);
|
|
240
294
|
if (tag === null) {
|
|
241
295
|
if (shown.copy)
|
|
@@ -267,6 +321,8 @@ export function defineRoomMedia(client) {
|
|
|
267
321
|
}
|
|
268
322
|
this.#drawn = drawn;
|
|
269
323
|
this.#show(shown, drawn);
|
|
324
|
+
if (drawn instanceof HTMLImageElement)
|
|
325
|
+
offered(drawn, this.#box, copies);
|
|
270
326
|
drawn.src = shown.url;
|
|
271
327
|
}
|
|
272
328
|
#failed(drawn) {
|
package/dist/messages.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { SessionState } from '@agentshouse/session-content';
|
|
1
2
|
import type { AcceptedMessage } from './adapter.js';
|
|
2
3
|
import type { Connection } from './tables.js';
|
|
3
4
|
export declare const MESSAGE_TABLES: readonly string[];
|
|
4
|
-
export declare const ROWS = "WITH chosen AS (\n SELECT listed.value AS conversation,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'assistant' ORDER BY position DESC, identity DESC LIMIT 1) AS answer,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND text <> '' ORDER BY position DESC, identity DESC LIMIT 1) AS said,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' ORDER BY position, identity LIMIT 1) AS opened,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' AND json_extract(message, '$.waiting') = 1 ORDER BY position, identity LIMIT 1) AS asking\n FROM json_each(?) AS listed\n )\n SELECT chosen.conversation AS conversation,\n substr(said.text, 1, 512) AS said_text,\n json_extract(said.message, '$.role') AS said_role,\n json_extract(said.message, '$.accepted_at') AS said_at,\n answer.turn AS answered,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n (SELECT value FROM conversation_facts WHERE conversation = chosen.conversation AND name = 'openedTurn') AS opened_turn,\n json_extract(opened.message, '$.source') AS opened_source,\n json_extract(opened.message, '$.sender') AS opened_sender,\n asking.identity AS asking_identity,\n asking.text AS asking_text,\n json_extract(asking.message, '$.accepted_at') AS asking_at,\n json_extract(asking.message, '$.source') AS asking_source,\n json_extract(asking.message, '$.sender') AS asking_sender\n FROM chosen\n LEFT JOIN conversation_messages said ON said.id = chosen.said\n LEFT JOIN conversation_messages answer ON answer.id = chosen.answer\n LEFT JOIN conversation_messages opened ON opened.id = chosen.opened\n LEFT JOIN conversation_messages asking ON asking.id = chosen.asking";
|
|
5
|
+
export declare const ROWS = "WITH chosen AS (\n SELECT listed.value AS conversation,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'assistant' ORDER BY position DESC, identity DESC LIMIT 1) AS answer,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND text <> '' ORDER BY position DESC, identity DESC LIMIT 1) AS said,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' ORDER BY position, identity LIMIT 1) AS opened,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' AND json_extract(message, '$.waiting') = 1 ORDER BY position, identity LIMIT 1) AS asking\n FROM json_each(?) AS listed\n )\n SELECT chosen.conversation AS conversation,\n substr(said.text, 1, 512) AS said_text,\n json_extract(said.message, '$.role') AS said_role,\n json_extract(said.message, '$.accepted_at') AS said_at,\n answer.turn AS answered,\n json_extract(answer.message, '$.content.state') AS saved_state,\n json_extract(answer.message, '$.accepted_at') AS saved_at,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n COALESCE(\n (SELECT value FROM conversation_facts WHERE conversation = chosen.conversation AND name = 'openedTurn'),\n CASE WHEN julianday(json_extract(answer.message, '$.accepted_at')) < (SELECT julianday(json_extract(value, '$')) FROM replica_facts WHERE name = 'readUntil') THEN answer.turn END\n ) AS opened_turn,\n json_extract(opened.message, '$.source') AS opened_source,\n json_extract(opened.message, '$.sender') AS opened_sender,\n asking.identity AS asking_identity,\n asking.text AS asking_text,\n json_extract(asking.message, '$.accepted_at') AS asking_at,\n json_extract(asking.message, '$.source') AS asking_source,\n json_extract(asking.message, '$.sender') AS asking_sender\n FROM chosen\n LEFT JOIN conversation_messages said ON said.id = chosen.said\n LEFT JOIN conversation_messages answer ON answer.id = chosen.answer\n LEFT JOIN conversation_messages opened ON opened.id = chosen.opened\n LEFT JOIN conversation_messages asking ON asking.id = chosen.asking";
|
|
5
6
|
export type HeldConversation = {
|
|
6
7
|
readonly conversation: string;
|
|
7
8
|
readonly read: string | null | undefined;
|
|
@@ -23,6 +24,10 @@ export type HeldRow = {
|
|
|
23
24
|
readonly at: string | null;
|
|
24
25
|
} | null;
|
|
25
26
|
readonly answered: string | null;
|
|
27
|
+
readonly saved: {
|
|
28
|
+
readonly state: SessionState;
|
|
29
|
+
readonly at: string;
|
|
30
|
+
} | null;
|
|
26
31
|
readonly openedTurn: string | null;
|
|
27
32
|
readonly failure: string | null;
|
|
28
33
|
readonly opened: HeldSource | null;
|
package/dist/messages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAM1D,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAQ3C,CAAC;
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAM1D,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAQ3C,CAAC;AAUF,eAAO,MAAM,IAAI,wvEA+BqD,CAAC;AAEvE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAE7F,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAEtF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;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 1';
|
|
17
17
|
const OLDEST_FIRST = 'ORDER BY position, identity LIMIT 1';
|
|
18
18
|
const OF_THE_ROW = 'SELECT id FROM conversation_messages WHERE conversation = listed.value';
|
|
19
|
+
const READ_UNTIL = `(SELECT julianday(json_extract(value, '$')) FROM replica_facts WHERE name = 'readUntil')`;
|
|
19
20
|
export const ROWS = `WITH chosen AS (
|
|
20
21
|
SELECT listed.value AS conversation,
|
|
21
22
|
(${OF_THE_ROW} AND ${ANSWERS_THE_TURN} ${NEWEST_FIRST}) AS answer,
|
|
@@ -29,8 +30,13 @@ export const ROWS = `WITH chosen AS (
|
|
|
29
30
|
json_extract(said.message, '$.role') AS said_role,
|
|
30
31
|
json_extract(said.message, '$.accepted_at') AS said_at,
|
|
31
32
|
answer.turn AS answered,
|
|
33
|
+
json_extract(answer.message, '$.content.state') AS saved_state,
|
|
34
|
+
json_extract(answer.message, '$.accepted_at') AS saved_at,
|
|
32
35
|
substr(json_extract(answer.message, '$.failure'), 1, ${EXCERPT}) AS failure,
|
|
33
|
-
(
|
|
36
|
+
COALESCE(
|
|
37
|
+
(SELECT value FROM conversation_facts WHERE conversation = chosen.conversation AND name = 'openedTurn'),
|
|
38
|
+
CASE WHEN julianday(json_extract(answer.message, '$.accepted_at')) < ${READ_UNTIL} THEN answer.turn END
|
|
39
|
+
) AS opened_turn,
|
|
34
40
|
json_extract(opened.message, '$.source') AS opened_source,
|
|
35
41
|
json_extract(opened.message, '$.sender') AS opened_sender,
|
|
36
42
|
asking.identity AS asking_identity,
|
|
@@ -127,6 +133,9 @@ export function conversationRows(connection, conversations) {
|
|
|
127
133
|
at: textOrNull(row.said_at),
|
|
128
134
|
},
|
|
129
135
|
answered: textOrNull(row.answered),
|
|
136
|
+
saved: row.saved_state === null || row.saved_at === null
|
|
137
|
+
? null
|
|
138
|
+
: { state: JSON.parse(text(row.saved_state)), at: text(row.saved_at) },
|
|
130
139
|
openedTurn: textOrNull(row.opened_turn),
|
|
131
140
|
failure: textOrNull(row.failure),
|
|
132
141
|
opened: row.opened_source === null ? null : heldSource(row.opened_source, row.opened_sender),
|
package/dist/name.d.ts
CHANGED
package/dist/name.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../src/name.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../src/name.ts"],"names":[],"mappings":"AA+GA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK9C;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
package/dist/name.js
CHANGED
|
@@ -97,22 +97,18 @@ function lowerLetterOf(character) {
|
|
|
97
97
|
function codePoint(character) {
|
|
98
98
|
return WORDLIKE.test(character) ? `-u${character.codePointAt(0)?.toString(16) ?? ''}-` : '-';
|
|
99
99
|
}
|
|
100
|
-
function latin(text
|
|
100
|
+
function latin(text) {
|
|
101
101
|
return [...text]
|
|
102
102
|
.map((character) => {
|
|
103
103
|
if ((character.codePointAt(0) ?? 0) < 0x80)
|
|
104
104
|
return character;
|
|
105
105
|
const lower = character.toLowerCase();
|
|
106
|
-
|
|
107
|
-
return lower === character ? letter : `${letter.charAt(0).toUpperCase()}${letter.slice(1)}`;
|
|
106
|
+
return lowerLetterOf(lower) ?? codePoint(lower);
|
|
108
107
|
})
|
|
109
108
|
.join('');
|
|
110
109
|
}
|
|
111
|
-
export function transliterated(text) {
|
|
112
|
-
return latin(text, () => '-');
|
|
113
|
-
}
|
|
114
110
|
export function nameFrom(title) {
|
|
115
|
-
return latin(title
|
|
111
|
+
return latin(title)
|
|
116
112
|
.toLowerCase()
|
|
117
113
|
.replace(/[^a-z0-9]+/g, '-')
|
|
118
114
|
.replace(/^-+|-+$/g, '');
|
package/dist/opening.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAsCxF"}
|
package/dist/opening.js
CHANGED
|
@@ -7,7 +7,7 @@ import { prepare } from './preparation.js';
|
|
|
7
7
|
import { unpair } from './queue.js';
|
|
8
8
|
import { emitRooms, emitStorageLoss, statusShown } from './shown.js';
|
|
9
9
|
export async function open(runtime, opened) {
|
|
10
|
-
const { store, socket, shell, conversations, build
|
|
10
|
+
const { store, socket, shell, conversations, build } = runtime;
|
|
11
11
|
if (socket.closed())
|
|
12
12
|
throw new Error('runtime closed');
|
|
13
13
|
const interrupted = await opened.fences();
|
|
@@ -25,7 +25,7 @@ export async function open(runtime, opened) {
|
|
|
25
25
|
}
|
|
26
26
|
const held = await opened.opened();
|
|
27
27
|
store.device.set({
|
|
28
|
-
|
|
28
|
+
completedWhenOpened: (await opened.facts(['lastCompleted'])).lastCompleted !== null,
|
|
29
29
|
});
|
|
30
30
|
try {
|
|
31
31
|
await opened.demote();
|
|
@@ -45,9 +45,25 @@ export async function open(runtime, opened) {
|
|
|
45
45
|
void eraseFenced(runtime, interrupted).catch(uncaught);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
+
await factsKept(runtime, opened);
|
|
48
49
|
statusShown(runtime);
|
|
49
50
|
prepare(runtime);
|
|
50
51
|
emitRooms(runtime);
|
|
51
52
|
void unpair(runtime).catch(uncaught);
|
|
52
53
|
return opened;
|
|
53
54
|
}
|
|
55
|
+
async function factsKept({ socket, adopt }, opened) {
|
|
56
|
+
const { session } = socket;
|
|
57
|
+
const { unstored } = session.now();
|
|
58
|
+
if (unstored !== null) {
|
|
59
|
+
queueMicrotask(() => {
|
|
60
|
+
void adopt(unstored).catch(uncaught);
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const { capabilities, queriesOnly } = await opened.facts(['capabilities', 'queriesOnly']);
|
|
65
|
+
if (queriesOnly.length > 0 && !session.now().roomsNamed)
|
|
66
|
+
session.set({ queriesOnly });
|
|
67
|
+
if (capabilities.length > 0)
|
|
68
|
+
socket.readyFromStore();
|
|
69
|
+
}
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
1
|
+
import type { ActionResult, AdapterFailure, AttachResult, BinaryCopy, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
3
|
import type { Attempt, Retries } from './retried.js';
|
|
4
4
|
import type { KeptBinary, KeptResult } from './opened.js';
|
|
@@ -34,8 +34,16 @@ export type BinaryLinkAnswer = {
|
|
|
34
34
|
name: string;
|
|
35
35
|
mediaType: string;
|
|
36
36
|
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
37
|
-
export type
|
|
38
|
-
|
|
37
|
+
export type ShownLinkAnswer = Extract<BinaryLinkAnswer, {
|
|
38
|
+
kind: 'link';
|
|
39
|
+
}> & {
|
|
40
|
+
copies: readonly BinaryCopy[];
|
|
41
|
+
};
|
|
42
|
+
type ShownRefusal = Exclude<BinaryLinkAnswer, {
|
|
43
|
+
kind: 'link';
|
|
44
|
+
}>;
|
|
45
|
+
export type HeldShownAnswer = KeptBinary | ShownLinkAnswer | ShownRefusal;
|
|
46
|
+
export type ShownAnswer = BinaryAnswer | ShownLinkAnswer | ShownRefusal;
|
|
39
47
|
export type AttachAnswer = {
|
|
40
48
|
kind: 'attached';
|
|
41
49
|
path: string;
|
package/dist/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,KAAK,OAAO,CAAC,IAAI,SAAS,MAAM,IAAI,eAAe,GAAG;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAErE,MAAM,MAAM,OAAO,GACf,OAAO,CAAC,uBAAuB,CAAC,GAChC,OAAO,CAAC,uBAAuB,CAAC,GAChC,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GACpD,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9C,aAAa,CAAC;AAElB,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,EAA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export declare
|
|
2
|
+
export declare const WORKING = "Working";
|
|
3
|
+
export declare function linesWords(added: number, removed: number): string;
|
|
4
|
+
export declare function turnLine(parts: readonly Part[], lead: string | null): string | null;
|
|
3
5
|
export declare function runningLine(parts: readonly Part[]): string | null;
|
|
4
6
|
//# sourceMappingURL=parts.d.ts.map
|
package/dist/parts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../src/parts.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../src/parts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAGrE,eAAO,MAAM,OAAO,YAAY,CAAC;AAOjC,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAMD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAenF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,MAAM,GAAG,IAAI,CAIjE"}
|
package/dist/parts.js
CHANGED
|
@@ -1,13 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { turnCounts } from '@agentshouse/session-content';
|
|
2
2
|
import { excerpt } from './read.js';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export const WORKING = 'Working';
|
|
4
|
+
function said(count, one, many) {
|
|
5
|
+
if (count === 0)
|
|
6
|
+
return null;
|
|
7
|
+
return count === 1 ? one : many(count);
|
|
8
|
+
}
|
|
9
|
+
export function linesWords(added, removed) {
|
|
10
|
+
return `+${added} −${removed}`;
|
|
11
|
+
}
|
|
12
|
+
function capitalized(words) {
|
|
13
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
14
|
+
}
|
|
15
|
+
export function turnLine(parts, lead) {
|
|
16
|
+
const counts = turnCounts(parts);
|
|
17
|
+
const kinds = [
|
|
18
|
+
said(counts.commands, 'ran 1 command', (count) => `ran ${count} commands`),
|
|
19
|
+
said(counts.edited, 'edited 1 file', (count) => `edited ${count} files`),
|
|
20
|
+
said(counts.other, 'made 1 other call', (count) => `made ${count} other calls`),
|
|
21
|
+
].filter((one) => one !== null);
|
|
22
|
+
if (kinds.length === 0)
|
|
23
|
+
return null;
|
|
24
|
+
const changed = counts.added === 0 && counts.removed === 0 ? null : linesWords(counts.added, counts.removed);
|
|
25
|
+
const failed = counts.failed === 0 ? null : `${counts.failed} failed`;
|
|
26
|
+
const words = kinds.join(' · ');
|
|
27
|
+
return [lead === null ? capitalized(words) : `${lead} · ${words}`, changed, failed]
|
|
28
|
+
.filter((one) => one !== null)
|
|
29
|
+
.join(' · ');
|
|
6
30
|
}
|
|
7
31
|
export function runningLine(parts) {
|
|
8
|
-
const
|
|
9
|
-
const note = [...own].reverse().find((part) => part.type === 'text' && part.text.trim() !== '');
|
|
32
|
+
const note = [...parts].reverse().find((part) => part.type === 'text' && part.text.trim() !== '');
|
|
10
33
|
if (note?.type === 'text')
|
|
11
34
|
return excerpt(note.text);
|
|
12
|
-
return
|
|
35
|
+
return turnLine(parts, null);
|
|
13
36
|
}
|