@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/change-set.js
CHANGED
|
@@ -1,110 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { changedPaths, sameBinary, sameChange } from './overlay.js';
|
|
4
|
-
import { beneath } from './paths.js';
|
|
5
|
-
import { compositionOf, sameMembership } from './replica.js';
|
|
6
|
-
import { markdownPath, rowsOf } from './rows.js';
|
|
7
|
-
import { finished, ROW_WEIGHT } from './turn.js';
|
|
8
|
-
function rowsAt(locator, replica, path) {
|
|
9
|
-
if (replica === null)
|
|
10
|
-
return [];
|
|
11
|
-
const visible = replica.visible;
|
|
12
|
-
const document = markdownPath(path) ? passingFrontmatter(visible.collection, path) : null;
|
|
13
|
-
const held = visible.documents[path] !== undefined && document !== undefined;
|
|
14
|
-
const binary = visible.binaries[path];
|
|
15
|
-
if (!held && binary === undefined)
|
|
16
|
-
return [];
|
|
17
|
-
return rowsOf(locator, path, document ?? null, compositionOf(replica.confirmed.record), visible.changes[path] ?? null, visible.fileIds[path] ?? null, binary === undefined ? null : binaryRecord(path, binary, visible.revisions[path]));
|
|
18
|
-
}
|
|
19
|
-
function modelShape(model) {
|
|
20
|
-
return model.status === 'unavailable' ? 'unavailable' : JSON.stringify(model.types);
|
|
21
|
-
}
|
|
22
|
-
export function changeSet(locator, before, after, changed = {}) {
|
|
23
|
-
return finished(changing(locator, before, after, changed));
|
|
24
|
-
}
|
|
25
|
-
export function* changing(locator, before, after, changed = {}) {
|
|
26
|
-
const documents = [];
|
|
27
|
-
const oldRoom = before?.confirmed.record;
|
|
28
|
-
const newRoom = after?.confirmed.record;
|
|
29
|
-
const collectionChanged = oldRoom !== undefined &&
|
|
30
|
-
newRoom !== undefined &&
|
|
31
|
-
modelShape(oldRoom.model) !== modelShape(newRoom.model);
|
|
32
|
-
const selectionChanged = oldRoom !== undefined &&
|
|
33
|
-
newRoom !== undefined &&
|
|
34
|
-
modelShape(oldRoom.selectionModel) !== modelShape(newRoom.selectionModel);
|
|
35
|
-
const reclassified = oldRoom !== undefined && newRoom !== undefined && !sameMembership(oldRoom, newRoom);
|
|
36
|
-
const paths = before === null || after === null || collectionChanged || selectionChanged || reclassified
|
|
37
|
-
? new Set([
|
|
38
|
-
...Object.keys(before?.visible.documents ?? {}),
|
|
39
|
-
...Object.keys(after?.visible.documents ?? {}),
|
|
40
|
-
...Object.keys(before?.visible.binaries ?? {}),
|
|
41
|
-
...Object.keys(after?.visible.binaries ?? {}),
|
|
42
|
-
])
|
|
43
|
-
: yield* changedPaths(before.visible, after.visible);
|
|
44
|
-
for (const path of paths) {
|
|
45
|
-
yield ROW_WEIGHT;
|
|
46
|
-
if (after?.visible.documents[path] === undefined &&
|
|
47
|
-
after?.visible.binaries[path] === undefined &&
|
|
48
|
-
before?.visible.documents[path] === undefined &&
|
|
49
|
-
before?.visible.binaries[path] === undefined)
|
|
50
|
-
continue;
|
|
51
|
-
const selected = newRoom?.typedSelection?.roots.some((root) => beneath(root, path)) ?? false;
|
|
52
|
-
const retyped = selected ? selectionChanged : collectionChanged;
|
|
53
|
-
if (before?.visible.documents[path] === after?.visible.documents[path] &&
|
|
54
|
-
sameBinary(before?.visible.binaries[path], after?.visible.binaries[path]) &&
|
|
55
|
-
before?.visible.revisions[path] === after?.visible.revisions[path] &&
|
|
56
|
-
before?.visible.fileIds[path] === after?.visible.fileIds[path] &&
|
|
57
|
-
sameChange(before?.visible.changes[path], after?.visible.changes[path]) &&
|
|
58
|
-
!retyped &&
|
|
59
|
-
!reclassified)
|
|
60
|
-
continue;
|
|
61
|
-
documents.push({
|
|
62
|
-
locator,
|
|
63
|
-
path,
|
|
64
|
-
get before() {
|
|
65
|
-
return rowsAt(locator, before, path);
|
|
66
|
-
},
|
|
67
|
-
get after() {
|
|
68
|
-
return rowsAt(locator, after, path);
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
}
|
|
1
|
+
export function changeSet(locator, changed = {}) {
|
|
2
|
+
const documents = changed.documents;
|
|
72
3
|
return {
|
|
73
|
-
documents
|
|
4
|
+
documents: documents === undefined
|
|
5
|
+
? []
|
|
6
|
+
: documents === null
|
|
7
|
+
? [{ locator, path: null }]
|
|
8
|
+
: documents.map((path) => ({ locator, path })),
|
|
74
9
|
drafts: (changed.drafts ?? []).map((path) => ({ locator, path })),
|
|
75
10
|
rooms: changed.room ? [locator] : [],
|
|
76
11
|
queues: changed.queue ? [locator] : [],
|
|
77
12
|
presentations: changed.presentation === undefined ? [] : [changed.presentation],
|
|
78
|
-
messages: [],
|
|
79
|
-
conversations: [],
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
export function entering(locator, replica, paths) {
|
|
83
|
-
return {
|
|
84
|
-
documents: paths.map((path) => ({
|
|
85
|
-
locator,
|
|
86
|
-
path,
|
|
87
|
-
before: [],
|
|
88
|
-
get after() {
|
|
89
|
-
return rowsAt(locator, replica, path);
|
|
90
|
-
},
|
|
91
|
-
})),
|
|
92
|
-
drafts: [],
|
|
93
|
-
rooms: [],
|
|
94
|
-
queues: [],
|
|
95
|
-
presentations: [],
|
|
96
|
-
messages: [],
|
|
97
13
|
conversations: [],
|
|
98
14
|
};
|
|
99
15
|
}
|
|
100
|
-
export function conversationChangeSet(
|
|
16
|
+
export function conversationChangeSet(conversations) {
|
|
101
17
|
return {
|
|
102
18
|
documents: [],
|
|
103
19
|
drafts: [],
|
|
104
20
|
rooms: [],
|
|
105
21
|
queues: [],
|
|
106
22
|
presentations: [],
|
|
107
|
-
messages,
|
|
108
23
|
conversations: [...new Set(conversations)],
|
|
109
24
|
};
|
|
110
25
|
}
|
|
@@ -115,7 +30,9 @@ export function mergeChangeSets(sets) {
|
|
|
115
30
|
rooms: [...new Set(sets.flatMap((set) => set.rooms))],
|
|
116
31
|
queues: [...new Set(sets.flatMap((set) => set.queues))],
|
|
117
32
|
presentations: [...new Set(sets.flatMap((set) => set.presentations))],
|
|
118
|
-
messages: sets.flatMap((set) => set.messages),
|
|
119
33
|
conversations: [...new Set(sets.flatMap((set) => set.conversations))],
|
|
120
34
|
};
|
|
121
35
|
}
|
|
36
|
+
export function touches(set, locator, path) {
|
|
37
|
+
return set.documents.some((change) => change.locator === locator && (change.path === null || change.path === path));
|
|
38
|
+
}
|
package/dist/change.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BinaryFile, HeadChange } from './adapter.js';
|
|
1
2
|
export type Change = {
|
|
2
3
|
readonly kind: 'field';
|
|
3
4
|
readonly path: string;
|
|
@@ -29,7 +30,6 @@ export type Change = {
|
|
|
29
30
|
readonly kind: 'binary';
|
|
30
31
|
readonly path: string;
|
|
31
32
|
readonly localId: string;
|
|
32
|
-
readonly blob: Blob;
|
|
33
33
|
readonly byteLength: number;
|
|
34
34
|
readonly mediaType: string;
|
|
35
35
|
readonly sha256: string;
|
|
@@ -40,6 +40,32 @@ export type Change = {
|
|
|
40
40
|
} | {
|
|
41
41
|
readonly kind: 'remove';
|
|
42
42
|
readonly path: string;
|
|
43
|
+
} | (Arriving & {
|
|
44
|
+
readonly content: string;
|
|
45
|
+
}) | (Arriving & {
|
|
46
|
+
readonly binary: BinaryFile;
|
|
47
|
+
});
|
|
48
|
+
type Arriving = {
|
|
49
|
+
readonly kind: 'arrival';
|
|
50
|
+
readonly path: string;
|
|
51
|
+
readonly revision?: string;
|
|
52
|
+
readonly fileId?: string;
|
|
53
|
+
readonly change?: HeadChange;
|
|
54
|
+
};
|
|
55
|
+
export type RoomMove = {
|
|
56
|
+
readonly source: {
|
|
57
|
+
readonly room: string;
|
|
58
|
+
readonly baseRoomVersion: string;
|
|
59
|
+
};
|
|
60
|
+
readonly destination: {
|
|
61
|
+
readonly room: string;
|
|
62
|
+
readonly baseRoomVersion: string;
|
|
63
|
+
readonly handle: string;
|
|
64
|
+
};
|
|
65
|
+
readonly moves: readonly {
|
|
66
|
+
readonly path: string;
|
|
67
|
+
readonly to: string;
|
|
68
|
+
}[];
|
|
43
69
|
};
|
|
44
70
|
export type Precondition = {
|
|
45
71
|
readonly kind: 'field';
|
|
@@ -81,9 +107,13 @@ export type ChangeBatch = {
|
|
|
81
107
|
readonly changes: readonly Change[];
|
|
82
108
|
readonly preconditions: readonly Precondition[];
|
|
83
109
|
readonly writtenBy?: WrittenBy;
|
|
110
|
+
readonly between?: RoomMove;
|
|
84
111
|
};
|
|
85
112
|
export declare function immutable(batch: ChangeBatch): ChangeBatch;
|
|
113
|
+
export declare function partnerOf(batch: ChangeBatch, locator: string): string | null;
|
|
114
|
+
export declare function leaving(batch: ChangeBatch, locator: string): boolean;
|
|
86
115
|
export declare function landing(changes: readonly Change[], index: number, path: string): string | null;
|
|
87
116
|
export declare function departure(changes: readonly Change[], index: number): string;
|
|
88
117
|
export declare function queuedFile(batch: ChangeBatch, path: string, localId: string): number;
|
|
118
|
+
export {};
|
|
89
119
|
//# sourceMappingURL=change.d.ts.map
|
package/dist/change.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change.d.ts","sourceRoot":"","sources":["../src/change.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GACd;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC5E;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC5E;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CA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AM,CAM3E;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAOpF"}
|
package/dist/change.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function frozen(value) {
|
|
2
2
|
if (Array.isArray(value))
|
|
3
3
|
return Object.freeze(value.map((item) => frozen(item)));
|
|
4
|
-
if (value === null || typeof value !== 'object'
|
|
4
|
+
if (value === null || typeof value !== 'object')
|
|
5
5
|
return value;
|
|
6
6
|
const copy = {};
|
|
7
7
|
for (const [name, item] of Object.entries(value))
|
|
@@ -11,6 +11,15 @@ function frozen(value) {
|
|
|
11
11
|
export function immutable(batch) {
|
|
12
12
|
return frozen(batch);
|
|
13
13
|
}
|
|
14
|
+
export function partnerOf(batch, locator) {
|
|
15
|
+
const between = batch.between;
|
|
16
|
+
if (between === undefined)
|
|
17
|
+
return null;
|
|
18
|
+
return between.source.room === locator ? between.destination.room : between.source.room;
|
|
19
|
+
}
|
|
20
|
+
export function leaving(batch, locator) {
|
|
21
|
+
return batch.between?.source.room === locator;
|
|
22
|
+
}
|
|
14
23
|
export function landing(changes, index, path) {
|
|
15
24
|
let at = path;
|
|
16
25
|
for (const change of changes.slice(index + 1)) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type HouseSource = {
|
|
2
|
+
readonly kind: 'request';
|
|
3
|
+
readonly request: string;
|
|
4
|
+
readonly routine: string;
|
|
5
|
+
readonly version: number;
|
|
6
|
+
readonly requester: {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly room: boolean;
|
|
9
|
+
};
|
|
10
|
+
readonly room: {
|
|
11
|
+
readonly ref: string;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
};
|
|
14
|
+
readonly approved: string | null;
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: 'mail';
|
|
17
|
+
readonly agent: string;
|
|
18
|
+
readonly owner: string;
|
|
19
|
+
};
|
|
20
|
+
export type ChatRequest = {
|
|
21
|
+
readonly request: string;
|
|
22
|
+
readonly room: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function sourceOf(value: unknown): HouseSource | null;
|
|
25
|
+
//# sourceMappingURL=house.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"house.d.ts","sourceRoot":"","sources":["../../src/chat/house.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GACnB;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IACtE,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAgC9E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAO3D"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { record, text } from './read.js';
|
|
2
|
+
function requestOf(source) {
|
|
3
|
+
const request = text(source, 'request');
|
|
4
|
+
const routine = record(source.routine);
|
|
5
|
+
const name = text(routine, 'name');
|
|
6
|
+
const version = routine.version;
|
|
7
|
+
const requester = record(source.requester);
|
|
8
|
+
const by = text(requester, 'name');
|
|
9
|
+
const room = record(source.room);
|
|
10
|
+
const ref = text(room, 'ref');
|
|
11
|
+
const called = text(room, 'name');
|
|
12
|
+
if (request === null ||
|
|
13
|
+
name === null ||
|
|
14
|
+
typeof version !== 'number' ||
|
|
15
|
+
by === null ||
|
|
16
|
+
ref === null ||
|
|
17
|
+
called === null)
|
|
18
|
+
return null;
|
|
19
|
+
return {
|
|
20
|
+
kind: 'request',
|
|
21
|
+
request,
|
|
22
|
+
routine: name,
|
|
23
|
+
version,
|
|
24
|
+
requester: { name: by, room: text(requester, 'room') !== null },
|
|
25
|
+
room: { ref, name: called },
|
|
26
|
+
approved: text(source, 'approved_at'),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function sourceOf(value) {
|
|
30
|
+
const source = record(value);
|
|
31
|
+
if (source.kind === 'request')
|
|
32
|
+
return requestOf(source);
|
|
33
|
+
if (source.kind !== 'mail')
|
|
34
|
+
return null;
|
|
35
|
+
const agent = text(record(source.agent), 'name');
|
|
36
|
+
const owner = text(record(source.owner), 'name');
|
|
37
|
+
return agent === null || owner === null ? null : { kind: 'mail', agent, owner };
|
|
38
|
+
}
|
package/dist/chat/input.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import type { ChatRequest } from './house.js';
|
|
2
3
|
import { type ChatNoteProps } from './kit.js';
|
|
3
4
|
export type ChatInputProps = {
|
|
4
5
|
readonly messageLength?: number;
|
|
5
6
|
readonly note?: (note: ChatNoteProps) => ReactNode;
|
|
6
7
|
readonly autoFocus?: boolean;
|
|
8
|
+
readonly decision?: (request: ChatRequest) => ReactNode;
|
|
7
9
|
};
|
|
8
|
-
export declare function ChatInput({ messageLength, note, autoFocus, }: ChatInputProps): ReactElement;
|
|
10
|
+
export declare function ChatInput({ messageLength, note, autoFocus, decision, }: ChatInputProps): ReactElement;
|
|
9
11
|
//# sourceMappingURL=input.d.ts.map
|
package/dist/chat/input.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/chat/input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/chat/input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAmBlG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAsD,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAMlG,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,SAAS,CAAC;IACnD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,SAAS,CAAC;CACzD,CAAC;AAgFF,wBAAgB,SAAS,CAAC,EACxB,aAAa,EACb,IAAY,EACZ,SAAiB,EACjB,QAAQ,GACT,EAAE,cAAc,GAAG,YAAY,CA4K/B"}
|
package/dist/chat/input.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useContext, useEffect, useMemo, useRef } from 'react';
|
|
3
|
-
import { ComposerPrimitive,
|
|
3
|
+
import { ComposerPrimitive, useAuiState, } from '@assistant-ui/react';
|
|
4
4
|
import { DropdownMenu } from 'radix-ui';
|
|
5
5
|
import ArrowUp from 'lucide-react/dist/esm/icons/arrow-up.mjs';
|
|
6
6
|
import Check from 'lucide-react/dist/esm/icons/check.mjs';
|
|
7
7
|
import ChevronDown from 'lucide-react/dist/esm/icons/chevron-down.mjs';
|
|
8
8
|
import CornerDownRight from 'lucide-react/dist/esm/icons/corner-down-right.mjs';
|
|
9
9
|
import ListEnd from 'lucide-react/dist/esm/icons/list-end.mjs';
|
|
10
|
-
import Paperclip from 'lucide-react/dist/esm/icons/paperclip.mjs';
|
|
11
10
|
import Pencil from 'lucide-react/dist/esm/icons/pencil.mjs';
|
|
12
11
|
import Plus from 'lucide-react/dist/esm/icons/plus.mjs';
|
|
13
12
|
import Square from 'lucide-react/dist/esm/icons/square.mjs';
|
|
@@ -42,10 +41,6 @@ function commandsFound(commands, query) {
|
|
|
42
41
|
const within = commands.filter((one) => !named.includes(one) && one.name.toLowerCase().includes(asked));
|
|
43
42
|
return [...named, ...within].map(commandItem);
|
|
44
43
|
}
|
|
45
|
-
function Attached({ id, name }) {
|
|
46
|
-
const aui = useAui();
|
|
47
|
-
return (_jsxs("span", { className: "ahc-chip ahc-chip--removable", children: [_jsx(Paperclip, { "aria-hidden": "true" }), _jsx(Name, { text: name }), _jsx(IconButton, { label: `Remove ${name}`, compact: true, onClick: () => void aui.composer().attachment({ id }).remove(), children: _jsx(X, { "aria-hidden": "true" }) })] }));
|
|
48
|
-
}
|
|
49
44
|
function Picker({ option, choose, }) {
|
|
50
45
|
const container = useContext(Portal);
|
|
51
46
|
return (_jsxs(DropdownMenu.Root, { modal: false, children: [_jsxs(DropdownMenu.Trigger, { className: "ahc-btn ahc-picker", "aria-label": option.name, title: option.name, children: [_jsx(Name, { text: option.values.find((one) => one.value === option.value)?.name ?? option.value }), _jsx(ChevronDown, { "aria-hidden": "true" })] }), _jsx(DropdownMenu.Portal, { container: container, children: _jsxs(DropdownMenu.Content, { className: "ahc-menu", side: "top", align: "start", children: [_jsx(DropdownMenu.Label, { className: "ahc-menu__heading", children: option.name }), _jsx(DropdownMenu.RadioGroup, { value: option.value, onValueChange: (value) => {
|
|
@@ -56,10 +51,10 @@ function Picker({ option, choose, }) {
|
|
|
56
51
|
function noted(note) {
|
|
57
52
|
return _jsx(ChatNote, { ...note });
|
|
58
53
|
}
|
|
59
|
-
export function ChatInput({ messageLength, note = noted, autoFocus = false, }) {
|
|
54
|
+
export function ChatInput({ messageLength, note = noted, autoFocus = false, decision, }) {
|
|
60
55
|
const chat = useChat();
|
|
56
|
+
const { attach } = chat;
|
|
61
57
|
const { client } = useChatScope();
|
|
62
|
-
const aui = useAui();
|
|
63
58
|
const opened = useOpened();
|
|
64
59
|
const { lone, commands, context, queued, running } = opened;
|
|
65
60
|
const conversation = chat.conversation ?? '';
|
|
@@ -71,7 +66,6 @@ export function ChatInput({ messageLength, note = noted, autoFocus = false, }) {
|
|
|
71
66
|
input.current?.focus();
|
|
72
67
|
}, [autoFocus, thread]);
|
|
73
68
|
const typed = useAuiState((s) => s.composer.text);
|
|
74
|
-
const attached = useAuiState((s) => s.composer.attachments.length > 0);
|
|
75
69
|
const fault = messageLength !== undefined && typed.length > messageLength
|
|
76
70
|
? `Keep it to ${messageLength} characters.`
|
|
77
71
|
: null;
|
|
@@ -88,12 +82,11 @@ export function ChatInput({ messageLength, note = noted, autoFocus = false, }) {
|
|
|
88
82
|
chat.edit(id);
|
|
89
83
|
input.current?.focus();
|
|
90
84
|
};
|
|
91
|
-
const drafted = typed.trim() !== ''
|
|
92
|
-
const readOnly = opened.deleted;
|
|
93
|
-
return (_jsx(Scoped, { children: _jsxs("div", { className: "ahc-input-area", children: [readOnly || queued.length === 0 ? null : (_jsxs("div", { role: "group", "aria-label": "Queued messages", className: "ahc-queue", children: [_jsxs("div", { className: "ahc-queue__head", children: [_jsx(ListEnd, { "aria-hidden": "true" }), _jsx("span", { className: "ahc-queue__said", children: `${queued.length} ${queued.length === 1 ? 'message waits' : 'messages wait'} for ${opened.name} to finish` }), running ? (_jsx(Button, { variant: "outline", compact: true, onClick: interrupt, children: "Send now" })) : null] }), queued.map((item) => (_jsxs("div", { className: "ahc-queue-row", children: [_jsx(CornerDownRight, { "aria-hidden": "true", className: "ahc-muted" }), _jsx("span", { className: "ahc-queue-row__text", children: item.text }), _jsx(IconButton, { label: "Edit queued message", compact: true, onClick: () => edit(item.id), children: _jsx(Pencil, { "aria-hidden": "true" }) }), _jsx(IconButton, { label: "Remove queued message", compact: true, onClick: () => chat.unqueue(item.id), children: _jsx(X, { "aria-hidden": "true" }) })] }, item.id)))] })), readOnly ? null : (_jsx(ComposerPrimitive.Root, { className: "ahc-composer", children: _jsxs(ComposerPrimitive.Unstable_TriggerPopoverRoot, { children: [commands.length === 0 ? null : (_jsxs(ComposerPrimitive.Unstable_TriggerPopover, { char: COMMAND, matcher: atStart, adapter: listed, "aria-label": "Commands", className: "ahc-menu ahc-commands", children: [_jsx(ComposerPrimitive.Unstable_TriggerPopover.Directive, { formatter: commanded }), _jsx(ComposerPrimitive.Unstable_TriggerPopoverItems, { children: (items) => items.map((item, index) => (_jsx(ComposerPrimitive.Unstable_TriggerPopoverItem, { item: item, index: index, className: "ahc-row ahc-row--two", children: _jsxs("span", { className: "ahc-row__label", children: [_jsx("span", { className: "ahc-row__title ahc-mono", children: item.label }), _jsx("span", { className: "ahc-row__sub", children: item.description })] }) }, item.id))) })] })),
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
} }), opened.options.map((option) => (_jsx(Picker, { option: option, choose: chat.choose }, option.id))), _jsx("span", { className: "ahc-spacer" }), context === null ? null : (_jsx("span", { title: "Context in use", className: "ahc-meta", children: contextText(context) })), running ? (_jsx("button", { type: "button", className: `ahc-btn ahc-btn--icon ${drafted ? 'ahc-btn--outline' : 'ahc-btn--ink'}`, "aria-label": "Stop", title: "Stop", onClick: interrupt, children: _jsx(Square, { "aria-hidden": "true" }) })) : null, running && !drafted ? null : (_jsx(ComposerPrimitive.Send, { className: "ahc-btn ahc-btn--icon ahc-btn--ink", "aria-label": running ? 'Queue message' : 'Send', disabled: fault !== null, children: _jsx(ArrowUp, { size: 20, "aria-hidden": "true" }) }))] })] }) })), fault === null ? null : (_jsx("p", { className: "ahc-note", role: "status", "data-state": "refused", children: fault })), note({ outcome: chat.acting.outcome }), note({ outcome: chat.sending.outcome, again: chat.sending.again ?? undefined })] }) }));
|
|
85
|
+
const drafted = typed.trim() !== '';
|
|
86
|
+
const readOnly = opened.deleted || opened.waits;
|
|
87
|
+
return (_jsx(Scoped, { children: _jsxs("div", { className: "ahc-input-area", children: [readOnly || queued.length === 0 ? null : (_jsxs("div", { role: "group", "aria-label": "Queued messages", className: "ahc-queue", children: [_jsxs("div", { className: "ahc-queue__head", children: [_jsx(ListEnd, { "aria-hidden": "true" }), _jsx("span", { className: "ahc-queue__said", children: `${queued.length} ${queued.length === 1 ? 'message waits' : 'messages wait'} for ${opened.name} to finish` }), running ? (_jsx(Button, { variant: "outline", compact: true, onClick: interrupt, children: "Send now" })) : null] }), queued.map((item) => (_jsxs("div", { className: "ahc-queue-row", children: [_jsx(CornerDownRight, { "aria-hidden": "true", className: "ahc-muted" }), _jsx("span", { className: "ahc-queue-row__text", children: item.text }), _jsx(IconButton, { label: "Edit queued message", compact: true, onClick: () => edit(item.id), children: _jsx(Pencil, { "aria-hidden": "true" }) }), _jsx(IconButton, { label: "Remove queued message", compact: true, onClick: () => chat.unqueue(item.id), children: _jsx(X, { "aria-hidden": "true" }) })] }, item.id)))] })), readOnly ? null : (_jsx(ComposerPrimitive.Root, { className: "ahc-composer", children: _jsxs(ComposerPrimitive.Unstable_TriggerPopoverRoot, { children: [commands.length === 0 ? null : (_jsxs(ComposerPrimitive.Unstable_TriggerPopover, { char: COMMAND, matcher: atStart, adapter: listed, "aria-label": "Commands", className: "ahc-menu ahc-commands", children: [_jsx(ComposerPrimitive.Unstable_TriggerPopover.Directive, { formatter: commanded }), _jsx(ComposerPrimitive.Unstable_TriggerPopoverItems, { children: (items) => items.map((item, index) => (_jsx(ComposerPrimitive.Unstable_TriggerPopoverItem, { item: item, index: index, className: "ahc-row ahc-row--two", children: _jsxs("span", { className: "ahc-row__label", children: [_jsx("span", { className: "ahc-row__title ahc-mono", children: item.label }), _jsx("span", { className: "ahc-row__sub", children: item.description })] }) }, item.id))) })] })), _jsx(ComposerPrimitive.Input, { asChild: true, "aria-label": "Message", placeholder: lone === null ? `Message ${opened.name}` : lone.field.prompt, submitMode: fault === null ? 'enter' : 'none', children: _jsx("textarea", { ref: input, className: "ahc-composer__input", rows: 1 }) }), _jsxs("div", { className: "ahc-composer__bar", children: [attach === null ? null : (_jsxs(_Fragment, { children: [_jsx(IconButton, { label: "Add files", onClick: () => picker.current?.click(), children: _jsx(Plus, { size: 20, "aria-hidden": "true" }) }), _jsx("input", { ref: picker, type: "file", multiple: true, hidden: true, onChange: (event) => {
|
|
88
|
+
const chosen = [...(event.target.files ?? [])];
|
|
89
|
+
event.target.value = '';
|
|
90
|
+
void attach(chosen);
|
|
91
|
+
} })] })), opened.options.map((option) => (_jsx(Picker, { option: option, choose: chat.choose }, option.id))), _jsx("span", { className: "ahc-spacer" }), context === null ? null : (_jsx("span", { title: "Context in use", className: "ahc-meta", children: contextText(context) })), running ? (_jsx("button", { type: "button", className: `ahc-btn ahc-btn--icon ${drafted ? 'ahc-btn--outline' : 'ahc-btn--ink'}`, "aria-label": "Stop", title: "Stop", onClick: interrupt, children: _jsx(Square, { "aria-hidden": "true" }) })) : null, running && !drafted ? null : (_jsx(ComposerPrimitive.Send, { className: "ahc-btn ahc-btn--icon ahc-btn--ink", "aria-label": running ? 'Queue message' : 'Send', disabled: fault !== null, children: _jsx(ArrowUp, { size: 20, "aria-hidden": "true" }) }))] })] }) })), opened.deleted || opened.waiting === null ? null : decision?.(opened.waiting), fault === null ? null : (_jsx("p", { className: "ahc-note", role: "status", "data-state": "refused", children: fault })), note({ outcome: chat.acting.outcome }), note({ outcome: chat.sending.outcome, again: chat.sending.again ?? undefined })] }) }));
|
|
99
92
|
}
|
package/dist/chat/list.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/chat/list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,SAAS,CAAC,EACf,aAAa,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,SAAS,CAAC;QACpB,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;KACpC,CAAC,GACF,SAAS,CAAC;IACd,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,SAAS,CAAC,GAAG,SAAS,CAAC;IAC9E,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;CAChE,CAAC;AAEF,eAAO,MAAM,SAAS,oCAA+B,CAAC;AAkEtD,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE;QACpB,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC;QACrC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,aAAa,CAAC;KAC3C,CAAC;IACF,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAC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AE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,MAAM,GAAG,IAAI,CAAC;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;CAC/B,CAAC;AAEF,wBAAgB,eAAe,CAAC,EAC9B,UAAe,EACf,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAQ,GACT,EAAE,oBAAoB,GAAG,YAAY,CAgFrC;AAoBD,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG,YAAY,CAkD7E"}
|
package/dist/chat/list.js
CHANGED
|
@@ -67,7 +67,7 @@ export function ChatMessageList({ components = {}, onLink, footer, waiting, chil
|
|
|
67
67
|
const silent = chat.view === null
|
|
68
68
|
? chat.conversation === null
|
|
69
69
|
: chat.view.messages.length === 0 && chat.view.turn === null;
|
|
70
|
-
return (_jsx(Scoped, { children: _jsx(Linked.Provider, { value: onLink ?? linked, children: _jsx(ThreadPrimitive.Root, { className: "ahc-thread", children: _jsxs(ThreadPrimitive.Viewport, { className: "ahc-viewport", ref: viewport, onScroll: earlier, children: [_jsxs("div", { className: "ahc-column ahc-messages", ref: content, children: [silent ? _jsx(Empty, {}) : null, _jsx(ThreadPrimitive.Messages, { components: {
|
|
70
|
+
return (_jsx(Scoped, { children: _jsx(Linked.Provider, { value: onLink ?? linked, children: _jsx(ThreadPrimitive.Root, { className: "ahc-thread", children: _jsxs(ThreadPrimitive.Viewport, { className: "ahc-viewport", ref: viewport, onScroll: earlier, children: [_jsxs("div", { className: "ahc-column ahc-messages", ref: content, children: [chat.renewed ? (_jsx("p", { role: "note", className: "ahc-meta", children: "New chat started" })) : null, silent ? _jsx(Empty, {}) : null, _jsx(ThreadPrimitive.Messages, { components: {
|
|
71
71
|
UserMessage: User,
|
|
72
72
|
AssistantMessage: Assistant,
|
|
73
73
|
SystemMessage: HouseMessage,
|
package/dist/chat/markdown.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode } from 'react';
|
|
2
2
|
export interface FileReference {
|
|
3
|
-
readonly
|
|
4
|
-
readonly names?: (destination: string) => boolean;
|
|
3
|
+
readonly names: (destination: string) => boolean;
|
|
5
4
|
readonly draw: (reference: string, label: string, image: boolean) => ReactNode;
|
|
6
5
|
}
|
|
7
6
|
interface MarkdownOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/chat/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAYf,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/chat/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAYf,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC;IACjD,QAAQ,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,SAAS,CAAC;CAChF;AAED,UAAU,eAAe;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC;CAC/B;AAYD,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM3C;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjD;AAiDD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAK3D;AA4JD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,EAAE,aAAa,GAAG,YAAY,CAgDrF"}
|
package/dist/chat/markdown.js
CHANGED
|
@@ -22,24 +22,7 @@ function headingId(slugs, text) {
|
|
|
22
22
|
return anchorOf(seen === 0 ? slug : `${slug}-${seen}`);
|
|
23
23
|
}
|
|
24
24
|
function whole(file, text) {
|
|
25
|
-
return
|
|
26
|
-
([...text.matchAll(file.pattern)].some((one) => one[0] === text) || file.names?.(text) === true));
|
|
27
|
-
}
|
|
28
|
-
function referenced(file, text, key) {
|
|
29
|
-
const parts = [];
|
|
30
|
-
let from = 0;
|
|
31
|
-
for (const found of text.matchAll(file.pattern)) {
|
|
32
|
-
const at = found.index;
|
|
33
|
-
if (at > from)
|
|
34
|
-
parts.push(text.slice(from, at));
|
|
35
|
-
parts.push(createElement(Fragment, { key: at }, file.draw(found[0], found[0], false)));
|
|
36
|
-
from = at + found[0].length;
|
|
37
|
-
}
|
|
38
|
-
if (from === 0)
|
|
39
|
-
return text;
|
|
40
|
-
if (from < text.length)
|
|
41
|
-
parts.push(text.slice(from));
|
|
42
|
-
return createElement(Fragment, { key }, ...parts);
|
|
25
|
+
return file !== undefined && file.names(text);
|
|
43
26
|
}
|
|
44
27
|
function safeHref(url) {
|
|
45
28
|
const href = url.replace(/[\t\n\r]/g, '').replace(/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g, '');
|
|
@@ -122,7 +105,7 @@ function render(node, key, options, header = false) {
|
|
|
122
105
|
case 'heading':
|
|
123
106
|
return createElement(`h${node.depth}`, { key, id: options.ids.get(node) }, ...children());
|
|
124
107
|
case 'text':
|
|
125
|
-
return
|
|
108
|
+
return node.value;
|
|
126
109
|
case 'emphasis':
|
|
127
110
|
return createElement('em', { key }, ...children());
|
|
128
111
|
case 'strong':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/chat/message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/chat/message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,OAAO,CAAC;AAuCf,eAAO,MAAM,MAAM,kCAAyB,MAAM,KAAK,IAAI,SAAe,CAAC;AAiR3E,wBAAgB,WAAW,IAAI,YAAY,CAkB1C;AAuCD,wBAAgB,YAAY,IAAI,YAAY,CAW3C;AAkCD,wBAAgB,WAAW,IAAI,YAAY,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,YAAY,CAiG/C"}
|
package/dist/chat/message.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext, } from 'react';
|
|
3
|
-
import { ActionBarPrimitive, AuiIf, ErrorPrimitive,
|
|
3
|
+
import { ActionBarPrimitive, AuiIf, ErrorPrimitive, MessagePrimitive, groupPartByType, useAuiState, } from '@assistant-ui/react';
|
|
4
4
|
import { MarkdownTextPrimitive } from '@assistant-ui/react-markdown';
|
|
5
5
|
import { Collapsible } from 'radix-ui';
|
|
6
6
|
import remarkGfm from 'remark-gfm';
|
|
@@ -15,15 +15,17 @@ import ImageGlyph from 'lucide-react/dist/esm/icons/image.mjs';
|
|
|
15
15
|
import Layers from 'lucide-react/dist/esm/icons/layers.mjs';
|
|
16
16
|
import ListChecks from 'lucide-react/dist/esm/icons/list-checks.mjs';
|
|
17
17
|
import ListTodo from 'lucide-react/dist/esm/icons/list-todo.mjs';
|
|
18
|
-
import Paperclip from 'lucide-react/dist/esm/icons/paperclip.mjs';
|
|
19
18
|
import RotateCw from 'lucide-react/dist/esm/icons/rotate-cw.mjs';
|
|
20
19
|
import Send from 'lucide-react/dist/esm/icons/send.mjs';
|
|
21
20
|
import SlidersHorizontal from 'lucide-react/dist/esm/icons/sliders-horizontal.mjs';
|
|
22
21
|
import Terminal from 'lucide-react/dist/esm/icons/terminal.mjs';
|
|
23
22
|
import { SESSION_STARTED } from '../conversation.js';
|
|
24
|
-
import { buttonClass,
|
|
23
|
+
import { buttonClass, Working } from './kit.js';
|
|
25
24
|
import { StillRunning } from './lasting.js';
|
|
25
|
+
import { stamp } from './name.js';
|
|
26
|
+
import { useOpened } from './opened.js';
|
|
26
27
|
import { useChat } from './provider.js';
|
|
28
|
+
import { isRoomPath, RoomFile } from './room-file.js';
|
|
27
29
|
import { list, record, text } from './read.js';
|
|
28
30
|
export const Linked = createContext(null);
|
|
29
31
|
const groupBy = groupPartByType({
|
|
@@ -137,7 +139,11 @@ function Thought({ indices, active, children, }) {
|
|
|
137
139
|
return (_jsx(Toggle, { icon: active ? now.icon : _jsx(ListChecks, { "aria-hidden": "true" }), label: active ? now.title : workedOf(calls), detail: active ? now.detail : '', active: active, children: children }));
|
|
138
140
|
}
|
|
139
141
|
const SCHEME = /^[a-z][a-z0-9+.-]*:/i;
|
|
140
|
-
|
|
142
|
+
const ROOM_LINK = /\[([^\]]*)\]\((\/rooms\/[^)\s]+)\)/gu;
|
|
143
|
+
function nameOf(href) {
|
|
144
|
+
return href.slice(href.lastIndexOf('/') + 1);
|
|
145
|
+
}
|
|
146
|
+
function Linking({ href, ...rest }) {
|
|
141
147
|
const onLink = useContext(Linked);
|
|
142
148
|
if (SCHEME.test(href) || onLink === null)
|
|
143
149
|
return _jsx("a", { ...rest, href: href, rel: "noreferrer" });
|
|
@@ -146,29 +152,75 @@ function Anchor({ node: _node, href = '', ...rest }) {
|
|
|
146
152
|
onLink(href);
|
|
147
153
|
} }));
|
|
148
154
|
}
|
|
155
|
+
function Anchor({ node: _node, href = '', ...rest }) {
|
|
156
|
+
const link = _jsx(Linking, { ...rest, href: href });
|
|
157
|
+
return isRoomPath(href) ? _jsx(RoomFile, { href: href, name: nameOf(href), otherwise: link }) : link;
|
|
158
|
+
}
|
|
149
159
|
const LINKED = { a: Anchor };
|
|
150
160
|
const THOUGHT = { className: 'ahc-thought' };
|
|
151
161
|
function Said({ thought = false }) {
|
|
152
162
|
return (_jsx(MarkdownTextPrimitive, { className: "ahc-text ahc-markdown", containerProps: thought ? THOUGHT : undefined, remarkPlugins: GFM, components: LINKED, smooth: false }));
|
|
153
163
|
}
|
|
154
|
-
function
|
|
155
|
-
return _jsx(
|
|
164
|
+
function Transcribed({ text: said }) {
|
|
165
|
+
return (_jsxs("span", { className: "ahc-transcript ahc-quiet", children: [_jsx("span", { className: "ahc-meta", children: "Transcript: " }), said] }));
|
|
166
|
+
}
|
|
167
|
+
function UserText({ text: said }) {
|
|
168
|
+
const transcripts = useAuiState((s) => s.message.metadata.custom.transcripts);
|
|
169
|
+
const pieces = [];
|
|
170
|
+
const shown = new Set();
|
|
171
|
+
let from = 0;
|
|
172
|
+
for (const found of said.matchAll(ROOM_LINK)) {
|
|
173
|
+
const [whole, , href] = found;
|
|
174
|
+
pieces.push(said.slice(from, found.index));
|
|
175
|
+
pieces.push(_jsx(RoomFile, { href: href, name: nameOf(href), otherwise: whole }, found.index));
|
|
176
|
+
const transcript = transcripts?.find((one) => one.path === href);
|
|
177
|
+
if (transcript !== undefined && !shown.has(href)) {
|
|
178
|
+
shown.add(href);
|
|
179
|
+
pieces.push(_jsx(Transcribed, { text: transcript.text }, `${found.index}:transcript`));
|
|
180
|
+
}
|
|
181
|
+
from = found.index + whole.length;
|
|
182
|
+
}
|
|
183
|
+
pieces.push(said.slice(from));
|
|
184
|
+
return _jsx("span", { className: "ahc-said", children: pieces });
|
|
156
185
|
}
|
|
157
186
|
export function UserMessage() {
|
|
158
187
|
const said = useAuiState((s) => s.message.parts.some((one) => one.type === 'text' && one.text !== ''));
|
|
159
|
-
const attached = useAuiState((s) => (s.message.attachments?.length ?? 0) > 0);
|
|
160
188
|
const undelivered = useAuiState((s) => s.message.metadata.custom.undelivered === true);
|
|
161
189
|
const unknown = useAuiState((s) => s.message.metadata.custom.unknown === true);
|
|
162
190
|
const id = useAuiState((s) => s.message.id);
|
|
163
|
-
return (_jsxs(MessagePrimitive.Root, { role: "group", "aria-label": "You", className: "ahc-you", children: [said ? (_jsx("div", { className: "ahc-bubble", children: _jsx(MessagePrimitive.Parts, { components: { Text: UserText } }) })) : null,
|
|
191
|
+
return (_jsxs(MessagePrimitive.Root, { role: "group", "aria-label": "You", className: "ahc-you", children: [said ? (_jsx("div", { className: "ahc-bubble", children: _jsx(MessagePrimitive.Parts, { components: { Text: UserText } }) })) : null, undelivered ? _jsx(Undelivered, {}) : null, unknown ? _jsx(DeliveryUnknown, { message: id }) : null] }));
|
|
192
|
+
}
|
|
193
|
+
function From({ source }) {
|
|
194
|
+
if (source.kind === 'mail') {
|
|
195
|
+
return (_jsxs("div", { className: "ahc-house__from", children: [_jsx("span", { className: "ahc-house__title", children: "House \u00B7 Mail" }), _jsx("span", { className: "ahc-meta", children: `From ${source.agent} of ${source.owner}` })] }));
|
|
196
|
+
}
|
|
197
|
+
const { requester, room } = source;
|
|
198
|
+
return (_jsxs("div", { className: "ahc-house__from", children: [_jsx("span", { className: "ahc-house__title", children: `House · ${source.routine} v${source.version}` }), _jsx("span", { className: "ahc-meta", children: requester.room ? `From ${requester.name}` : `From ${requester.name} in ${room.name}` })] }));
|
|
199
|
+
}
|
|
200
|
+
function Decided({ source, waiting, }) {
|
|
201
|
+
if (source.kind !== 'request')
|
|
202
|
+
return null;
|
|
203
|
+
if (waiting)
|
|
204
|
+
return _jsx("span", { className: "ahc-meta", children: "Waits for your approval" });
|
|
205
|
+
if (source.approved === null)
|
|
206
|
+
return null;
|
|
207
|
+
return (_jsxs("span", { className: "ahc-meta", children: ["Approved ", _jsx("time", { dateTime: source.approved, children: stamp(source.approved) })] }));
|
|
164
208
|
}
|
|
165
209
|
export function HouseMessage() {
|
|
166
|
-
|
|
210
|
+
const custom = useAuiState((s) => s.message.metadata.custom);
|
|
211
|
+
const source = (custom.source ?? null);
|
|
212
|
+
return (_jsxs(MessagePrimitive.Root, { role: "group", "aria-label": "House", className: "ahc-house", children: [source === null ? null : _jsx(From, { source: source }), _jsx(MessagePrimitive.Parts, { components: { Text: UserText } }), source === null ? null : _jsx(Decided, { source: source, waiting: custom.waiting === true }), custom.undelivered === true ? _jsx(Undelivered, {}) : null] }));
|
|
167
213
|
}
|
|
168
214
|
function DeliveryUnknown({ message }) {
|
|
169
215
|
const chat = useChat();
|
|
170
216
|
return (_jsxs("span", { className: "ahc-meta", children: ["Delivery unknown", _jsx("button", { type: "button", className: buttonClass('outline', true, false), disabled: chat.acting.busy, onClick: () => void chat.retry(message), children: "Retry" })] }));
|
|
171
217
|
}
|
|
218
|
+
function Renew() {
|
|
219
|
+
const chat = useOpened();
|
|
220
|
+
if (chat.deleted)
|
|
221
|
+
return null;
|
|
222
|
+
return (_jsx("button", { type: "button", className: buttonClass('outline', true, false), disabled: chat.acting.busy, onClick: () => void chat.renew(), children: "Start new chat" }));
|
|
223
|
+
}
|
|
172
224
|
export function Undelivered() {
|
|
173
225
|
return _jsx("span", { className: "ahc-meta", children: "Telegram didn't receive this" });
|
|
174
226
|
}
|
|
@@ -192,11 +244,11 @@ export function AssistantMessage() {
|
|
|
192
244
|
case 'tool-call':
|
|
193
245
|
return _jsx(ToolCall, { call: part, active: part.status.type === 'running' });
|
|
194
246
|
case 'file':
|
|
195
|
-
return (_jsxs("div", { className: "ahc-toolline ahc-quiet", children: [_jsx(ImageGlyph, { "aria-hidden": "true" }), _jsx("span", { className: "ahc-clipped", children: part.filename })] }));
|
|
247
|
+
return (_jsx(RoomFile, { href: part.data, name: part.filename ?? nameOf(part.data), otherwise: _jsxs("div", { className: "ahc-toolline ahc-quiet", children: [_jsx(ImageGlyph, { "aria-hidden": "true" }), _jsx("span", { className: "ahc-clipped", children: part.filename })] }) }));
|
|
196
248
|
case 'indicator':
|
|
197
249
|
return _jsx(Working, { step: started ? SESSION_STARTED : undefined });
|
|
198
250
|
default:
|
|
199
251
|
return null;
|
|
200
252
|
}
|
|
201
|
-
} }), _jsx(MessagePrimitive.Error, { children: _jsxs(ErrorPrimitive.Root, { className: "ahc-failure", children: [_jsx(ErrorPrimitive.Message, {}), _jsx(AuiIf, { condition: (s) => s.thread.capabilities.reload && s.message.metadata.custom.again === true, children: _jsx(ActionBarPrimitive.Reload, { className: buttonClass('outline', true, false), children: "Try again" }) })] }) }), custom.undelivered === true ? _jsx(Undelivered, {}) : null, said ? (_jsx(ActionBarPrimitive.Root, { hideWhenRunning: true, autohide: "not-last", autohideFloat: "always", className: last ? 'ahc-actions' : 'ahc-actions ahc-actions--floating', children: _jsxs(ActionBarPrimitive.Copy, { className: `${buttonClass('quiet', true, true)} ahc-secondary`, "aria-label": "Copy", children: [_jsx(AuiIf, { condition: (s) => s.message.isCopied, children: _jsx(Check, { "aria-hidden": "true" }) }), _jsx(AuiIf, { condition: (s) => !s.message.isCopied, children: _jsx(Copy, { "aria-hidden": "true" }) })] }) })) : null, lasting.length === 0 ? null : _jsx(StillRunning, { lasting: lasting })] }));
|
|
253
|
+
} }), _jsx(MessagePrimitive.Error, { children: _jsxs(ErrorPrimitive.Root, { className: "ahc-failure", children: [_jsx(ErrorPrimitive.Message, {}), _jsx(AuiIf, { condition: (s) => s.thread.capabilities.reload && s.message.metadata.custom.again === true, children: _jsx(ActionBarPrimitive.Reload, { className: buttonClass('outline', true, false), children: "Try again" }) }), custom.renew === true ? _jsx(Renew, {}) : null] }) }), custom.undelivered === true ? _jsx(Undelivered, {}) : null, said ? (_jsx(ActionBarPrimitive.Root, { hideWhenRunning: true, autohide: "not-last", autohideFloat: "always", className: last ? 'ahc-actions' : 'ahc-actions ahc-actions--floating', children: _jsxs(ActionBarPrimitive.Copy, { className: `${buttonClass('quiet', true, true)} ahc-secondary`, "aria-label": "Copy", children: [_jsx(AuiIf, { condition: (s) => s.message.isCopied, children: _jsx(Check, { "aria-hidden": "true" }) }), _jsx(AuiIf, { condition: (s) => !s.message.isCopied, children: _jsx(Copy, { "aria-hidden": "true" }) })] }) })) : null, lasting.length === 0 ? null : _jsx(StillRunning, { lasting: lasting })] }));
|
|
202
254
|
}
|