@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/chat/messages.d.ts
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
import type { ThreadMessageLike } from '@assistant-ui/react';
|
|
2
2
|
import type { TurnContext } from '../adapter.js';
|
|
3
3
|
import type { ConversationView } from '../conversation.js';
|
|
4
|
+
import { type ChatRequest, type HouseSource } from './house.js';
|
|
4
5
|
import { type Part } from './parts.js';
|
|
5
6
|
type Entry = ConversationView['messages'][number];
|
|
7
|
+
export type Transcript = {
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly text: string;
|
|
10
|
+
};
|
|
6
11
|
export type Said = {
|
|
7
12
|
readonly turn: string;
|
|
8
13
|
readonly user: boolean;
|
|
9
14
|
readonly house: boolean;
|
|
15
|
+
readonly source: HouseSource | null;
|
|
10
16
|
readonly waiting: boolean;
|
|
11
17
|
readonly text: string;
|
|
18
|
+
readonly transcripts: readonly Transcript[];
|
|
12
19
|
readonly parts: readonly Part[];
|
|
13
20
|
readonly context: TurnContext | null;
|
|
14
21
|
readonly failure: string | null;
|
|
22
|
+
readonly resumeRefused: boolean;
|
|
15
23
|
readonly undelivered: boolean;
|
|
16
|
-
readonly files: readonly string[];
|
|
17
24
|
};
|
|
18
25
|
export declare function saidOf(entry: Entry): Said;
|
|
19
26
|
export declare function awaitsTurn(view: ConversationView | null): boolean;
|
|
27
|
+
export declare function requestIn(view: ConversationView | null): {
|
|
28
|
+
readonly request: ChatRequest;
|
|
29
|
+
readonly waiting: boolean;
|
|
30
|
+
} | null;
|
|
20
31
|
export declare function askedBefore(view: ConversationView | null, id: string | null): string | null;
|
|
21
32
|
export declare function chatMessages(view: ConversationView | null): ThreadMessageLike[];
|
|
22
33
|
export declare function contextOf(view: ConversationView | null): TurnContext | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/chat/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAA0D,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAO/F,KAAK,KAAK,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAElD,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,E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,IAAI,EAAE,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B,CAAC;AAaF,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAyBzC;AAiGD,wBAAgB,UAAU,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,OAAO,CAKjE;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAC5B;IAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAOrE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAO3F;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,EAAE,CAiE/E;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAS3E"}
|
package/dist/chat/messages.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sourceOf } from './house.js';
|
|
1
2
|
import { contextIn, jobOf, partsOf, stillRunning } from './parts.js';
|
|
2
3
|
import { list, record, text } from './read.js';
|
|
3
4
|
const SAID = new WeakMap();
|
|
@@ -7,17 +8,24 @@ export function saidOf(entry) {
|
|
|
7
8
|
if (held !== undefined)
|
|
8
9
|
return held;
|
|
9
10
|
const message = record(entry.message);
|
|
11
|
+
const house = text(message, 'role') === 'house';
|
|
10
12
|
const said = {
|
|
11
13
|
turn: text(message, 'turn_id') ?? entry.turn,
|
|
12
14
|
user: text(message, 'role') === 'user',
|
|
13
|
-
house
|
|
15
|
+
house,
|
|
16
|
+
source: house ? sourceOf(message.source) : null,
|
|
14
17
|
waiting: message.waiting === true,
|
|
15
18
|
text: text(message, 'text') ?? '',
|
|
19
|
+
transcripts: list(message, 'transcripts').flatMap((entry) => {
|
|
20
|
+
const path = text(record(entry), 'path');
|
|
21
|
+
const said = text(record(entry), 'text');
|
|
22
|
+
return path === null || said === null ? [] : [{ path, text: said }];
|
|
23
|
+
}),
|
|
16
24
|
parts: partsOf(list(message, 'parts')),
|
|
17
25
|
context: contextIn(message.context),
|
|
18
26
|
failure: text(message, 'failure'),
|
|
27
|
+
resumeRefused: message.resume_refused === true,
|
|
19
28
|
undelivered: message.telegram_undelivered === true,
|
|
20
|
-
files: list(message, 'files').flatMap((one) => text(record(one), 'name') ?? []),
|
|
21
29
|
};
|
|
22
30
|
SAID.set(entry, said);
|
|
23
31
|
return said;
|
|
@@ -83,7 +91,7 @@ function contentOf(id, parts, live) {
|
|
|
83
91
|
args: { steps: part.steps.map((step) => ({ ...step })) },
|
|
84
92
|
};
|
|
85
93
|
case 'image':
|
|
86
|
-
return { type: 'file', filename: part.name, mimeType: part.mediaType, data:
|
|
94
|
+
return { type: 'file', filename: part.name, mimeType: part.mediaType, data: part.path };
|
|
87
95
|
}
|
|
88
96
|
});
|
|
89
97
|
}
|
|
@@ -105,6 +113,14 @@ export function awaitsTurn(view) {
|
|
|
105
113
|
const said = saidOf(newest);
|
|
106
114
|
return said.user || (said.house && !said.waiting);
|
|
107
115
|
}
|
|
116
|
+
export function requestIn(view) {
|
|
117
|
+
for (const entry of view?.messages ?? []) {
|
|
118
|
+
const { waiting, source } = saidOf(entry);
|
|
119
|
+
if (source?.kind === 'request')
|
|
120
|
+
return { request: { request: source.request, room: source.room.ref }, waiting };
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
108
124
|
export function askedBefore(view, id) {
|
|
109
125
|
const said = (view?.messages ?? []).map((entry) => ({ ...saidOf(entry), id: entry.identity }));
|
|
110
126
|
const asked = said
|
|
@@ -125,7 +141,14 @@ export function chatMessages(view) {
|
|
|
125
141
|
id: entry.identity,
|
|
126
142
|
role: 'system',
|
|
127
143
|
content: [{ type: 'text', text: one.text }],
|
|
128
|
-
metadata: {
|
|
144
|
+
metadata: {
|
|
145
|
+
custom: {
|
|
146
|
+
...custom,
|
|
147
|
+
source: one.source,
|
|
148
|
+
waiting: one.waiting,
|
|
149
|
+
transcripts: one.transcripts,
|
|
150
|
+
},
|
|
151
|
+
},
|
|
129
152
|
}));
|
|
130
153
|
if (one.user) {
|
|
131
154
|
const unknown = view.deliveryUnknown.includes(entry.identity);
|
|
@@ -133,14 +156,7 @@ export function chatMessages(view) {
|
|
|
133
156
|
id: entry.identity,
|
|
134
157
|
role: 'user',
|
|
135
158
|
content: [{ type: 'text', text: one.text }],
|
|
136
|
-
|
|
137
|
-
id: `${entry.identity}:${at}`,
|
|
138
|
-
type: 'file',
|
|
139
|
-
name,
|
|
140
|
-
status: { type: 'complete' },
|
|
141
|
-
content: [],
|
|
142
|
-
})),
|
|
143
|
-
metadata: { custom: { ...custom, unknown } },
|
|
159
|
+
metadata: { custom: { ...custom, unknown, transcripts: one.transcripts } },
|
|
144
160
|
}));
|
|
145
161
|
}
|
|
146
162
|
const failed = one.failure === null
|
|
@@ -156,7 +172,14 @@ export function chatMessages(view) {
|
|
|
156
172
|
role: 'assistant',
|
|
157
173
|
content: contentOf(entry.identity, one.parts, false),
|
|
158
174
|
status: failed,
|
|
159
|
-
metadata: {
|
|
175
|
+
metadata: {
|
|
176
|
+
custom: {
|
|
177
|
+
...custom,
|
|
178
|
+
lasting: working,
|
|
179
|
+
again,
|
|
180
|
+
renew: failed !== undefined && one.resumeRefused,
|
|
181
|
+
},
|
|
182
|
+
},
|
|
160
183
|
}));
|
|
161
184
|
});
|
|
162
185
|
if (view.turn === null)
|
package/dist/chat/name.d.ts
CHANGED
package/dist/chat/name.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../src/chat/name.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../src/chat/name.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAM1C,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAUxC;AAgBD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI7C;AAED,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,YAAY,CAc1E"}
|
package/dist/chat/name.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
const INSTANT = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})/g;
|
|
3
|
-
function stamp(at) {
|
|
3
|
+
export function stamp(at) {
|
|
4
4
|
const time = new Date(at);
|
|
5
5
|
return Number.isNaN(time.getTime())
|
|
6
6
|
? ''
|
package/dist/chat/opened.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../../src/chat/opened.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../../src/chat/opened.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtE,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG;IAC/B,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,wBAAgB,SAAS,IAAI,MAAM,CAgBlC"}
|
package/dist/chat/opened.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { requestIn } from './messages.js';
|
|
1
2
|
import { useChat, useChatScope } from './provider.js';
|
|
2
3
|
export function useOpened() {
|
|
3
4
|
const chat = useChat();
|
|
@@ -13,5 +14,6 @@ export function useOpened() {
|
|
|
13
14
|
name: live?.name ?? entry?.agent.name ?? '',
|
|
14
15
|
deleted: known && chat.conversation !== null && by !== null && live === undefined,
|
|
15
16
|
busy: chat.running || asks,
|
|
17
|
+
waits: requestIn(chat.view)?.waiting ?? entry?.waiting === true,
|
|
16
18
|
};
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/chat/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAa,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG/E,KAAK,OAAO,GAAG,SAAS,iBAAiB,EAAE,CAAC;AAE5C,MAAM,MAAM,WAAW,GACnB;IACE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI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AAI,GAClB,WAAW,CAuBb;AAED,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAkB7F;AAED,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,WAAW,CAWvF;AAED,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,CAUlF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,WAAW,CAQxE;AAED,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,EAC9D,KAAK,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,GAC3C,WAAW,CAQb;AAED,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,WAAW,CAQlE"}
|
package/dist/chat/overlay.js
CHANGED
|
@@ -31,11 +31,7 @@ export function sentMessage(key, into, said, turn) {
|
|
|
31
31
|
identity: key,
|
|
32
32
|
turn: turn ?? key,
|
|
33
33
|
text: said.text,
|
|
34
|
-
message: {
|
|
35
|
-
role: 'user',
|
|
36
|
-
text: said.text,
|
|
37
|
-
files: said.files.map((file) => ({ name: file.name })),
|
|
38
|
-
},
|
|
34
|
+
message: { role: 'user', text: said.text },
|
|
39
35
|
},
|
|
40
36
|
],
|
|
41
37
|
},
|
package/dist/chat/parts.d.ts
CHANGED
package/dist/chat/parts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../../src/chat/parts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,MAAM,MAAM,QAAQ,GAAG;IACrB,QAA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O,GAAG,WAAW,GAAG,IAAI,CAK1D;AAED,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,UAAU,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,GAAG,GAAG;IAChB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAIF,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CASvC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC,CA0C7F"}
|
package/dist/chat/parts.js
CHANGED
|
@@ -22,10 +22,11 @@ function partOf(raw) {
|
|
|
22
22
|
return command === null ? null : { type: 'message', command, target: text(part, 'target') };
|
|
23
23
|
}
|
|
24
24
|
case 'image': {
|
|
25
|
+
const path = text(part, 'file');
|
|
25
26
|
const name = text(part, 'name');
|
|
26
|
-
return name === null
|
|
27
|
+
return path === null || name === null
|
|
27
28
|
? null
|
|
28
|
-
: { type: 'image', name, mediaType: text(part, 'media_type') ?? '' };
|
|
29
|
+
: { type: 'image', path, name, mediaType: text(part, 'media_type') ?? '' };
|
|
29
30
|
}
|
|
30
31
|
case 'marker': {
|
|
31
32
|
const marker = text(part, 'marker');
|
package/dist/chat/provider.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { TurnContext } from '../adapter.js';
|
|
|
3
3
|
import type { MdRuntimeClient } from '../client.js';
|
|
4
4
|
import { type ChatDraft, type ConversationAgent, type ConversationEntry, type ConversationView } from '../conversation.js';
|
|
5
5
|
import { type ChatOutcome } from './acts.js';
|
|
6
|
+
import type { ChatRequest } from './house.js';
|
|
6
7
|
import { type ChatCommand, type ChatOption } from './process.js';
|
|
7
8
|
import { type ChatLone, type ChatQuestion } from './questions.js';
|
|
8
9
|
export type ChatOpened = {
|
|
@@ -21,6 +22,7 @@ export type ChatState = ChatOpened & {
|
|
|
21
22
|
readonly conversations: readonly ConversationEntry[];
|
|
22
23
|
readonly agents: readonly ConversationAgent[];
|
|
23
24
|
readonly view: ConversationView | null;
|
|
25
|
+
readonly waiting: ChatRequest | null;
|
|
24
26
|
readonly running: boolean;
|
|
25
27
|
readonly questions: readonly ChatQuestion[];
|
|
26
28
|
readonly lone: ChatLone | null;
|
|
@@ -32,14 +34,17 @@ export type ChatState = ChatOpened & {
|
|
|
32
34
|
readonly again: (() => void) | null;
|
|
33
35
|
};
|
|
34
36
|
readonly acting: ChatActing;
|
|
37
|
+
readonly renewed: boolean;
|
|
35
38
|
open(conversation: string): void;
|
|
36
39
|
start(agent: string): void;
|
|
37
40
|
send(draft: ChatDraft): void;
|
|
41
|
+
attach: ((files: readonly File[]) => Promise<boolean>) | null;
|
|
38
42
|
answer(question: ChatQuestion, response: unknown): Promise<boolean>;
|
|
39
43
|
choose(option: string, value: string): Promise<boolean>;
|
|
40
44
|
stop(): Promise<boolean>;
|
|
41
45
|
kill(): Promise<boolean>;
|
|
42
46
|
retry(message: string): Promise<boolean>;
|
|
47
|
+
renew(): Promise<boolean>;
|
|
43
48
|
done(): Promise<boolean>;
|
|
44
49
|
rename(name: string): Promise<boolean>;
|
|
45
50
|
remove(): Promise<boolean>;
|
|
@@ -50,6 +55,7 @@ export type ChatProviderProps = {
|
|
|
50
55
|
readonly client: MdRuntimeClient;
|
|
51
56
|
readonly conversation?: string | null;
|
|
52
57
|
readonly agent?: string | null;
|
|
58
|
+
readonly attachTo?: string | null;
|
|
53
59
|
readonly onOpen?: (opened: ChatOpened) => void;
|
|
54
60
|
readonly children?: ReactNode;
|
|
55
61
|
};
|
|
@@ -59,6 +65,6 @@ type Scope = {
|
|
|
59
65
|
};
|
|
60
66
|
export declare function useChatScope(): Scope;
|
|
61
67
|
export declare function useChat(): ChatState;
|
|
62
|
-
export declare function ChatProvider({ client, conversation, agent, onOpen, children, }: ChatProviderProps): ReactElement;
|
|
68
|
+
export declare function ChatProvider({ client, conversation, agent, attachTo, onOpen, children, }: ChatProviderProps): ReactElement;
|
|
63
69
|
export {};
|
|
64
70
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/chat/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/chat/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EAML,KAAK,WAAW,EAGjB,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAe9C,OAAO,EAAoC,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C,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;CAC/B,CAAC;AAmJF,KAAK,KAAK,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAI3E,wBAAgB,YAAY,IAAI,KAAK,CAIpC;AAED,wBAAgB,OAAO,IAAI,SAAS,CAInC;AAED,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,YAAmB,EACnB,KAAY,EACZ,QAAe,EACf,MAAM,EACN,QAAQ,GACT,EAAE,iBAAiB,GAAG,YAAY,CAslBlC"}
|
package/dist/chat/provider.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, createElement, useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, } from 'react';
|
|
2
|
-
import { AssistantRuntimeProvider, createMessageQueue,
|
|
2
|
+
import { AssistantRuntimeProvider, createMessageQueue, useExternalStoreRuntime, } from '@assistant-ui/react';
|
|
3
3
|
import { attempts } from '../attempt.js';
|
|
4
4
|
import { newChat, } from '../conversation.js';
|
|
5
5
|
import { expectedList } from '../expectation.js';
|
|
@@ -7,7 +7,7 @@ import { chatDraftRevision } from '../identity.js';
|
|
|
7
7
|
import { useObserve } from '../react.js';
|
|
8
8
|
import { accepted, answeredOf, outcomeOf, sender, unanswered, } from './acts.js';
|
|
9
9
|
import { CHAT_WINDOW, useEarlier } from './earlier.js';
|
|
10
|
-
import { askedBefore, chatMessages, contextOf } from './messages.js';
|
|
10
|
+
import { askedBefore, chatMessages, contextOf, requestIn } from './messages.js';
|
|
11
11
|
import { useSteady } from './steady.js';
|
|
12
12
|
import { conversationChanged, conversationGone, conversationListed, deliveryRetried, optionChosen, overlay, questionAnswered, sentMessage, } from './overlay.js';
|
|
13
13
|
import { commandIn, commandsOf, optionsOf } from './process.js';
|
|
@@ -19,7 +19,7 @@ function sharedOf(client) {
|
|
|
19
19
|
const held = SHARED.get(client);
|
|
20
20
|
if (held !== undefined)
|
|
21
21
|
return held;
|
|
22
|
-
const fresh = { overlay: overlay(), created: new Map(), sends: 0 };
|
|
22
|
+
const fresh = { overlay: overlay(), created: new Map(), renewed: new Set(), sends: 0 };
|
|
23
23
|
SHARED.set(client, fresh);
|
|
24
24
|
return fresh;
|
|
25
25
|
}
|
|
@@ -92,46 +92,20 @@ function useActs(overlay, online) {
|
|
|
92
92
|
return { ...running, call, clear };
|
|
93
93
|
}
|
|
94
94
|
const AS_IT_IS = (message) => message;
|
|
95
|
-
const ATTACHMENTS = {
|
|
96
|
-
accept: '*',
|
|
97
|
-
add: ({ file }) => Promise.resolve({
|
|
98
|
-
id: generateId(),
|
|
99
|
-
type: 'file',
|
|
100
|
-
name: file.name,
|
|
101
|
-
contentType: file.type,
|
|
102
|
-
file,
|
|
103
|
-
status: { type: 'requires-action', reason: 'composer-send' },
|
|
104
|
-
}),
|
|
105
|
-
send: (attachment) => Promise.resolve({ ...attachment, status: { type: 'complete' }, content: [] }),
|
|
106
|
-
remove: () => Promise.resolve(),
|
|
107
|
-
};
|
|
108
|
-
function filesOf(attachments) {
|
|
109
|
-
return attachments.flatMap((one) => one.file === undefined ? [] : [{ name: one.name, blob: one.file }]);
|
|
110
|
-
}
|
|
111
|
-
function fileOf(file) {
|
|
112
|
-
return file.blob instanceof File && file.blob.name === file.name
|
|
113
|
-
? file.blob
|
|
114
|
-
: new File([file.blob], file.name, { type: file.blob.type });
|
|
115
|
-
}
|
|
116
95
|
function textOf(parts) {
|
|
117
96
|
return parts.map((part) => (part.type === 'text' ? (part.text ?? '') : '')).join('');
|
|
118
97
|
}
|
|
119
98
|
function draftOf(message) {
|
|
120
|
-
return { text: textOf(message.content)
|
|
99
|
+
return { text: textOf(message.content) };
|
|
100
|
+
}
|
|
101
|
+
function linkOf(path) {
|
|
102
|
+
return `[${path.slice(path.lastIndexOf('/') + 1)}](${path})`;
|
|
121
103
|
}
|
|
122
104
|
function appended(draft) {
|
|
123
105
|
return {
|
|
124
106
|
role: 'user',
|
|
125
107
|
content: [{ type: 'text', text: draft.text }],
|
|
126
|
-
attachments:
|
|
127
|
-
id: generateId(),
|
|
128
|
-
type: 'file',
|
|
129
|
-
name: file.name,
|
|
130
|
-
contentType: file.blob.type,
|
|
131
|
-
file: fileOf(file),
|
|
132
|
-
status: { type: 'complete' },
|
|
133
|
-
content: [],
|
|
134
|
-
})),
|
|
108
|
+
attachments: [],
|
|
135
109
|
metadata: { custom: {} },
|
|
136
110
|
createdAt: new Date(),
|
|
137
111
|
parentId: null,
|
|
@@ -139,9 +113,6 @@ function appended(draft) {
|
|
|
139
113
|
runConfig: undefined,
|
|
140
114
|
};
|
|
141
115
|
}
|
|
142
|
-
function composed(state) {
|
|
143
|
-
return JSON.stringify([state.text, state.attachments.map((one) => one.id)]);
|
|
144
|
-
}
|
|
145
116
|
const ChatContext = createContext(null);
|
|
146
117
|
const ScopeContext = createContext(null);
|
|
147
118
|
export function useChatScope() {
|
|
@@ -156,7 +127,7 @@ export function useChat() {
|
|
|
156
127
|
throw new Error('useChat is called outside a ChatProvider');
|
|
157
128
|
return chat;
|
|
158
129
|
}
|
|
159
|
-
export function ChatProvider({ client, conversation = null, agent = null, onOpen, children, }) {
|
|
130
|
+
export function ChatProvider({ client, conversation = null, agent = null, attachTo = null, onOpen, children, }) {
|
|
160
131
|
const shared = sharedOf(client);
|
|
161
132
|
const asked = JSON.stringify([conversation, agent]);
|
|
162
133
|
const [followed, setFollowed] = useState(asked);
|
|
@@ -204,6 +175,10 @@ export function ChatProvider({ client, conversation = null, agent = null, onOpen
|
|
|
204
175
|
const lone = loneOf(questions);
|
|
205
176
|
const commands = useMemo(() => commandsOf(view), [view]);
|
|
206
177
|
const messages = useMemo(() => chatMessages(view), [view]);
|
|
178
|
+
const awaiting = useMemo(() => {
|
|
179
|
+
const held = requestIn(view);
|
|
180
|
+
return held?.waiting === true ? held.request : null;
|
|
181
|
+
}, [view]);
|
|
207
182
|
const sending = useActs(shared.overlay, online);
|
|
208
183
|
const behind = useActs(shared.overlay, online);
|
|
209
184
|
const acting = useActs(shared.overlay, online);
|
|
@@ -226,7 +201,7 @@ export function ChatProvider({ client, conversation = null, agent = null, onOpen
|
|
|
226
201
|
own.current = [...own.current, `${to}\u0000${revision ?? ''}`];
|
|
227
202
|
}, []);
|
|
228
203
|
const keep = useCallback((to, draft) => {
|
|
229
|
-
const revision = draft.text === ''
|
|
204
|
+
const revision = draft.text === '' ? null : chatDraftRevision();
|
|
230
205
|
noted(to, revision);
|
|
231
206
|
void (revision === null
|
|
232
207
|
? client.chatDraft.discard(to)
|
|
@@ -332,6 +307,20 @@ export function ChatProvider({ client, conversation = null, agent = null, onOpen
|
|
|
332
307
|
return Promise.resolve(false);
|
|
333
308
|
return control('conversation.retry', { conversation_id: to, message_id: message }, deliveryRetried(to, message));
|
|
334
309
|
};
|
|
310
|
+
const renew = () => {
|
|
311
|
+
const from = opened.current.conversation;
|
|
312
|
+
const by = conversations.find((one) => one.conversation === from)?.agent.identity ??
|
|
313
|
+
opened.current.agent;
|
|
314
|
+
if (from === null || by === null)
|
|
315
|
+
return Promise.resolve(false);
|
|
316
|
+
return acting.call((send) => send.carried('conversation.create', { agent: by, replaces: from }, (operation) => client.conversation.create({ agent_id: by, operation_id: operation, replaces: from })), null, (result) => {
|
|
317
|
+
const conversation = text(record(result), 'conversation');
|
|
318
|
+
if (conversation === null)
|
|
319
|
+
return;
|
|
320
|
+
shared.renewed.add(conversation);
|
|
321
|
+
go({ conversation, agent: by });
|
|
322
|
+
});
|
|
323
|
+
};
|
|
335
324
|
const done = (to = opened.current.conversation) => to === null
|
|
336
325
|
? Promise.resolve(false)
|
|
337
326
|
: control('conversation.markDone', { conversation_id: to }, conversationChanged(to, { finished: new Date().toISOString() }, (one) => one.finished !== null));
|
|
@@ -421,12 +410,11 @@ export function ChatProvider({ client, conversation = null, agent = null, onOpen
|
|
|
421
410
|
const said = askedBefore(view, parent);
|
|
422
411
|
if (said === null)
|
|
423
412
|
return;
|
|
424
|
-
const draft = { text: said
|
|
413
|
+
const draft = { text: said };
|
|
425
414
|
const into = thread;
|
|
426
415
|
deliverDraft(draft, () => back(draft, into), () => undefined);
|
|
427
416
|
},
|
|
428
417
|
adapters: {
|
|
429
|
-
attachments: ATTACHMENTS,
|
|
430
418
|
threadList: {
|
|
431
419
|
...(thread === null ? {} : { threadId: thread }),
|
|
432
420
|
threads: threads.regular,
|
|
@@ -457,9 +445,33 @@ export function ChatProvider({ client, conversation = null, agent = null, onOpen
|
|
|
457
445
|
const composer = aui.thread.composer;
|
|
458
446
|
const now = composer.getState().text;
|
|
459
447
|
composer.setText(now === '' ? one.text : `${one.text}\n${now}`);
|
|
460
|
-
for (const file of one.files)
|
|
461
|
-
void composer.addAttachment(fileOf(file));
|
|
462
448
|
}
|
|
449
|
+
function linked(path, into) {
|
|
450
|
+
if (current.current !== into) {
|
|
451
|
+
void client.chatDraft.prepend(into, { text: linkOf(path) });
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
const composer = aui.thread.composer;
|
|
455
|
+
const now = composer.getState().text;
|
|
456
|
+
composer.setText(now === '' ? linkOf(path) : `${now}\n${linkOf(path)}`);
|
|
457
|
+
}
|
|
458
|
+
const attach = (room, files) => {
|
|
459
|
+
const into = thread;
|
|
460
|
+
if (into === null || files.length === 0)
|
|
461
|
+
return Promise.resolve(false);
|
|
462
|
+
return acting.call(async (send) => {
|
|
463
|
+
let result = { kind: 'offline' };
|
|
464
|
+
for (const file of files) {
|
|
465
|
+
result = await send.numbered('conversation.attach', { room, name: file.name }, () => client.conversation.attach(room, { name: file.name, blob: file }));
|
|
466
|
+
if (!accepted(result))
|
|
467
|
+
return result;
|
|
468
|
+
const path = text(record(result.result), 'path');
|
|
469
|
+
if (path !== null)
|
|
470
|
+
linked(path, into);
|
|
471
|
+
}
|
|
472
|
+
return result;
|
|
473
|
+
});
|
|
474
|
+
};
|
|
463
475
|
function taken(message) {
|
|
464
476
|
const said = textOf(message.content);
|
|
465
477
|
if (lone === null || commandIn(said, commands))
|
|
@@ -527,7 +539,7 @@ export function ChatProvider({ client, conversation = null, agent = null, onOpen
|
|
|
527
539
|
const message = unqueue(id);
|
|
528
540
|
if (thread === null || item === undefined)
|
|
529
541
|
return;
|
|
530
|
-
back(message === undefined ? { text: textOf(item.parts)
|
|
542
|
+
back(message === undefined ? { text: textOf(item.parts) } : draftOf(message), thread);
|
|
531
543
|
};
|
|
532
544
|
const reconcile = useRef(() => undefined);
|
|
533
545
|
reconcile.current = () => {
|
|
@@ -546,44 +558,25 @@ export function ChatProvider({ client, conversation = null, agent = null, onOpen
|
|
|
546
558
|
}
|
|
547
559
|
own.current = own.current.filter((one) => !one.startsWith(at));
|
|
548
560
|
const composer = aui.thread.composer;
|
|
549
|
-
const
|
|
561
|
+
const typed = composer.getState().text;
|
|
550
562
|
const stored = view.chatDraft;
|
|
551
|
-
const
|
|
552
|
-
const kept = !known && (typed.text !== '' || typed.files.length > 0);
|
|
563
|
+
const kept = !known && typed !== '';
|
|
553
564
|
if (kept && stored === null) {
|
|
554
|
-
shown.current = `${at}${
|
|
555
|
-
keep(thread, typed);
|
|
565
|
+
shown.current = `${at}${typed}`;
|
|
566
|
+
keep(thread, { text: typed });
|
|
556
567
|
return;
|
|
557
568
|
}
|
|
558
569
|
const draft = kept
|
|
559
|
-
?
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
: stored;
|
|
564
|
-
if (state.text === (draft?.text ?? '') &&
|
|
565
|
-
state.attachments.length === 0 &&
|
|
566
|
-
(draft?.files.length ?? 0) === 0) {
|
|
567
|
-
shown.current = `${at}${composed(state)}`;
|
|
570
|
+
? [stored?.text ?? '', typed].filter((one) => one !== '').join('\n')
|
|
571
|
+
: (stored?.text ?? '');
|
|
572
|
+
shown.current = `${at}${draft}`;
|
|
573
|
+
if (typed === draft)
|
|
568
574
|
return;
|
|
569
|
-
}
|
|
570
575
|
seeding.current = true;
|
|
571
|
-
composer.setText(draft
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
.finally(() => {
|
|
576
|
-
seeding.current = false;
|
|
577
|
-
if (current.current !== thread) {
|
|
578
|
-
reconcile.current();
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
const seeded = composer.getState();
|
|
582
|
-
shown.current = `${at}${composed(seeded)}`;
|
|
583
|
-
if (kept)
|
|
584
|
-
keep(thread, { text: seeded.text, files: filesOf(seeded.attachments) });
|
|
585
|
-
reconcile.current();
|
|
586
|
-
});
|
|
576
|
+
composer.setText(draft);
|
|
577
|
+
seeding.current = false;
|
|
578
|
+
if (kept)
|
|
579
|
+
keep(thread, { text: draft });
|
|
587
580
|
};
|
|
588
581
|
useEffect(() => reconcile.current(), [aui, thread, view]);
|
|
589
582
|
useEffect(() => {
|
|
@@ -594,12 +587,12 @@ export function ChatProvider({ client, conversation = null, agent = null, onOpen
|
|
|
594
587
|
return composer.subscribe(() => {
|
|
595
588
|
if (seeding.current || !heard.current.startsWith(at))
|
|
596
589
|
return;
|
|
597
|
-
const
|
|
598
|
-
const next = `${at}${
|
|
590
|
+
const typed = composer.getState().text;
|
|
591
|
+
const next = `${at}${typed}`;
|
|
599
592
|
if (next === shown.current)
|
|
600
593
|
return;
|
|
601
594
|
shown.current = next;
|
|
602
|
-
keep(thread, { text:
|
|
595
|
+
keep(thread, { text: typed });
|
|
603
596
|
});
|
|
604
597
|
}, [aui, thread, keep]);
|
|
605
598
|
const queued = lanes().map((item) => ({ id: item.id, text: textOf(item.parts) }));
|
|
@@ -608,6 +601,7 @@ export function ChatProvider({ client, conversation = null, agent = null, onOpen
|
|
|
608
601
|
conversations,
|
|
609
602
|
agents,
|
|
610
603
|
view,
|
|
604
|
+
waiting: awaiting,
|
|
611
605
|
running,
|
|
612
606
|
questions,
|
|
613
607
|
lone,
|
|
@@ -617,14 +611,17 @@ export function ChatProvider({ client, conversation = null, agent = null, onOpen
|
|
|
617
611
|
queued,
|
|
618
612
|
sending: { busy: sending.busy, outcome: sending.outcome, again },
|
|
619
613
|
acting: { busy: acting.busy, outcome: acting.outcome },
|
|
614
|
+
renewed: open.conversation !== null && shared.renewed.has(open.conversation),
|
|
620
615
|
open: openConversation,
|
|
621
616
|
start,
|
|
622
617
|
send: (draft) => lined().enqueue(appended(draft)),
|
|
618
|
+
attach: attachTo === null ? null : (files) => attach(attachTo, files),
|
|
623
619
|
answer,
|
|
624
620
|
choose,
|
|
625
621
|
stop,
|
|
626
622
|
kill,
|
|
627
623
|
retry,
|
|
624
|
+
renew,
|
|
628
625
|
done: () => done(),
|
|
629
626
|
rename: (name) => rename(name),
|
|
630
627
|
remove: () => remove(),
|
package/dist/chat/ready.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactElement, type ReactNode } from 'react';
|
|
2
2
|
import type { MdRuntimeClient } from '../client.js';
|
|
3
|
+
import type { ChatRequest } from './house.js';
|
|
3
4
|
import { type ChatNoteProps } from './kit.js';
|
|
4
5
|
import { type AgentLook } from './list.js';
|
|
5
6
|
import { type ChatOpened, type ChatState } from './provider.js';
|
|
@@ -8,6 +9,7 @@ export type ChatProps = AgentLook & {
|
|
|
8
9
|
readonly client?: MdRuntimeClient;
|
|
9
10
|
readonly conversation?: string | null;
|
|
10
11
|
readonly agent?: string | null;
|
|
12
|
+
readonly attachTo?: string | null;
|
|
11
13
|
readonly onOpen?: (opened: ChatOpened) => void;
|
|
12
14
|
readonly width?: ChatWidth;
|
|
13
15
|
readonly showChats?: boolean;
|
|
@@ -20,8 +22,9 @@ export type ChatProps = AgentLook & {
|
|
|
20
22
|
readonly waiting?: (chat: ChatState) => string | null;
|
|
21
23
|
readonly messageLength?: number;
|
|
22
24
|
readonly autoFocus?: boolean;
|
|
25
|
+
readonly decision?: (request: ChatRequest) => ReactNode;
|
|
23
26
|
};
|
|
24
|
-
export declare function Chat({ client, conversation, agent, onOpen, ...look }: ChatProps): ReactElement;
|
|
27
|
+
export declare function Chat({ client, conversation, agent, attachTo, onOpen, ...look }: ChatProps): ReactElement;
|
|
25
28
|
export type MountedChat = {
|
|
26
29
|
update(props: ChatProps & {
|
|
27
30
|
readonly client: MdRuntimeClient;
|