@agentshouse/mdruntime 0.1.0-c5f333dfa0583 → 0.1.0-c5fe3b2cddda7
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/README.md +10 -8
- package/dist/adapter.d.ts +39 -40
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +2 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +28 -4
- 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 +16 -8
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +142 -94
- package/dist/change-set.d.ts +1 -7
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +1 -4
- package/dist/client.d.ts +6 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +54 -7
- package/dist/collection.d.ts +5 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +24 -19
- package/dist/compile.d.ts +6 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +94 -33
- package/dist/connection.d.ts +8 -7
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1160 -1151
- package/dist/conversation.d.ts +7 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +171 -55
- package/dist/durability.d.ts +1 -5
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +1 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +1 -1
- package/dist/file.d.ts +2 -11
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +6 -4
- package/dist/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +370 -0
- package/dist/host.d.ts +3 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +42 -18
- 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 +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +2 -1
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +3 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +93 -38
- package/dist/messages.d.ts +28 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +90 -0
- package/dist/model.d.ts +6 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -10
- package/dist/observation.d.ts +1 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +1 -1
- package/dist/outcome.d.ts +13 -6
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +16 -5
- package/dist/overlay.js +1 -1
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/query.d.ts +10 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +12 -1
- package/dist/reach.d.ts +8 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +69 -46
- package/dist/readiness.d.ts +14 -15
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +2 -8
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +26 -0
- package/dist/refresh.d.ts +9 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +64 -30
- package/dist/replica.d.ts +5 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +4 -7
- package/dist/room-draft.d.ts +18 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +73 -6
- package/dist/rows.d.ts +15 -6
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +102 -74
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +13 -7
- package/dist/search.d.ts +11 -43
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +0 -296
- package/dist/shared.d.ts +0 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +0 -10
- package/dist/status.d.ts +4 -3
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -1
- package/dist/store.d.ts +23 -58
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +37 -272
- package/dist/stored.d.ts +10 -23
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +217 -218
- package/dist/tables.d.ts +51 -46
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +94 -53
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/validation.d.ts +3 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +35 -96
- package/dist/wire.d.ts +5 -5
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -2
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +156 -0
- package/package.json +11 -19
- package/AGENTS.md +0 -312
- package/dist/chat/acts.d.ts +0 -33
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/context.d.ts +0 -3
- package/dist/chat/context.d.ts.map +0 -1
- package/dist/chat/context.js +0 -10
- package/dist/chat/earlier.d.ts +0 -10
- package/dist/chat/earlier.d.ts.map +0 -1
- package/dist/chat/earlier.js +0 -54
- package/dist/chat/house.d.ts +0 -25
- package/dist/chat/house.d.ts.map +0 -1
- package/dist/chat/house.js +0 -38
- package/dist/chat/input.d.ts +0 -11
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -92
- package/dist/chat/kit.d.ts +0 -61
- package/dist/chat/kit.d.ts.map +0 -1
- package/dist/chat/kit.js +0 -123
- package/dist/chat/lasting.d.ts +0 -6
- package/dist/chat/lasting.d.ts.map +0 -1
- package/dist/chat/lasting.js +0 -19
- package/dist/chat/list.d.ts +0 -28
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -103
- package/dist/chat/markdown.d.ts +0 -21
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -246
- package/dist/chat/message.d.ts +0 -7
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -254
- package/dist/chat/messages.d.ts +0 -35
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -210
- package/dist/chat/name.d.ts +0 -7
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -12
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -19
- package/dist/chat/overlay.d.ts +0 -32
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -103
- package/dist/chat/parts.d.ts +0 -58
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -120
- package/dist/chat/pieces.d.ts +0 -62
- package/dist/chat/pieces.d.ts.map +0 -1
- package/dist/chat/pieces.js +0 -1110
- package/dist/chat/process.d.ts +0 -20
- package/dist/chat/process.d.ts.map +0 -1
- package/dist/chat/process.js +0 -32
- package/dist/chat/provider.d.ts +0 -70
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -635
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -69
- package/dist/chat/questions.d.ts +0 -31
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/questions.js +0 -111
- package/dist/chat/read.d.ts +0 -5
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/read.js +0 -13
- package/dist/chat/ready.d.ts +0 -37
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -93
- package/dist/chat/room-file.d.ts +0 -8
- package/dist/chat/room-file.d.ts.map +0 -1
- package/dist/chat/room-file.js +0 -72
- package/dist/chat/steady.d.ts +0 -3
- package/dist/chat/steady.d.ts.map +0 -1
- package/dist/chat/steady.js +0 -26
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -307
- package/dist/chat.d.ts +0 -15
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -8
- package/dist/reads.d.ts +0 -11
- package/dist/reads.d.ts.map +0 -1
- package/dist/reads.js +0 -98
package/dist/chat/messages.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { sourceOf } from './house.js';
|
|
2
|
-
import { contextIn, jobOf, partsOf, stillRunning } from './parts.js';
|
|
3
|
-
import { list, record, text } from './read.js';
|
|
4
|
-
const SAID = new WeakMap();
|
|
5
|
-
const CONVERTED = new WeakMap();
|
|
6
|
-
export function saidOf(entry) {
|
|
7
|
-
const held = SAID.get(entry);
|
|
8
|
-
if (held !== undefined)
|
|
9
|
-
return held;
|
|
10
|
-
const message = record(entry.message);
|
|
11
|
-
const house = text(message, 'role') === 'house';
|
|
12
|
-
const said = {
|
|
13
|
-
turn: text(message, 'turn_id') ?? entry.turn,
|
|
14
|
-
user: text(message, 'role') === 'user',
|
|
15
|
-
house,
|
|
16
|
-
source: house ? sourceOf(message.source) : null,
|
|
17
|
-
waiting: message.waiting === true,
|
|
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
|
-
}),
|
|
24
|
-
parts: partsOf(list(message, 'parts')),
|
|
25
|
-
context: contextIn(message.context),
|
|
26
|
-
failure: text(message, 'failure'),
|
|
27
|
-
resumeRefused: message.resume_refused === true,
|
|
28
|
-
undelivered: message.telegram_undelivered === true,
|
|
29
|
-
};
|
|
30
|
-
SAID.set(entry, said);
|
|
31
|
-
return said;
|
|
32
|
-
}
|
|
33
|
-
function sameWork(held, now) {
|
|
34
|
-
return (held.length === now.length &&
|
|
35
|
-
held.every((one, at) => one.kind === now[at].kind && one.title === now[at].title && one.next === now[at].next));
|
|
36
|
-
}
|
|
37
|
-
function converted(entry, lasting, again, unknown, convert) {
|
|
38
|
-
const held = CONVERTED.get(entry);
|
|
39
|
-
if (held !== undefined &&
|
|
40
|
-
held.again === again &&
|
|
41
|
-
held.unknown === unknown &&
|
|
42
|
-
sameWork(held.lasting, lasting)) {
|
|
43
|
-
return held.message;
|
|
44
|
-
}
|
|
45
|
-
const message = convert();
|
|
46
|
-
CONVERTED.set(entry, { lasting, again, unknown, message });
|
|
47
|
-
return message;
|
|
48
|
-
}
|
|
49
|
-
function markerArgs(part) {
|
|
50
|
-
if (part.marker !== 'job')
|
|
51
|
-
return { marker: part.marker, text: part.text };
|
|
52
|
-
const job = jobOf(part.text);
|
|
53
|
-
return {
|
|
54
|
-
marker: part.marker,
|
|
55
|
-
text: part.text,
|
|
56
|
-
job: job.kind,
|
|
57
|
-
label: job.label,
|
|
58
|
-
state: job.state,
|
|
59
|
-
next: job.next ?? '',
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function contentOf(id, parts, live) {
|
|
63
|
-
return parts.map((part, at) => {
|
|
64
|
-
const done = !live || at < parts.length - 1;
|
|
65
|
-
const call = (toolName, args) => ({
|
|
66
|
-
type: 'tool-call',
|
|
67
|
-
toolCallId: `${id}:${at}`,
|
|
68
|
-
toolName,
|
|
69
|
-
args,
|
|
70
|
-
result: done ? null : undefined,
|
|
71
|
-
});
|
|
72
|
-
switch (part.type) {
|
|
73
|
-
case 'text':
|
|
74
|
-
return { type: 'text', text: part.text };
|
|
75
|
-
case 'reasoning':
|
|
76
|
-
return { type: 'reasoning', text: part.text };
|
|
77
|
-
case 'commands':
|
|
78
|
-
return call('commands', { count: part.count });
|
|
79
|
-
case 'subagent':
|
|
80
|
-
return {
|
|
81
|
-
...call('subagent', { description: part.description }),
|
|
82
|
-
result: part.done ? part.result : undefined,
|
|
83
|
-
};
|
|
84
|
-
case 'message':
|
|
85
|
-
return call('message', { command: part.command, target: part.target ?? '' });
|
|
86
|
-
case 'marker':
|
|
87
|
-
return call('marker', markerArgs(part));
|
|
88
|
-
case 'plan':
|
|
89
|
-
return {
|
|
90
|
-
...call('plan', {}),
|
|
91
|
-
args: { steps: part.steps.map((step) => ({ ...step })) },
|
|
92
|
-
};
|
|
93
|
-
case 'image':
|
|
94
|
-
return { type: 'file', filename: part.name, mimeType: part.mediaType, data: part.path };
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
function leftRunning(view) {
|
|
99
|
-
if (view.process?.running === false)
|
|
100
|
-
return new Map();
|
|
101
|
-
const turns = view.messages.flatMap((entry) => {
|
|
102
|
-
const one = saidOf(entry);
|
|
103
|
-
return one.user || one.house ? [] : [{ turn: one.turn, parts: one.parts, ended: true }];
|
|
104
|
-
});
|
|
105
|
-
return stillRunning(view.turn === null
|
|
106
|
-
? turns
|
|
107
|
-
: [...turns, { turn: view.turn.turn, parts: partsOf(view.turn.parts), ended: false }]);
|
|
108
|
-
}
|
|
109
|
-
export function awaitsTurn(view) {
|
|
110
|
-
const newest = view?.messages.at(-1);
|
|
111
|
-
if (view?.turn !== null || newest === undefined)
|
|
112
|
-
return false;
|
|
113
|
-
const said = saidOf(newest);
|
|
114
|
-
return said.user || (said.house && !said.waiting);
|
|
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
|
-
}
|
|
124
|
-
export function askedBefore(view, id) {
|
|
125
|
-
const said = (view?.messages ?? []).map((entry) => ({ ...saidOf(entry), id: entry.identity }));
|
|
126
|
-
const asked = said
|
|
127
|
-
.slice(0, said.findIndex((one) => one.id === id) + 1)
|
|
128
|
-
.reverse()
|
|
129
|
-
.find((one) => one.user || one.house);
|
|
130
|
-
return asked === undefined || asked.house || asked.text === '' ? null : asked.text;
|
|
131
|
-
}
|
|
132
|
-
export function chatMessages(view) {
|
|
133
|
-
if (view === null)
|
|
134
|
-
return [];
|
|
135
|
-
const lasting = leftRunning(view);
|
|
136
|
-
const said = view.messages.map((entry, at) => {
|
|
137
|
-
const one = saidOf(entry);
|
|
138
|
-
const custom = { undelivered: one.undelivered };
|
|
139
|
-
if (one.house)
|
|
140
|
-
return converted(entry, [], false, false, () => ({
|
|
141
|
-
id: entry.identity,
|
|
142
|
-
role: 'system',
|
|
143
|
-
content: [{ type: 'text', text: one.text }],
|
|
144
|
-
metadata: {
|
|
145
|
-
custom: {
|
|
146
|
-
...custom,
|
|
147
|
-
source: one.source,
|
|
148
|
-
waiting: one.waiting,
|
|
149
|
-
transcripts: one.transcripts,
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
}));
|
|
153
|
-
if (one.user) {
|
|
154
|
-
const unknown = view.deliveryUnknown.includes(entry.identity);
|
|
155
|
-
return converted(entry, [], false, unknown, () => ({
|
|
156
|
-
id: entry.identity,
|
|
157
|
-
role: 'user',
|
|
158
|
-
content: [{ type: 'text', text: one.text }],
|
|
159
|
-
metadata: { custom: { ...custom, unknown, transcripts: one.transcripts } },
|
|
160
|
-
}));
|
|
161
|
-
}
|
|
162
|
-
const failed = one.failure === null
|
|
163
|
-
? undefined
|
|
164
|
-
: { type: 'incomplete', reason: 'error', error: one.failure };
|
|
165
|
-
const working = lasting.get(one.turn) ?? [];
|
|
166
|
-
const again = failed !== undefined &&
|
|
167
|
-
view.turn === null &&
|
|
168
|
-
at === view.messages.length - 1 &&
|
|
169
|
-
askedBefore(view, view.messages[at - 1]?.identity ?? null) !== null;
|
|
170
|
-
return converted(entry, working, again, false, () => ({
|
|
171
|
-
id: entry.identity,
|
|
172
|
-
role: 'assistant',
|
|
173
|
-
content: contentOf(entry.identity, one.parts, false),
|
|
174
|
-
status: failed,
|
|
175
|
-
metadata: {
|
|
176
|
-
custom: {
|
|
177
|
-
...custom,
|
|
178
|
-
lasting: working,
|
|
179
|
-
again,
|
|
180
|
-
renew: failed !== undefined && one.resumeRefused,
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
}));
|
|
184
|
-
});
|
|
185
|
-
if (view.turn === null)
|
|
186
|
-
return said;
|
|
187
|
-
const running = `running:${view.turn.turn}`;
|
|
188
|
-
return [
|
|
189
|
-
...said,
|
|
190
|
-
{
|
|
191
|
-
id: running,
|
|
192
|
-
role: 'assistant',
|
|
193
|
-
content: contentOf(running, partsOf(view.turn.parts), true),
|
|
194
|
-
status: { type: 'running' },
|
|
195
|
-
},
|
|
196
|
-
];
|
|
197
|
-
}
|
|
198
|
-
export function contextOf(view) {
|
|
199
|
-
if (view === null)
|
|
200
|
-
return null;
|
|
201
|
-
const running = view.turn === null ? null : contextIn(view.turn.context);
|
|
202
|
-
if (running !== null)
|
|
203
|
-
return running;
|
|
204
|
-
for (const entry of [...view.messages].reverse()) {
|
|
205
|
-
const held = contextIn(record(entry.message).context);
|
|
206
|
-
if (held !== null)
|
|
207
|
-
return held;
|
|
208
|
-
}
|
|
209
|
-
return null;
|
|
210
|
-
}
|
package/dist/chat/name.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ReactElement } from 'react';
|
|
2
|
-
export declare function stamp(at: string): string;
|
|
3
|
-
export declare function readable(name: string): string;
|
|
4
|
-
export declare function ChatName({ name }: {
|
|
5
|
-
readonly name: string;
|
|
6
|
-
}): ReactElement;
|
|
7
|
-
//# sourceMappingURL=name.d.ts.map
|
package/dist/chat/name.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
const INSTANT = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})/g;
|
|
3
|
-
export function stamp(at) {
|
|
4
|
-
const time = new Date(at);
|
|
5
|
-
return Number.isNaN(time.getTime())
|
|
6
|
-
? ''
|
|
7
|
-
: time.toLocaleString('en-US', {
|
|
8
|
-
month: 'short',
|
|
9
|
-
day: 'numeric',
|
|
10
|
-
hour: '2-digit',
|
|
11
|
-
minute: '2-digit',
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
function partsOf(name) {
|
|
15
|
-
const parts = [];
|
|
16
|
-
let from = 0;
|
|
17
|
-
for (const found of name.matchAll(INSTANT)) {
|
|
18
|
-
const shown = stamp(found[0]);
|
|
19
|
-
if (shown === '')
|
|
20
|
-
continue;
|
|
21
|
-
if (found.index > from)
|
|
22
|
-
parts.push({ text: name.slice(from, found.index), at: null });
|
|
23
|
-
parts.push({ text: shown, at: found[0] });
|
|
24
|
-
from = found.index + found[0].length;
|
|
25
|
-
}
|
|
26
|
-
if (from < name.length)
|
|
27
|
-
parts.push({ text: name.slice(from), at: null });
|
|
28
|
-
return parts;
|
|
29
|
-
}
|
|
30
|
-
export function readable(name) {
|
|
31
|
-
return partsOf(name)
|
|
32
|
-
.map((part) => part.text)
|
|
33
|
-
.join('');
|
|
34
|
-
}
|
|
35
|
-
export function ChatName({ name }) {
|
|
36
|
-
return (_jsx(_Fragment, { children: partsOf(name).map((part, at) => part.at === null ? (part.text) : (_jsx("time", { dateTime: part.at, children: part.text }, at))) }));
|
|
37
|
-
}
|
package/dist/chat/opened.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ConversationEntry } from '../conversation.js';
|
|
2
|
-
import { type ChatState } from './provider.js';
|
|
3
|
-
export type Opened = ChatState & {
|
|
4
|
-
readonly entry: ConversationEntry | undefined;
|
|
5
|
-
readonly by: string | null;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly deleted: boolean;
|
|
8
|
-
readonly busy: boolean;
|
|
9
|
-
readonly waits: boolean;
|
|
10
|
-
};
|
|
11
|
-
export declare function useOpened(): Opened;
|
|
12
|
-
//# sourceMappingURL=opened.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { requestIn } from './messages.js';
|
|
2
|
-
import { useChat, useChatScope } from './provider.js';
|
|
3
|
-
export function useOpened() {
|
|
4
|
-
const chat = useChat();
|
|
5
|
-
const { known } = useChatScope();
|
|
6
|
-
const entry = chat.conversations.find((one) => one.conversation === chat.conversation);
|
|
7
|
-
const by = entry?.agent.identity ?? chat.agent;
|
|
8
|
-
const live = chat.agents.find((one) => one.identity === by);
|
|
9
|
-
const asks = chat.view?.process?.running === true && chat.questions.length > 0;
|
|
10
|
-
return {
|
|
11
|
-
...chat,
|
|
12
|
-
entry,
|
|
13
|
-
by,
|
|
14
|
-
name: live?.name ?? entry?.agent.name ?? '',
|
|
15
|
-
deleted: known && chat.conversation !== null && by !== null && live === undefined,
|
|
16
|
-
busy: chat.running || asks,
|
|
17
|
-
waits: requestIn(chat.view)?.waiting ?? entry?.waiting === true,
|
|
18
|
-
};
|
|
19
|
-
}
|
package/dist/chat/overlay.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ChatDraft, ConversationEntry, ConversationView } from '../conversation.js';
|
|
2
|
-
import { type ExpectedOf, type Expecting } from '../expectation.js';
|
|
3
|
-
type Entries = readonly ConversationEntry[];
|
|
4
|
-
export type Expectation = {
|
|
5
|
-
readonly key: string;
|
|
6
|
-
readonly view: 'conversation';
|
|
7
|
-
draw(held: ConversationView): ConversationView;
|
|
8
|
-
shown(held: ConversationView): boolean;
|
|
9
|
-
} | {
|
|
10
|
-
readonly key: string;
|
|
11
|
-
readonly view: 'conversations';
|
|
12
|
-
draw(held: Entries): Entries;
|
|
13
|
-
shown(held: Entries): boolean;
|
|
14
|
-
};
|
|
15
|
-
export type Expected = ExpectedOf<Expectation>;
|
|
16
|
-
export type Overlay = Omit<Expecting<Expectation>, 'expect' | 'heard' | 'drawn'> & {
|
|
17
|
-
expect(act: number, expected: Expected): void;
|
|
18
|
-
heard(held: ConversationView): void;
|
|
19
|
-
heardList(held: Entries): void;
|
|
20
|
-
conversation(held: ConversationView): ConversationView;
|
|
21
|
-
conversations(held: Entries): Entries;
|
|
22
|
-
};
|
|
23
|
-
export declare function overlay(): Overlay;
|
|
24
|
-
export declare function sentMessage(key: string, into: readonly string[], said: ChatDraft, turn: string | null): Expectation;
|
|
25
|
-
export declare function optionChosen(conversation: string, option: string, value: string): Expectation;
|
|
26
|
-
export declare function questionAnswered(conversation: string, interaction: string): Expectation;
|
|
27
|
-
export declare function deliveryRetried(conversation: string, message: string): Expectation;
|
|
28
|
-
export declare function conversationListed(entry: ConversationEntry): Expectation;
|
|
29
|
-
export declare function conversationChanged(conversation: string, changes: Partial<Pick<ConversationEntry, 'name' | 'finished'>>, shown: (entry: ConversationEntry) => boolean): Expectation;
|
|
30
|
-
export declare function conversationGone(conversation: string): Expectation;
|
|
31
|
-
export {};
|
|
32
|
-
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,EAAE,cAAc,CAAC;IAC9B,IAAI,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IAC/C,KAAK,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC;CACxC,GACD;IACE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IAC7B,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;CAC/B,CAAC;AAEN,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;AAE/C,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC,GAAG;IACjF,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC9C,KAAK,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACpC,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IACvD,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;CACvC,CAAC;AAEF,wBAAgB,OAAO,IAAI,OAAO,CAiBjC;AAED,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,MAAM,GAAG,IAAI,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
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { expecting } from '../expectation.js';
|
|
2
|
-
import { record, text } from './read.js';
|
|
3
|
-
export function overlay() {
|
|
4
|
-
const held = expecting();
|
|
5
|
-
return {
|
|
6
|
-
subscribe: held.subscribe,
|
|
7
|
-
version: held.version,
|
|
8
|
-
begin: held.begin,
|
|
9
|
-
drop: held.drop,
|
|
10
|
-
expect: (act, expected) => held.expect(act, expected),
|
|
11
|
-
heard: (view) => held.heard((one) => one.view === 'conversation' && one.shown(view)),
|
|
12
|
-
heardList: (entries) => held.heard((one) => one.view === 'conversations' && one.shown(entries)),
|
|
13
|
-
conversation: (view) => held.drawn().reduce((now, one) => (one.view === 'conversation' ? one.draw(now) : now), view),
|
|
14
|
-
conversations: (entries) => held
|
|
15
|
-
.drawn()
|
|
16
|
-
.reduce((now, one) => (one.view === 'conversations' ? one.draw(now) : now), entries),
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export function sentMessage(key, into, said, turn) {
|
|
20
|
-
const sealed = (held) => turn !== null && held.messages.some((one) => one.turn === turn);
|
|
21
|
-
return {
|
|
22
|
-
key,
|
|
23
|
-
view: 'conversation',
|
|
24
|
-
draw: (held) => !into.includes(held.conversation) || sealed(held)
|
|
25
|
-
? held
|
|
26
|
-
: {
|
|
27
|
-
...held,
|
|
28
|
-
messages: [
|
|
29
|
-
...held.messages,
|
|
30
|
-
{
|
|
31
|
-
identity: key,
|
|
32
|
-
turn: turn ?? key,
|
|
33
|
-
text: said.text,
|
|
34
|
-
message: { role: 'user', text: said.text },
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
shown: sealed,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export function optionChosen(conversation, option, value) {
|
|
42
|
-
const ours = (entry) => text(record(entry), 'id') === option;
|
|
43
|
-
return {
|
|
44
|
-
key: `option ${conversation} ${option}`,
|
|
45
|
-
view: 'conversation',
|
|
46
|
-
draw: (held) => held.conversation !== conversation
|
|
47
|
-
? held
|
|
48
|
-
: {
|
|
49
|
-
...held,
|
|
50
|
-
options: held.options.map((entry) => ours(entry) && entry.type === 'select' ? { ...entry, currentValue: value } : entry),
|
|
51
|
-
},
|
|
52
|
-
shown: (held) => held.conversation === conversation &&
|
|
53
|
-
held.options.some((entry) => ours(entry) && text(record(entry), 'currentValue') === value),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export function questionAnswered(conversation, interaction) {
|
|
57
|
-
const ours = (entry) => text(record(entry), 'interaction_id') === interaction;
|
|
58
|
-
return {
|
|
59
|
-
key: `answer ${conversation} ${interaction}`,
|
|
60
|
-
view: 'conversation',
|
|
61
|
-
draw: (held) => held.conversation !== conversation
|
|
62
|
-
? held
|
|
63
|
-
: { ...held, questions: held.questions.filter((entry) => !ours(entry)) },
|
|
64
|
-
shown: (held) => held.conversation === conversation && !held.questions.some(ours),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
export function deliveryRetried(conversation, message) {
|
|
68
|
-
return {
|
|
69
|
-
key: `retry ${conversation} ${message}`,
|
|
70
|
-
view: 'conversation',
|
|
71
|
-
draw: (held) => held.conversation !== conversation
|
|
72
|
-
? held
|
|
73
|
-
: { ...held, deliveryUnknown: held.deliveryUnknown.filter((one) => one !== message) },
|
|
74
|
-
shown: (held) => held.conversation === conversation && !held.deliveryUnknown.includes(message),
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
export function conversationListed(entry) {
|
|
78
|
-
const ours = (one) => one.conversation === entry.conversation;
|
|
79
|
-
return {
|
|
80
|
-
key: `conversation ${entry.conversation}`,
|
|
81
|
-
view: 'conversations',
|
|
82
|
-
draw: (held) => (held.some(ours) ? held : [...held, entry]),
|
|
83
|
-
shown: (held) => held.some(ours),
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
export function conversationChanged(conversation, changes, shown) {
|
|
87
|
-
const ours = (one) => one.conversation === conversation;
|
|
88
|
-
return {
|
|
89
|
-
key: `conversation ${conversation} ${Object.keys(changes).sort().join(' ')}`,
|
|
90
|
-
view: 'conversations',
|
|
91
|
-
draw: (held) => held.map((one) => (ours(one) ? { ...one, ...changes } : one)),
|
|
92
|
-
shown: (held) => held.some((one) => ours(one) && shown(one)),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
export function conversationGone(conversation) {
|
|
96
|
-
const ours = (one) => one.conversation === conversation;
|
|
97
|
-
return {
|
|
98
|
-
key: `conversation ${conversation}`,
|
|
99
|
-
view: 'conversations',
|
|
100
|
-
draw: (held) => held.filter((one) => !ours(one)),
|
|
101
|
-
shown: (held) => !held.some(ours),
|
|
102
|
-
};
|
|
103
|
-
}
|
package/dist/chat/parts.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { TurnContext } from '../adapter.js';
|
|
2
|
-
export type PlanStep = {
|
|
3
|
-
readonly content: string;
|
|
4
|
-
readonly status: string;
|
|
5
|
-
};
|
|
6
|
-
export type Marker = 'mode' | 'compaction' | 'retry' | 'model' | 'job';
|
|
7
|
-
export type Part = {
|
|
8
|
-
readonly type: 'text';
|
|
9
|
-
readonly text: string;
|
|
10
|
-
} | {
|
|
11
|
-
readonly type: 'reasoning';
|
|
12
|
-
readonly text: string;
|
|
13
|
-
} | {
|
|
14
|
-
readonly type: 'commands';
|
|
15
|
-
readonly count: number;
|
|
16
|
-
} | {
|
|
17
|
-
readonly type: 'subagent';
|
|
18
|
-
readonly description: string;
|
|
19
|
-
readonly done: boolean;
|
|
20
|
-
readonly result: string | null;
|
|
21
|
-
} | {
|
|
22
|
-
readonly type: 'message';
|
|
23
|
-
readonly command: string;
|
|
24
|
-
readonly target: string | null;
|
|
25
|
-
} | {
|
|
26
|
-
readonly type: 'image';
|
|
27
|
-
readonly path: string;
|
|
28
|
-
readonly name: string;
|
|
29
|
-
readonly mediaType: string;
|
|
30
|
-
} | {
|
|
31
|
-
readonly type: 'marker';
|
|
32
|
-
readonly marker: Marker;
|
|
33
|
-
readonly text: string;
|
|
34
|
-
} | {
|
|
35
|
-
readonly type: 'plan';
|
|
36
|
-
readonly steps: readonly PlanStep[];
|
|
37
|
-
};
|
|
38
|
-
export declare function partsOf(raw: readonly unknown[]): readonly Part[];
|
|
39
|
-
export declare function contextIn(raw: unknown): TurnContext | null;
|
|
40
|
-
export type Turn = {
|
|
41
|
-
readonly turn: string;
|
|
42
|
-
readonly parts: readonly Part[];
|
|
43
|
-
readonly ended: boolean;
|
|
44
|
-
};
|
|
45
|
-
export type ChatWork = {
|
|
46
|
-
readonly kind: 'job' | 'schedule' | 'subagent';
|
|
47
|
-
readonly title: string;
|
|
48
|
-
readonly next: string | null;
|
|
49
|
-
};
|
|
50
|
-
export type Job = {
|
|
51
|
-
readonly label: string;
|
|
52
|
-
readonly kind: 'started' | 'scheduled' | 'ended';
|
|
53
|
-
readonly state: string;
|
|
54
|
-
readonly next: string | null;
|
|
55
|
-
};
|
|
56
|
-
export declare function jobOf(said: string): Job;
|
|
57
|
-
export declare function stillRunning(turns: readonly Turn[]): ReadonlyMap<string, readonly ChatWork[]>;
|
|
58
|
-
//# sourceMappingURL=parts.d.ts.map
|
package/dist/chat/parts.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAEvE,MAAM,MAAM,IAAI,GACZ;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACtF;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC3E;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAA;CAAE,CAAC;AAoDnE,wBAAgB,OAAO,CAAC,GAAG,EAAE,SAAS,OAAO,EAAE,GAAG,SAAS,IAAI,EAAE,CAEhE;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,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
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { list, record, text } from './read.js';
|
|
2
|
-
const MARKERS = ['mode', 'compaction', 'retry', 'model', 'job'];
|
|
3
|
-
function partOf(raw) {
|
|
4
|
-
const part = record(raw);
|
|
5
|
-
switch (text(part, 'type')) {
|
|
6
|
-
case 'text':
|
|
7
|
-
case 'reasoning': {
|
|
8
|
-
const said = text(part, 'text');
|
|
9
|
-
return said === null ? null : { type: part.type, text: said };
|
|
10
|
-
}
|
|
11
|
-
case 'commands':
|
|
12
|
-
return typeof part.count === 'number' ? { type: 'commands', count: part.count } : null;
|
|
13
|
-
case 'subagent':
|
|
14
|
-
return {
|
|
15
|
-
type: 'subagent',
|
|
16
|
-
description: text(part, 'description') ?? '',
|
|
17
|
-
done: part.status === 'done',
|
|
18
|
-
result: text(part, 'result'),
|
|
19
|
-
};
|
|
20
|
-
case 'message': {
|
|
21
|
-
const command = text(part, 'command');
|
|
22
|
-
return command === null ? null : { type: 'message', command, target: text(part, 'target') };
|
|
23
|
-
}
|
|
24
|
-
case 'image': {
|
|
25
|
-
const path = text(part, 'file');
|
|
26
|
-
const name = text(part, 'name');
|
|
27
|
-
return path === null || name === null
|
|
28
|
-
? null
|
|
29
|
-
: { type: 'image', path, name, mediaType: text(part, 'media_type') ?? '' };
|
|
30
|
-
}
|
|
31
|
-
case 'marker': {
|
|
32
|
-
const marker = text(part, 'marker');
|
|
33
|
-
return marker === null || !MARKERS.includes(marker)
|
|
34
|
-
? null
|
|
35
|
-
: { type: 'marker', marker: marker, text: text(part, 'text') ?? '' };
|
|
36
|
-
}
|
|
37
|
-
case 'plan':
|
|
38
|
-
return {
|
|
39
|
-
type: 'plan',
|
|
40
|
-
steps: list(part, 'entries').flatMap((entry) => {
|
|
41
|
-
const step = record(entry);
|
|
42
|
-
const content = text(step, 'content');
|
|
43
|
-
return content === null ? [] : [{ content, status: text(step, 'status') ?? '' }];
|
|
44
|
-
}),
|
|
45
|
-
};
|
|
46
|
-
default:
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
export function partsOf(raw) {
|
|
51
|
-
return raw.flatMap((one) => partOf(one) ?? []);
|
|
52
|
-
}
|
|
53
|
-
export function contextIn(raw) {
|
|
54
|
-
const held = record(raw);
|
|
55
|
-
return typeof held.used === 'number' && typeof held.window === 'number' && held.window > 0
|
|
56
|
-
? { used: held.used, window: held.window }
|
|
57
|
-
: null;
|
|
58
|
-
}
|
|
59
|
-
const NEXT_RUN = 'next run ';
|
|
60
|
-
export function jobOf(said) {
|
|
61
|
-
const at = said.lastIndexOf(': ');
|
|
62
|
-
const label = at === -1 ? said : said.slice(0, at);
|
|
63
|
-
const state = at === -1 ? '' : said.slice(at + 2);
|
|
64
|
-
if (state === 'running')
|
|
65
|
-
return { label, kind: 'started', state, next: null };
|
|
66
|
-
if (state === 'scheduled')
|
|
67
|
-
return { label, kind: 'scheduled', state, next: null };
|
|
68
|
-
return state.startsWith(NEXT_RUN)
|
|
69
|
-
? { label, kind: 'scheduled', state, next: state.slice(NEXT_RUN.length) }
|
|
70
|
-
: { label, kind: 'ended', state, next: null };
|
|
71
|
-
}
|
|
72
|
-
export function stillRunning(turns) {
|
|
73
|
-
const open = [];
|
|
74
|
-
const close = (key) => {
|
|
75
|
-
const at = open.map((one) => one.key).lastIndexOf(key);
|
|
76
|
-
if (at !== -1)
|
|
77
|
-
open.splice(at, 1);
|
|
78
|
-
};
|
|
79
|
-
for (const { turn, parts, ended } of turns) {
|
|
80
|
-
for (const part of parts) {
|
|
81
|
-
if (part.type === 'subagent') {
|
|
82
|
-
const key = `subagent\u0000${part.description}`;
|
|
83
|
-
if (part.done)
|
|
84
|
-
close(key);
|
|
85
|
-
else if (ended) {
|
|
86
|
-
open.push({ turn, key, work: { kind: 'subagent', title: part.description, next: null } });
|
|
87
|
-
}
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (part.type !== 'marker' || part.marker !== 'job')
|
|
91
|
-
continue;
|
|
92
|
-
const job = jobOf(part.text);
|
|
93
|
-
const started = `job\u0000${job.label}`;
|
|
94
|
-
const schedule = `schedule\u0000${job.label}`;
|
|
95
|
-
if (job.kind === 'scheduled') {
|
|
96
|
-
close(schedule);
|
|
97
|
-
if (ended) {
|
|
98
|
-
open.push({
|
|
99
|
-
turn,
|
|
100
|
-
key: schedule,
|
|
101
|
-
work: { kind: 'schedule', title: job.label, next: job.next },
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else if (job.kind === 'started') {
|
|
106
|
-
if (ended) {
|
|
107
|
-
open.push({ turn, key: started, work: { kind: 'job', title: job.label, next: null } });
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
close(started);
|
|
112
|
-
close(schedule);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const under = new Map();
|
|
117
|
-
for (const one of open)
|
|
118
|
-
under.set(one.turn, [...(under.get(one.turn) ?? []), one.work]);
|
|
119
|
-
return under;
|
|
120
|
-
}
|