@agentshouse/mdruntime 0.1.0-cf04ede9fb796 → 0.1.0-cf08ada271a7f
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 +8 -8
- package/dist/acceptance.d.ts +0 -3
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +51 -131
- package/dist/actions.js +2 -2
- package/dist/adapter.d.ts +16 -44
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -19
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- package/dist/client.d.ts +3 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6 -4
- package/dist/collection.d.ts +22 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +12 -2
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +15 -21
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +13 -13
- package/dist/conversation-live.d.ts +3 -4
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +2 -3
- package/dist/conversation.d.ts +4 -6
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +43 -71
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +5 -3
- package/dist/expectation.d.ts +4 -2
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +33 -11
- package/dist/failure.d.ts +1 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -0
- package/dist/host.d.ts +17 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +16 -4
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/install.d.ts +0 -1
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +46 -59
- package/dist/job.d.ts +1 -29
- package/dist/job.d.ts.map +1 -1
- package/dist/job.js +2 -49
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +9 -6
- package/dist/listing.d.ts +4 -4
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +15 -22
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +3 -3
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +2 -1
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +3 -3
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +3 -3
- package/dist/memory.d.ts +4 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +8 -6
- package/dist/messages.d.ts +0 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +9 -29
- package/dist/model.d.ts +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -5
- package/dist/models.d.ts +4 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +101 -126
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +12 -17
- package/dist/opened.js +3 -3
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +6 -4
- package/dist/overlay.d.ts +2 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +32 -21
- package/dist/parts.d.ts +3 -52
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +15 -120
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +12 -5
- package/dist/queries.js +1 -1
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.js +1 -1
- package/dist/queue.d.ts +39 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +455 -0
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +5 -4
- package/dist/react.d.ts +4 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +10 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +4 -1
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +3 -2
- package/dist/replica.d.ts +5 -11
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +13 -15
- package/dist/room-draft.d.ts +4 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +36 -52
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +17 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -4
- package/dist/runtime.d.ts +5 -16
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +41 -90
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +233 -116
- package/dist/saves.d.ts +2 -40
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +102 -697
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +0 -1
- package/dist/shared.d.ts +0 -5
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +4 -90
- package/dist/shown.d.ts +2 -1
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +15 -11
- package/dist/socket/rooms.d.ts +1 -4
- package/dist/socket/rooms.d.ts.map +1 -1
- package/dist/socket/session.d.ts +0 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket.d.ts +0 -1
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +2 -2
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +5 -4
- package/dist/store/records.d.ts +1 -3
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +2 -5
- package/dist/store/space.d.ts +1 -1
- package/dist/store/space.d.ts.map +1 -1
- package/dist/store/space.js +0 -2
- package/dist/store/watchers.js +1 -2
- package/dist/store.d.ts +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +1 -1
- package/dist/stored.d.ts +1 -1
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +6 -6
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +4 -3
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +25 -27
- package/dist/tables.d.ts +0 -5
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +8 -11
- package/dist/tallies.js +5 -5
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +2 -2
- package/dist/wire.d.ts +4 -4
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +3 -3
- package/package.json +3 -2
package/dist/opened.js
CHANGED
|
@@ -36,14 +36,14 @@ export function openedFiles(database, fenced) {
|
|
|
36
36
|
let part = 0;
|
|
37
37
|
const write = async (bytes) => {
|
|
38
38
|
if (!(await database.ask({ kind: 'opened.part', key, part, bytes }))) {
|
|
39
|
-
throw new Error(
|
|
39
|
+
throw new Error();
|
|
40
40
|
}
|
|
41
41
|
part += 1;
|
|
42
42
|
};
|
|
43
43
|
try {
|
|
44
44
|
if (fenced(name.locator) ||
|
|
45
45
|
!(await database.ask({ kind: 'opened.begin', key, ...name, mediaType }))) {
|
|
46
|
-
throw new Error(
|
|
46
|
+
throw new Error();
|
|
47
47
|
}
|
|
48
48
|
for (;;) {
|
|
49
49
|
const read = await reader.read();
|
|
@@ -61,7 +61,7 @@ export function openedFiles(database, fenced) {
|
|
|
61
61
|
await write(taken(chunks, held));
|
|
62
62
|
const received = hashed.hex();
|
|
63
63
|
if (sha256 !== undefined && sha256 !== received) {
|
|
64
|
-
throw new Error(
|
|
64
|
+
throw new Error();
|
|
65
65
|
}
|
|
66
66
|
const whole = await database.ask({
|
|
67
67
|
kind: 'opened.keep',
|
package/dist/opening.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CA2CxF"}
|
package/dist/opening.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { conversationsOpened } from './conversation.js';
|
|
2
2
|
import { detectStorageLoss, nextGeneration, refusedForSpace } from './durability.js';
|
|
3
|
+
import { uncaught } from './failure.js';
|
|
3
4
|
import { sweep } from './install.js';
|
|
4
5
|
import { eraseFenced } from './lost.js';
|
|
5
6
|
import { prepare } from './preparation.js';
|
|
7
|
+
import { unpair } from './queue.js';
|
|
6
8
|
import { emitRooms, emitStorageLoss, statusShown } from './shown.js';
|
|
7
9
|
export async function open(runtime, opened) {
|
|
8
10
|
const { store, socket, journal, shell, conversations, build, usableWhenHeld } = runtime;
|
|
@@ -40,18 +42,18 @@ export async function open(runtime, opened) {
|
|
|
40
42
|
await conversationsOpened(conversations, opened);
|
|
41
43
|
if (interrupted.length > 0) {
|
|
42
44
|
queueMicrotask(() => {
|
|
43
|
-
void eraseFenced(runtime, interrupted).catch(() => {
|
|
45
|
+
void eraseFenced(runtime, interrupted).catch((error) => {
|
|
44
46
|
journal.record('erasure failed');
|
|
47
|
+
uncaught(error);
|
|
45
48
|
});
|
|
46
49
|
});
|
|
47
50
|
}
|
|
48
51
|
statusShown(runtime);
|
|
49
52
|
prepare(runtime);
|
|
50
53
|
emitRooms(runtime);
|
|
51
|
-
void
|
|
52
|
-
.exclusive(() => runtime.unpair(opened))
|
|
53
|
-
.catch(() => {
|
|
54
|
+
void unpair(runtime).catch((error) => {
|
|
54
55
|
journal.record('unpair failed');
|
|
56
|
+
uncaught(error);
|
|
55
57
|
});
|
|
56
58
|
return opened;
|
|
57
59
|
}
|
package/dist/overlay.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BinaryFile, HeadChange } from './adapter.js';
|
|
2
|
+
import { type Composition } from './collection.js';
|
|
2
3
|
import type { ChangeBatch } from './change.js';
|
|
3
4
|
export type Heads = {
|
|
4
5
|
revisions: Readonly<Record<string, string>>;
|
|
@@ -22,5 +23,5 @@ export type Layer = Heads & {
|
|
|
22
23
|
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
23
24
|
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
24
25
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
25
|
-
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Generator<number, Layer, void>;
|
|
26
|
+
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], composition: Composition, unapplied?: () => void): Generator<number, Layer, void>;
|
|
26
27
|
//# sourceMappingURL=overlay.d.ts.map
|
package/dist/overlay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAU,WAAW,EAAgB,MAAM,aAAa,CAAC;AAIrE,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,OAAO,EAAE,QAAQ,CAAC,MAA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,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAsChC"}
|
package/dist/overlay.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { apply, frontmatterValue, parse, serialize, } from '@agentshouse/mdmodel';
|
|
1
|
+
import { apply, create, frontmatterValue, parse, serialize, TYPE_FIELD, } from '@agentshouse/mdmodel';
|
|
2
|
+
import { definitionsAt } from './collection.js';
|
|
2
3
|
import { drafted, entriesIn, settling } from './shared.js';
|
|
3
4
|
import { ROW_WEIGHT } from './turn.js';
|
|
4
5
|
export function* acceptedBinaries(files) {
|
|
@@ -24,7 +25,6 @@ export function sameChange(left, right) {
|
|
|
24
25
|
left.author?.id === right.author?.id &&
|
|
25
26
|
left.author?.name === right.author?.name);
|
|
26
27
|
}
|
|
27
|
-
const EMPTY_FRONTMATTER = '---\n---\n';
|
|
28
28
|
function isPart(change) {
|
|
29
29
|
return change.kind === 'field' || change.kind === 'section' || change.kind === 'preamble';
|
|
30
30
|
}
|
|
@@ -53,16 +53,23 @@ function* priorsOf(preconditions) {
|
|
|
53
53
|
preamble: (path) => preambles.get(path) ?? '',
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
function compose(fields, sections) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
function compose(path, fields, sections, composition) {
|
|
57
|
+
const declared = fields[TYPE_FIELD];
|
|
58
|
+
const type = typeof declared === 'string' && declared !== '' ? declared : undefined;
|
|
59
|
+
const definition = definitionsAt(composition, path)(type);
|
|
60
|
+
const created = create(type, definition);
|
|
61
|
+
const next = apply(created, [
|
|
62
|
+
...Object.entries(fields).flatMap(([name, value]) => (name !== TYPE_FIELD || type === undefined) && frontmatterValue(value)
|
|
63
|
+
? [{ kind: 'field', name, value, prior: undefined }]
|
|
64
|
+
: []),
|
|
65
|
+
...Object.entries(sections).map(([name, value]) => ({
|
|
66
|
+
kind: 'section',
|
|
67
|
+
name,
|
|
68
|
+
value,
|
|
69
|
+
prior: undefined,
|
|
70
|
+
})),
|
|
71
|
+
], definition);
|
|
72
|
+
return serialize(next.outcome === 'applied' ? next.document : created);
|
|
66
73
|
}
|
|
67
74
|
function edited(change, priors) {
|
|
68
75
|
if (change.kind === 'field')
|
|
@@ -81,17 +88,19 @@ function edited(change, priors) {
|
|
|
81
88
|
prior: priors.section(change.path, change.name),
|
|
82
89
|
};
|
|
83
90
|
}
|
|
84
|
-
function edit(staged, changes, priors) {
|
|
91
|
+
function edit(staged, changes, priors, composition) {
|
|
85
92
|
const path = changes[0].path;
|
|
86
93
|
delete staged.revisions[path];
|
|
87
94
|
const text = staged.documents[path];
|
|
88
95
|
if (text === undefined)
|
|
89
96
|
return changes.length;
|
|
90
|
-
const
|
|
97
|
+
const definitions = definitionsAt(composition, path);
|
|
98
|
+
const parsed = parse(text, path, definitions);
|
|
91
99
|
if (!parsed.ok)
|
|
92
100
|
return changes.length;
|
|
101
|
+
const definition = definitions(parsed.document.type);
|
|
93
102
|
const wanted = changes.map((change) => edited(change, priors));
|
|
94
|
-
const first = apply(parsed.document, wanted);
|
|
103
|
+
const first = apply(parsed.document, wanted, definition);
|
|
95
104
|
if (first.outcome === 'refuse')
|
|
96
105
|
return changes.length;
|
|
97
106
|
if (first.outcome === 'applied') {
|
|
@@ -100,7 +109,7 @@ function edit(staged, changes, priors) {
|
|
|
100
109
|
}
|
|
101
110
|
const stale = new Set(first.stale);
|
|
102
111
|
const kept = wanted.filter((_, at) => !stale.has(at));
|
|
103
|
-
const rest = apply(parsed.document, kept);
|
|
112
|
+
const rest = apply(parsed.document, kept, definition);
|
|
104
113
|
if (rest.outcome !== 'applied')
|
|
105
114
|
return changes.length;
|
|
106
115
|
staged.documents[path] = serialize(rest.document);
|
|
@@ -151,10 +160,12 @@ function erase(staged, path) {
|
|
|
151
160
|
delete staged.changes[path];
|
|
152
161
|
delete staged.binaries[path];
|
|
153
162
|
}
|
|
154
|
-
function stage(staged, change) {
|
|
163
|
+
function stage(staged, change, composition) {
|
|
155
164
|
if (change.kind === 'create') {
|
|
156
165
|
staged.documents[change.path] =
|
|
157
|
-
'content' in change
|
|
166
|
+
'content' in change
|
|
167
|
+
? change.content
|
|
168
|
+
: compose(change.path, change.fields, change.sections, composition);
|
|
158
169
|
delete staged.fileIds[change.path];
|
|
159
170
|
delete staged.created[change.path];
|
|
160
171
|
delete staged.changes[change.path];
|
|
@@ -206,7 +217,7 @@ function arrive(heads, change) {
|
|
|
206
217
|
if (change.change !== undefined)
|
|
207
218
|
heads.changes[change.path] = change.change;
|
|
208
219
|
}
|
|
209
|
-
export function* overlaying(base, queue, unapplied) {
|
|
220
|
+
export function* overlaying(base, queue, composition, unapplied) {
|
|
210
221
|
const staged = {
|
|
211
222
|
documents: drafted(base.documents),
|
|
212
223
|
binaries: drafted(base.binaries),
|
|
@@ -220,7 +231,7 @@ export function* overlaying(base, queue, unapplied) {
|
|
|
220
231
|
for (let index = 0; index < batch.changes.length; index += 1) {
|
|
221
232
|
const change = batch.changes[index];
|
|
222
233
|
if (!isPart(change)) {
|
|
223
|
-
if (!stage(staged, change))
|
|
234
|
+
if (!stage(staged, change, composition))
|
|
224
235
|
unapplied?.();
|
|
225
236
|
yield ROW_WEIGHT;
|
|
226
237
|
continue;
|
|
@@ -234,7 +245,7 @@ export function* overlaying(base, queue, unapplied) {
|
|
|
234
245
|
index += 1;
|
|
235
246
|
}
|
|
236
247
|
const text = staged.documents[change.path] ?? '';
|
|
237
|
-
for (let left = edit(staged, run, priors); left > 0; left -= 1)
|
|
248
|
+
for (let left = edit(staged, run, priors, composition); left > 0; left -= 1)
|
|
238
249
|
unapplied?.();
|
|
239
250
|
yield ROW_WEIGHT + text.length;
|
|
240
251
|
}
|
package/dist/parts.d.ts
CHANGED
|
@@ -1,49 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type JobMarker, type OpenJob } from './job.js';
|
|
3
|
-
export type PlanStep = {
|
|
4
|
-
readonly content: string;
|
|
5
|
-
readonly status: string;
|
|
6
|
-
};
|
|
7
|
-
export type Marker = 'mode' | 'compaction' | 'retry' | 'model' | 'job';
|
|
8
|
-
export type Part = {
|
|
9
|
-
readonly type: 'text';
|
|
10
|
-
readonly text: string;
|
|
11
|
-
} | {
|
|
12
|
-
readonly type: 'reasoning';
|
|
13
|
-
readonly text: string;
|
|
14
|
-
} | {
|
|
15
|
-
readonly type: 'commands';
|
|
16
|
-
readonly count: number;
|
|
17
|
-
} | {
|
|
18
|
-
readonly type: 'subagent';
|
|
19
|
-
readonly description: string;
|
|
20
|
-
readonly done: boolean;
|
|
21
|
-
readonly result: string | null;
|
|
22
|
-
} | {
|
|
23
|
-
readonly type: 'message';
|
|
24
|
-
readonly command: string;
|
|
25
|
-
readonly target: string | null;
|
|
26
|
-
} | {
|
|
27
|
-
readonly type: 'image';
|
|
28
|
-
readonly path: string;
|
|
29
|
-
readonly name: string;
|
|
30
|
-
readonly mediaType: string;
|
|
31
|
-
} | {
|
|
32
|
-
readonly type: 'marker';
|
|
33
|
-
readonly marker: Marker;
|
|
34
|
-
readonly text: string;
|
|
35
|
-
} | {
|
|
36
|
-
readonly type: 'plan';
|
|
37
|
-
readonly steps: readonly PlanStep[];
|
|
38
|
-
};
|
|
39
|
-
export declare function partsOf(raw: readonly unknown[]): readonly Part[];
|
|
40
|
-
export declare function contextIn(raw: unknown): TurnContext | null;
|
|
41
|
-
export declare function tokensIn(raw: unknown): number | null;
|
|
42
|
-
export type Turn = {
|
|
43
|
-
readonly turn: string;
|
|
44
|
-
readonly parts: readonly Part[];
|
|
45
|
-
readonly ended: boolean;
|
|
46
|
-
};
|
|
1
|
+
import { type Part, type SessionState } from '@agentshouse/session-content';
|
|
47
2
|
export type ChatWork = {
|
|
48
3
|
readonly kind: 'job' | 'schedule' | 'subagent';
|
|
49
4
|
readonly title: string;
|
|
@@ -51,10 +6,6 @@ export type ChatWork = {
|
|
|
51
6
|
readonly activity: string | null;
|
|
52
7
|
};
|
|
53
8
|
export declare function counted(count: number): string;
|
|
54
|
-
export declare function runningLine(
|
|
55
|
-
export declare function
|
|
56
|
-
readonly started: string | null;
|
|
57
|
-
readonly parts: readonly unknown[];
|
|
58
|
-
} | null): readonly OpenJob[];
|
|
59
|
-
export declare function stillRunning(turns: readonly Turn[], subagents: readonly RunningSubagent[]): ReadonlyMap<string, readonly ChatWork[]>;
|
|
9
|
+
export declare function runningLine(parts: readonly Part[]): string | null;
|
|
10
|
+
export declare function workOf(state: SessionState | null): readonly ChatWork[];
|
|
60
11
|
//# sourceMappingURL=parts.d.ts.map
|
package/dist/parts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../src/parts.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../src/parts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,IAAI,EAAE,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAGnF,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;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,MAAM,GAAG,IAAI,CAMjE;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,QAAQ,EAAE,CAOtE"}
|
package/dist/parts.js
CHANGED
|
@@ -1,126 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { excerpt
|
|
3
|
-
const MARKERS = ['mode', 'compaction', 'retry', 'model', 'job'];
|
|
4
|
-
function partOf(raw) {
|
|
5
|
-
const part = record(raw);
|
|
6
|
-
switch (text(part, 'type')) {
|
|
7
|
-
case 'text':
|
|
8
|
-
case 'reasoning': {
|
|
9
|
-
const said = text(part, 'text');
|
|
10
|
-
return said === null ? null : { type: part.type, text: said };
|
|
11
|
-
}
|
|
12
|
-
case 'commands':
|
|
13
|
-
return typeof part.count === 'number' ? { type: 'commands', count: part.count } : null;
|
|
14
|
-
case 'subagent':
|
|
15
|
-
return {
|
|
16
|
-
type: 'subagent',
|
|
17
|
-
description: text(part, 'description') ?? '',
|
|
18
|
-
done: part.status === 'done',
|
|
19
|
-
result: text(part, 'result'),
|
|
20
|
-
};
|
|
21
|
-
case 'message': {
|
|
22
|
-
const command = text(part, 'command');
|
|
23
|
-
return command === null ? null : { type: 'message', command, target: text(part, 'target') };
|
|
24
|
-
}
|
|
25
|
-
case 'image': {
|
|
26
|
-
const path = text(part, 'file');
|
|
27
|
-
const name = text(part, 'name');
|
|
28
|
-
return path === null || name === null
|
|
29
|
-
? null
|
|
30
|
-
: { type: 'image', path, name, mediaType: text(part, 'media_type') ?? '' };
|
|
31
|
-
}
|
|
32
|
-
case 'marker': {
|
|
33
|
-
const marker = text(part, 'marker');
|
|
34
|
-
return marker === null || !MARKERS.includes(marker)
|
|
35
|
-
? null
|
|
36
|
-
: { type: 'marker', marker: marker, text: text(part, 'text') ?? '' };
|
|
37
|
-
}
|
|
38
|
-
case 'plan':
|
|
39
|
-
return {
|
|
40
|
-
type: 'plan',
|
|
41
|
-
steps: list(part, 'entries').flatMap((entry) => {
|
|
42
|
-
const step = record(entry);
|
|
43
|
-
const content = text(step, 'content');
|
|
44
|
-
return content === null ? [] : [{ content, status: text(step, 'status') ?? '' }];
|
|
45
|
-
}),
|
|
46
|
-
};
|
|
47
|
-
default:
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
export function partsOf(raw) {
|
|
52
|
-
return raw.flatMap((one) => partOf(one) ?? []);
|
|
53
|
-
}
|
|
54
|
-
export function contextIn(raw) {
|
|
55
|
-
const held = record(raw);
|
|
56
|
-
return typeof held.used === 'number' && typeof held.window === 'number' && held.window > 0
|
|
57
|
-
? { used: held.used, window: held.window }
|
|
58
|
-
: null;
|
|
59
|
-
}
|
|
60
|
-
const TOKEN_KINDS = ['input', 'output', 'cache_read', 'cache_write'];
|
|
61
|
-
export function tokensIn(raw) {
|
|
62
|
-
const held = record(raw);
|
|
63
|
-
const counts = TOKEN_KINDS.map((kind) => held[kind]);
|
|
64
|
-
return counts.every((count) => typeof count === 'number')
|
|
65
|
-
? counts.reduce((sum, count) => sum + count, 0)
|
|
66
|
-
: null;
|
|
67
|
-
}
|
|
1
|
+
import { isOwn } from '@agentshouse/session-content';
|
|
2
|
+
import { excerpt } from './read.js';
|
|
68
3
|
export function counted(count) {
|
|
69
4
|
return count === 1 ? '1 command' : `${count} commands`;
|
|
70
5
|
}
|
|
71
|
-
export function runningLine(
|
|
72
|
-
const
|
|
73
|
-
const note =
|
|
6
|
+
export function runningLine(parts) {
|
|
7
|
+
const newest = parts.filter(isOwn).reverse();
|
|
8
|
+
const note = newest.find((part) => part.type === 'text' && part.text.trim() !== '');
|
|
74
9
|
if (note?.type === 'text')
|
|
75
10
|
return excerpt(note.text);
|
|
76
|
-
const
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
export function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const open = [];
|
|
87
|
-
for (const { turn, parts, ended } of turns) {
|
|
88
|
-
for (const part of parts) {
|
|
89
|
-
if (part.type === 'subagent') {
|
|
90
|
-
const key = `subagent\u0000${part.description}`;
|
|
91
|
-
if (part.done)
|
|
92
|
-
closeLast(open, key);
|
|
93
|
-
else if (ended) {
|
|
94
|
-
open.push({
|
|
95
|
-
turn,
|
|
96
|
-
key,
|
|
97
|
-
work: { kind: 'subagent', title: part.description, next: null, activity: null },
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
if (part.type !== 'marker' || part.marker !== 'job')
|
|
103
|
-
continue;
|
|
104
|
-
markerMoved(open, part.text, (job, key) => ended
|
|
105
|
-
? {
|
|
106
|
-
turn,
|
|
107
|
-
key,
|
|
108
|
-
work: {
|
|
109
|
-
kind: job.kind === 'started' ? 'job' : 'schedule',
|
|
110
|
-
title: job.label,
|
|
111
|
-
next: job.next,
|
|
112
|
-
activity: null,
|
|
113
|
-
},
|
|
114
|
-
}
|
|
115
|
-
: null);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
const doing = [...subagents];
|
|
119
|
-
const under = new Map();
|
|
120
|
-
for (const { turn, work } of open) {
|
|
121
|
-
const at = work.kind === 'subagent' ? doing.findIndex((one) => one.description === work.title) : -1;
|
|
122
|
-
const shown = at === -1 ? work : { ...work, activity: doing.splice(at, 1)[0].activity };
|
|
123
|
-
under.set(turn, [...(under.get(turn) ?? []), shown]);
|
|
124
|
-
}
|
|
125
|
-
return under;
|
|
11
|
+
const call = newest.find((part) => part.type === 'call');
|
|
12
|
+
return call?.type === 'call' && call.line !== '' ? call.line : null;
|
|
13
|
+
}
|
|
14
|
+
export function workOf(state) {
|
|
15
|
+
return (state?.running ?? []).map(({ kind, label, progress, next }) => ({
|
|
16
|
+
kind: kind === 'subagent' || kind === 'schedule' ? kind : 'job',
|
|
17
|
+
title: label,
|
|
18
|
+
next,
|
|
19
|
+
activity: progress,
|
|
20
|
+
}));
|
|
126
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preparation.d.ts","sourceRoot":"","sources":["../src/preparation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preparation.d.ts","sourceRoot":"","sources":["../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"}
|
package/dist/preparation.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { changeSet } from './change-set.js';
|
|
2
|
+
import { uncaught } from './failure.js';
|
|
2
3
|
import { installationOf } from './install.js';
|
|
3
4
|
import { listedLocators } from './listing.js';
|
|
4
5
|
import { planReach } from './reach.js';
|
|
@@ -57,8 +58,9 @@ export function prepare(runtime, locators = []) {
|
|
|
57
58
|
await prepareReplica(runtime, waiting).catch((error) => unpreparedBy(runtime, waiting, error));
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
|
-
catch {
|
|
61
|
+
catch (error) {
|
|
61
62
|
journal.record('preparation failed');
|
|
63
|
+
uncaught(error);
|
|
62
64
|
}
|
|
63
65
|
finally {
|
|
64
66
|
device.set({ preparing: false });
|
|
@@ -165,8 +167,9 @@ function establish(runtime, name) {
|
|
|
165
167
|
.then(() => {
|
|
166
168
|
store.readiness.queue();
|
|
167
169
|
void probeEachMinute(runtime);
|
|
168
|
-
}, () => {
|
|
170
|
+
}, (error) => {
|
|
169
171
|
journal.record(`target record failed ${name}`);
|
|
172
|
+
uncaught(error);
|
|
170
173
|
})
|
|
171
174
|
.finally(() => {
|
|
172
175
|
const establishing = new Set(device.now().establishing);
|
|
@@ -206,8 +209,8 @@ export function filled(runtime) {
|
|
|
206
209
|
store.readiness.queue();
|
|
207
210
|
void probeEachMinute(runtime);
|
|
208
211
|
}
|
|
209
|
-
async function installedTarget({ store
|
|
210
|
-
if (store.device.now().heldWhenOpened
|
|
212
|
+
async function installedTarget({ store }) {
|
|
213
|
+
if (store.device.now().heldWhenOpened)
|
|
211
214
|
return true;
|
|
212
215
|
const { targets } = await (await store.open()).facts();
|
|
213
216
|
return Object.values(targets).some((target) => target.established);
|
|
@@ -218,7 +221,11 @@ async function probeEachMinute(runtime) {
|
|
|
218
221
|
const idle = () => !space.full() || space.probing() || socket.closed();
|
|
219
222
|
if (idle())
|
|
220
223
|
return;
|
|
221
|
-
|
|
224
|
+
const installed = await installedTarget(runtime).catch((error) => {
|
|
225
|
+
uncaught(error);
|
|
226
|
+
return false;
|
|
227
|
+
});
|
|
228
|
+
if (!installed)
|
|
222
229
|
return;
|
|
223
230
|
if (idle())
|
|
224
231
|
return;
|
package/dist/queries.js
CHANGED
|
@@ -64,7 +64,7 @@ function coveredRooms(runtime, locators, whole, held) {
|
|
|
64
64
|
}
|
|
65
65
|
if (pending.length > 0)
|
|
66
66
|
return { pending };
|
|
67
|
-
return { coverage: { rooms: coverage,
|
|
67
|
+
return { coverage: { rooms: coverage, overlay }, rooms: read };
|
|
68
68
|
}
|
|
69
69
|
function covered(runtime, plan, held) {
|
|
70
70
|
return coveredRooms(runtime, reachedRooms(runtime, plan, held), plan.rooms === null && plan.reach === null, held);
|
package/dist/query.d.ts
CHANGED
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3C,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,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AAE,CAAC;AAElE,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,WAAW,GAAG,aAAa,CAAC;AAEvE,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG;IAC7B,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,GAAE,SAAS,GAAG,IAAW,GAAG,IAAI,CAEjG"}
|
package/dist/questions.js
CHANGED
|
@@ -114,7 +114,7 @@ export function questionAsked(questions) {
|
|
|
114
114
|
return questionsOf({ questions })[0]?.asked ?? null;
|
|
115
115
|
}
|
|
116
116
|
export function loneOf(questions) {
|
|
117
|
-
const asked = questions.length === 1 && !questions[0]
|
|
117
|
+
const asked = questions.length === 1 && !questions[0].secret ? questions[0] : undefined;
|
|
118
118
|
const only = asked?.fields.length === 1 ? asked.fields[0] : undefined;
|
|
119
119
|
return asked !== undefined && only !== undefined && entered(only)
|
|
120
120
|
? { question: asked, field: only }
|
package/dist/queue.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { MutationResult } from './adapter.js';
|
|
2
|
+
import { type ChangeBatch } from './change.js';
|
|
3
|
+
import { type HeldReplica, type ReplicaRecord, type Returned, type Slice } from './replica.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
import type { SavePlan } from './save.js';
|
|
6
|
+
import type { SaveResult } from './saves.js';
|
|
7
|
+
import type { PendingState, RoomCommit, Store, StoredFile, View, Work } from './store.js';
|
|
8
|
+
export type Queueing = Pick<Runtime, 'store' | 'journal' | 'localSaves'> & {
|
|
9
|
+
readonly socket: Pick<Runtime['socket'], 'continuing'>;
|
|
10
|
+
};
|
|
11
|
+
export type Restand = {
|
|
12
|
+
readonly locator: string;
|
|
13
|
+
readonly record: ReplicaRecord;
|
|
14
|
+
readonly accepted?: string;
|
|
15
|
+
readonly adopted?: Returned;
|
|
16
|
+
readonly installed?: Pick<RoomCommit, 'published' | 'refreshed'>;
|
|
17
|
+
readonly refused?: true;
|
|
18
|
+
readonly after?: () => void;
|
|
19
|
+
};
|
|
20
|
+
export type Appending = {
|
|
21
|
+
readonly plan: SavePlan;
|
|
22
|
+
readonly files: readonly StoredFile[];
|
|
23
|
+
readonly held: ReadonlyMap<string, {
|
|
24
|
+
readonly replica: HeldReplica;
|
|
25
|
+
readonly confirmed: Slice;
|
|
26
|
+
}>;
|
|
27
|
+
readonly after?: () => Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
type Answer = Extract<MutationResult, {
|
|
30
|
+
kind: 'conflicted' | 'rejected';
|
|
31
|
+
}>;
|
|
32
|
+
export declare function withdrawable(states: ReadonlyMap<string, PendingState>): (batch: ChangeBatch) => boolean;
|
|
33
|
+
export declare function sliceAt(store: Store, record: ReplicaRecord, view: View, queue: readonly ChangeBatch[], extra?: Iterable<string>, moved?: Iterable<string>): Promise<Slice>;
|
|
34
|
+
export declare function settle(runtime: Queueing, locators: readonly string[], decide: (held: ReadonlyMap<string, Work>) => Promise<readonly Restand[]>): Promise<void>;
|
|
35
|
+
export declare function answered(runtime: Queueing, locator: string, head: ChangeBatch, answer: Answer): Promise<void>;
|
|
36
|
+
export declare function unpair(runtime: Queueing): Promise<void>;
|
|
37
|
+
export declare function append(runtime: Queueing, appending: Appending): Promise<SaveResult>;
|
|
38
|
+
export {};
|
|
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