@agentshouse/mdruntime 0.1.0-cf08ada271a7f → 0.1.0-cf0c43fc48aad
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 +12 -12
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +25 -35
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +116 -65
- package/dist/adapter.d.ts +11 -4
- package/dist/adapter.d.ts.map +1 -1
- package/dist/client.d.ts +6 -17
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +26 -11
- package/dist/compile.d.ts +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +17 -4
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +15 -10
- package/dist/conversation-live.d.ts +7 -2
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +6 -3
- package/dist/conversation.d.ts +25 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +157 -76
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +18 -45
- package/dist/durability.d.ts +3 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.js +1 -1
- package/dist/expectation.d.ts +25 -14
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +51 -20
- package/dist/failure.d.ts +2 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +29 -7
- package/dist/index.d.ts +9 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/install.d.ts +2 -3
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +9 -22
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +32 -26
- package/dist/listing.d.ts +4 -9
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +21 -51
- package/dist/locks.d.ts +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +8 -38
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +7 -19
- package/dist/media.js +1 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +36 -17
- package/dist/messages.d.ts +9 -2
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +20 -10
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +15 -32
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +2 -2
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +3 -9
- package/dist/outcome.d.ts +3 -0
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +15 -0
- package/dist/overlay.d.ts +3 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +8 -4
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +2 -9
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +6 -14
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +15 -21
- package/dist/presence.d.ts +52 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +220 -0
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +23 -13
- package/dist/questions.d.ts +0 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +0 -7
- package/dist/queue.d.ts +2 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +26 -31
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +62 -18
- package/dist/react.d.ts +5 -4
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +28 -5
- package/dist/reads.d.ts +3 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +5 -1
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +29 -7
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +2 -4
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +2 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +24 -19
- package/dist/runtime.d.ts +4 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +1 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +105 -55
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +8 -11
- package/dist/seed.js +2 -2
- package/dist/shown.d.ts +2 -2
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +14 -23
- package/dist/socket/lanes.d.ts +12 -4
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +34 -8
- package/dist/socket.d.ts +3 -5
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +3 -14
- package/dist/source.d.ts +0 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/store/records.d.ts +7 -3
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +12 -2
- package/dist/store.d.ts +10 -5
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +37 -12
- package/dist/stored.d.ts +1 -0
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +5 -5
- package/dist/surface.d.ts +1 -1
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +9 -13
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +63 -58
- package/dist/tables.d.ts +6 -3
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +34 -10
- package/dist/wire.d.ts +47 -3
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +12 -1
- package/package.json +3 -3
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -5
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -7
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/socket/rooms.d.ts +0 -41
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/messages.d.ts
CHANGED
|
@@ -30,6 +30,12 @@ export type HeldRow = {
|
|
|
30
30
|
readonly at: string | null;
|
|
31
31
|
}) | null;
|
|
32
32
|
};
|
|
33
|
+
export type ConversationFact = 'openedTurn' | 'dismissedSuggestion';
|
|
34
|
+
export type HeldFact = {
|
|
35
|
+
readonly conversation: string;
|
|
36
|
+
readonly name: ConversationFact;
|
|
37
|
+
readonly value: string;
|
|
38
|
+
};
|
|
33
39
|
export type ConversationWrite = {
|
|
34
40
|
readonly conversation: string;
|
|
35
41
|
readonly messages: readonly AcceptedMessage[];
|
|
@@ -44,6 +50,7 @@ export declare function messageWindow(connection: Connection, conversation: stri
|
|
|
44
50
|
export declare function messageCount(connection: Connection, conversation: string, phrase: string | null): number;
|
|
45
51
|
export declare function conversationRows(connection: Connection, conversations: readonly string[]): HeldRow[];
|
|
46
52
|
export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
|
|
47
|
-
export declare function
|
|
48
|
-
export declare function
|
|
53
|
+
export declare function conversationFacts(connection: Connection): HeldFact[];
|
|
54
|
+
export declare function keptFact(connection: Connection, { conversation, name, value }: HeldFact): null;
|
|
55
|
+
export declare function forgottenConversations(connection: Connection): void;
|
|
49
56
|
//# sourceMappingURL=messages.d.ts.map
|
package/dist/messages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAA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,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,MAAM,CAOR;AAaD,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,SAAS,MAAM,EAAE,GAC/B,OAAO,EAAE,CAuBX;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAO/F;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ,EAAE,CAMpE;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,QAAQ,GAAG,IAAI,CAM9F;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAEnE"}
|
package/dist/messages.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { sql } from '@agentshouse/mdmodel';
|
|
2
2
|
import { EXCERPT } from './read.js';
|
|
3
|
+
import { tablesOf } from './stored.js';
|
|
3
4
|
const SAID_BY_HOUSE = `json_extract(message, '$.role') = 'house'`;
|
|
4
5
|
const ANSWERS_THE_TURN = `json_extract(message, '$.role') = 'assistant'`;
|
|
5
6
|
export const MESSAGE_TABLES = [
|
|
6
7
|
'CREATE TABLE conversation_reads (conversation TEXT PRIMARY KEY, read TEXT, partial INTEGER NOT NULL) WITHOUT ROWID',
|
|
7
|
-
'CREATE TABLE conversation_messages (id INTEGER PRIMARY KEY, conversation TEXT NOT NULL, identity TEXT NOT NULL, turn TEXT NOT NULL, position TEXT NOT NULL, message TEXT NOT NULL, text TEXT NOT NULL)',
|
|
8
|
+
'CREATE TABLE conversation_messages (id INTEGER PRIMARY KEY, conversation TEXT NOT NULL, identity TEXT NOT NULL, turn TEXT NOT NULL, position TEXT NOT NULL, change TEXT NOT NULL, message TEXT NOT NULL, text TEXT NOT NULL)',
|
|
8
9
|
'CREATE UNIQUE INDEX conversation_messages_identity ON conversation_messages (conversation, identity)',
|
|
9
10
|
'CREATE INDEX conversation_messages_position ON conversation_messages (conversation, position, identity)',
|
|
10
11
|
'CREATE INDEX conversation_messages_turn ON conversation_messages (conversation, turn)',
|
|
11
12
|
`CREATE INDEX conversation_messages_house ON conversation_messages (conversation, position, identity) WHERE ${SAID_BY_HOUSE}`,
|
|
13
|
+
'CREATE TABLE conversation_facts (conversation TEXT NOT NULL, name TEXT NOT NULL, value TEXT NOT NULL, PRIMARY KEY (conversation, name)) WITHOUT ROWID',
|
|
12
14
|
];
|
|
13
15
|
const NEWEST_FIRST = 'ORDER BY position DESC, identity DESC LIMIT 1';
|
|
14
16
|
const OLDEST_FIRST = 'ORDER BY position, identity LIMIT 1';
|
|
@@ -63,11 +65,12 @@ export function heldConversations(connection, conversations) {
|
|
|
63
65
|
}
|
|
64
66
|
export function keptMessages(connection, { conversation, messages, read }) {
|
|
65
67
|
for (const message of messages) {
|
|
66
|
-
connection.run('INSERT INTO conversation_messages (conversation, identity, turn, position, message, text) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT (conversation, identity) DO UPDATE SET turn = excluded.turn, position = excluded.position, message = excluded.message, text = excluded.text', [
|
|
68
|
+
connection.run('INSERT INTO conversation_messages (conversation, identity, turn, position, change, message, text) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT (conversation, identity) DO UPDATE SET turn = excluded.turn, position = excluded.position, change = excluded.change, message = excluded.message, text = excluded.text', [
|
|
67
69
|
conversation,
|
|
68
70
|
message.identity,
|
|
69
71
|
message.turn,
|
|
70
72
|
message.position,
|
|
73
|
+
message.change,
|
|
71
74
|
JSON.stringify(message.message ?? null),
|
|
72
75
|
message.text,
|
|
73
76
|
]);
|
|
@@ -82,6 +85,7 @@ function accepted(row) {
|
|
|
82
85
|
identity: text(row.identity),
|
|
83
86
|
turn: text(row.turn),
|
|
84
87
|
position: text(row.position),
|
|
88
|
+
change: text(row.change),
|
|
85
89
|
text: text(row.text),
|
|
86
90
|
message: JSON.parse(text(row.message)),
|
|
87
91
|
};
|
|
@@ -93,7 +97,7 @@ function holding(phrase) {
|
|
|
93
97
|
}
|
|
94
98
|
export function messageWindow(connection, conversation, limit, before, phrase) {
|
|
95
99
|
const held = holding(phrase);
|
|
96
|
-
const rows = connection.rows(`SELECT identity, turn, position, message, text FROM conversation_messages WHERE conversation = ?${held.sql}${before === null ? '' : ' AND (position < ? OR (position = ? AND identity < ?))'} ORDER BY position DESC, identity DESC LIMIT ?`, before === null
|
|
100
|
+
const rows = connection.rows(`SELECT identity, turn, position, change, message, text FROM conversation_messages WHERE conversation = ?${held.sql}${before === null ? '' : ' AND (position < ? OR (position = ? AND identity < ?))'} ORDER BY position DESC, identity DESC LIMIT ?`, before === null
|
|
97
101
|
? [conversation, ...held.bind, limit + 1]
|
|
98
102
|
: [conversation, ...held.bind, before[0], before[0], before[1], limit + 1]);
|
|
99
103
|
return { messages: rows.slice(0, limit).map(accepted).reverse(), more: rows.length > limit };
|
|
@@ -137,12 +141,18 @@ export function conversationRows(connection, conversations) {
|
|
|
137
141
|
export function turnArrived(connection, conversation, turn) {
|
|
138
142
|
return (connection.rows('SELECT 1 FROM conversation_messages WHERE conversation = ? AND turn = ? LIMIT 1', [conversation, turn]).length > 0);
|
|
139
143
|
}
|
|
140
|
-
export function
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
export function conversationFacts(connection) {
|
|
145
|
+
return connection.rows('SELECT conversation, name, value FROM conversation_facts').map((row) => ({
|
|
146
|
+
conversation: text(row.conversation),
|
|
147
|
+
name: text(row.name),
|
|
148
|
+
value: text(row.value),
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
export function keptFact(connection, { conversation, name, value }) {
|
|
152
|
+
connection.run('INSERT OR REPLACE INTO conversation_facts (conversation, name, value) VALUES (?, ?, ?)', [conversation, name, value]);
|
|
153
|
+
return null;
|
|
144
154
|
}
|
|
145
|
-
export function
|
|
146
|
-
|
|
147
|
-
|
|
155
|
+
export function forgottenConversations(connection) {
|
|
156
|
+
for (const table of tablesOf(MESSAGE_TABLES))
|
|
157
|
+
connection.run(`DELETE FROM ${table}`);
|
|
148
158
|
}
|
package/dist/models.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAOnE,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAGvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAc,YAAY,EAAS,MAAM,YAAY,CAAC;AAMlE,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAE9D;
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAOnE,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAGvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAc,YAAY,EAAS,MAAM,YAAY,CAAC;AAMlE,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAE9D;AA0DD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,eAAe,EAC5B,KAAK,EAAE,UAAU,GAAG,IAAI,EACxB,OAAO,CAAC,EAAE,IAAI,iBA2Bf;AAED,wBAAsB,MAAM,CAC1B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,eAAe,iBAkB7B;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,EAC1C,MAAM,EAAE,SAAS,GAAG,QAAQ,EAC5B,KAAK,EAAE,YAAY,iBA8CpB;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvF"}
|
package/dist/models.js
CHANGED
|
@@ -3,7 +3,7 @@ import { changeSet } from './change-set.js';
|
|
|
3
3
|
import { composedOf } from './collection.js';
|
|
4
4
|
import { declared, sameDeclaration } from './declaration.js';
|
|
5
5
|
import { uncaught } from './failure.js';
|
|
6
|
-
import {
|
|
6
|
+
import { declarationOf, listedLocators } from './listing.js';
|
|
7
7
|
import { loseRooms } from './lost.js';
|
|
8
8
|
import { NO_MODEL } from './model.js';
|
|
9
9
|
import { settle } from './queue.js';
|
|
@@ -15,8 +15,8 @@ function declaredAsHeld(held, declaration) {
|
|
|
15
15
|
export function revoked(model) {
|
|
16
16
|
return model?.status === 'unavailable' && model.reason === 'revoked';
|
|
17
17
|
}
|
|
18
|
-
function unheldModelOf({
|
|
19
|
-
return
|
|
18
|
+
function unheldModelOf({ presence }, locator) {
|
|
19
|
+
return presence.unheldModel(locator) ?? NO_MODEL;
|
|
20
20
|
}
|
|
21
21
|
async function modelNow(runtime, locator) {
|
|
22
22
|
return (await runtime.store.record(locator))?.model ?? unheldModelOf(runtime, locator);
|
|
@@ -33,12 +33,8 @@ function recordAlone(store, record) {
|
|
|
33
33
|
composed: composedOf(store.composed(record)),
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
function unheld(runtime, locator, declaration, model) {
|
|
40
|
-
runtime.socket.rooms.stand(locator, { unheldModel: model });
|
|
41
|
-
listed(runtime, locator, declaration);
|
|
36
|
+
function unheld(runtime, locator, model) {
|
|
37
|
+
runtime.presence.modelled(locator, model);
|
|
42
38
|
emitRooms(runtime);
|
|
43
39
|
}
|
|
44
40
|
function recorded(runtime, locator, declaration, model) {
|
|
@@ -48,11 +44,10 @@ function recorded(runtime, locator, declaration, model) {
|
|
|
48
44
|
return;
|
|
49
45
|
const current = await store.record(locator);
|
|
50
46
|
if (current === undefined) {
|
|
51
|
-
unheld(runtime, locator,
|
|
47
|
+
unheld(runtime, locator, model);
|
|
52
48
|
return;
|
|
53
49
|
}
|
|
54
50
|
const answer = await (await store.open()).commit({ rooms: [recordAlone(store, { ...current, declaration, model })] });
|
|
55
|
-
listed(runtime, locator, declaration);
|
|
56
51
|
void store.changed(changeSet(locator, {
|
|
57
52
|
documents: answer.changed[locator] ?? [],
|
|
58
53
|
room: true,
|
|
@@ -76,7 +71,7 @@ export async function retainModel(runtime, locator, declaration, given, refused)
|
|
|
76
71
|
return [];
|
|
77
72
|
const current = works.get(locator)?.replica;
|
|
78
73
|
if (current === undefined) {
|
|
79
|
-
unheld(runtime, locator,
|
|
74
|
+
unheld(runtime, locator, next);
|
|
80
75
|
return [];
|
|
81
76
|
}
|
|
82
77
|
return [
|
|
@@ -84,33 +79,25 @@ export async function retainModel(runtime, locator, declaration, given, refused)
|
|
|
84
79
|
locator,
|
|
85
80
|
record: { ...current.record, declaration, model: next },
|
|
86
81
|
...(refused === undefined ? {} : { refused }),
|
|
87
|
-
after: () => listed(runtime, locator, declaration),
|
|
88
82
|
},
|
|
89
83
|
];
|
|
90
84
|
});
|
|
91
85
|
}
|
|
92
86
|
export async function scoped(runtime, result, locator, declaration) {
|
|
93
|
-
const { socket,
|
|
87
|
+
const { socket, presence } = runtime;
|
|
94
88
|
if (result.scope === 'content' && !result.retryable) {
|
|
95
|
-
journal.record(`scoped refusal ${locator} ${result.scope} ${result.code}`);
|
|
96
89
|
await loseRooms(runtime, [locator]);
|
|
97
90
|
return;
|
|
98
91
|
}
|
|
99
|
-
|
|
100
|
-
refusal: { code: result.code, fields: result.fields, retryable: result.retryable },
|
|
101
|
-
});
|
|
92
|
+
presence.refused(locator, result);
|
|
102
93
|
if (result.scope === 'model')
|
|
103
94
|
await retainModel(runtime, locator, declaration, { status: 'unavailable', reason: 'not-readable' }, true);
|
|
104
|
-
else if (result.scope !== 'operation')
|
|
105
|
-
socket.rooms.stand(locator, { unreadable: true });
|
|
106
95
|
if (!socket.continuing())
|
|
107
96
|
return;
|
|
108
|
-
listed(runtime, locator, declaration);
|
|
109
97
|
emitRooms(runtime);
|
|
110
|
-
journal.record(`scoped refusal ${locator} ${result.scope} ${result.code}`);
|
|
111
98
|
}
|
|
112
99
|
export async function settleModels(runtime, held, status, local) {
|
|
113
|
-
const { store, socket,
|
|
100
|
+
const { store, socket, presence } = runtime;
|
|
114
101
|
const owed = (model) => model.status !== 'unavailable' && model.status !== status;
|
|
115
102
|
const declaredAnew = await store.exclusive(async () => {
|
|
116
103
|
if (!socket.continuing())
|
|
@@ -132,18 +119,14 @@ export async function settleModels(runtime, held, status, local) {
|
|
|
132
119
|
await local.commit({ rooms: records.map((record) => recordAlone(store, record)) });
|
|
133
120
|
}
|
|
134
121
|
catch (error) {
|
|
135
|
-
journal.record(`model ${status} persistence failed`);
|
|
136
122
|
uncaught(error);
|
|
137
123
|
}
|
|
138
124
|
}
|
|
139
|
-
for (const [locator
|
|
140
|
-
const
|
|
125
|
+
for (const [locator] of unchanged) {
|
|
126
|
+
const unheldModel = presence.unheldModel(locator);
|
|
141
127
|
if (!stored.has(locator) && unheldModel !== null) {
|
|
142
|
-
|
|
143
|
-
unheldModel: { ...unheldModel, status },
|
|
144
|
-
});
|
|
128
|
+
presence.modelled(locator, { ...unheldModel, status });
|
|
145
129
|
}
|
|
146
|
-
listed(runtime, locator, declaration);
|
|
147
130
|
}
|
|
148
131
|
if (unchanged.length > 0)
|
|
149
132
|
emitRooms(runtime);
|
|
@@ -158,10 +141,10 @@ export async function settleModels(runtime, held, status, local) {
|
|
|
158
141
|
}
|
|
159
142
|
}
|
|
160
143
|
export async function cachedModels(runtime, local) {
|
|
161
|
-
const { store,
|
|
144
|
+
const { store, presence } = runtime;
|
|
162
145
|
const held = await store.rooms();
|
|
163
146
|
await settleModels(runtime, new Map(listedLocators(runtime, held).flatMap((locator) => {
|
|
164
|
-
const discovered =
|
|
147
|
+
const discovered = presence.room(locator);
|
|
165
148
|
const declaration = discovered === undefined
|
|
166
149
|
? declarationOf(runtime, locator, held.get(locator))?.room
|
|
167
150
|
: declared(discovered);
|
package/dist/opened.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ export type OpenedFiles = {
|
|
|
18
18
|
find(name: OpenedName): Promise<KeptBinary | null>;
|
|
19
19
|
fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
|
|
20
20
|
};
|
|
21
|
-
export declare function openedFiles(database: RuntimeDatabase,
|
|
21
|
+
export declare function openedFiles(database: RuntimeDatabase, lost: (locator: string) => boolean): OpenedFiles;
|
|
22
22
|
//# sourceMappingURL=opened.d.ts.map
|
package/dist/opened.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../src/opened.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAErF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SA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UAAU,GAAG,IAAI,CAAC,CAAC;IACnD,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACjF,CAAC;AAsBF,wBAAgB,WAAW,CACzB,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,GACjC,WAAW,CAsFb"}
|
package/dist/opened.js
CHANGED
|
@@ -20,7 +20,7 @@ function taken(chunks, size) {
|
|
|
20
20
|
}
|
|
21
21
|
return part;
|
|
22
22
|
}
|
|
23
|
-
export function openedFiles(database,
|
|
23
|
+
export function openedFiles(database, lost) {
|
|
24
24
|
const fetching = new Map();
|
|
25
25
|
async function find(name) {
|
|
26
26
|
const held = await database.ask({ kind: 'opened.find', ...name });
|
|
@@ -41,7 +41,7 @@ export function openedFiles(database, fenced) {
|
|
|
41
41
|
part += 1;
|
|
42
42
|
};
|
|
43
43
|
try {
|
|
44
|
-
if (
|
|
44
|
+
if (lost(name.locator) ||
|
|
45
45
|
!(await database.ask({ kind: 'opened.begin', key, ...name, mediaType }))) {
|
|
46
46
|
throw new Error();
|
|
47
47
|
}
|
package/dist/opening.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAqCxF"}
|
package/dist/opening.js
CHANGED
|
@@ -7,7 +7,7 @@ import { prepare } from './preparation.js';
|
|
|
7
7
|
import { unpair } from './queue.js';
|
|
8
8
|
import { emitRooms, emitStorageLoss, statusShown } from './shown.js';
|
|
9
9
|
export async function open(runtime, opened) {
|
|
10
|
-
const { store, socket,
|
|
10
|
+
const { store, socket, shell, conversations, build, usableWhenHeld } = runtime;
|
|
11
11
|
if (socket.closed())
|
|
12
12
|
throw new Error('runtime closed');
|
|
13
13
|
const interrupted = await opened.fences();
|
|
@@ -42,18 +42,12 @@ export async function open(runtime, opened) {
|
|
|
42
42
|
await conversationsOpened(conversations, opened);
|
|
43
43
|
if (interrupted.length > 0) {
|
|
44
44
|
queueMicrotask(() => {
|
|
45
|
-
void eraseFenced(runtime, interrupted).catch(
|
|
46
|
-
journal.record('erasure failed');
|
|
47
|
-
uncaught(error);
|
|
48
|
-
});
|
|
45
|
+
void eraseFenced(runtime, interrupted).catch(uncaught);
|
|
49
46
|
});
|
|
50
47
|
}
|
|
51
48
|
statusShown(runtime);
|
|
52
49
|
prepare(runtime);
|
|
53
50
|
emitRooms(runtime);
|
|
54
|
-
void unpair(runtime).catch(
|
|
55
|
-
journal.record('unpair failed');
|
|
56
|
-
uncaught(error);
|
|
57
|
-
});
|
|
51
|
+
void unpair(runtime).catch(uncaught);
|
|
58
52
|
return opened;
|
|
59
53
|
}
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
|
+
import type { Attempt, Retries } from './retried.js';
|
|
3
4
|
import type { KeptBinary, KeptResult } from './opened.js';
|
|
4
5
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
5
6
|
kind: Kind;
|
|
@@ -84,5 +85,7 @@ export type QueueEntry = {
|
|
|
84
85
|
} & (Submission | {
|
|
85
86
|
readonly state: 'local';
|
|
86
87
|
});
|
|
88
|
+
export declare const UNANSWERED: ActionResult;
|
|
89
|
+
export declare function handedOutcome(retries: Retries, attempt: Attempt | undefined, result: ActionResult): CallResult;
|
|
87
90
|
export {};
|
|
88
91
|
//# sourceMappingURL=outcome.d.ts.map
|
package/dist/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,KAAK,OAAO,CAAC,IAAI,SAAS,MAAM,IAAI,eAAe,GAAG;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAErE,MAAM,MAAM,OAAO,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aAAa,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,MAAM,EAAE,YAAY,GACnB,UAAU,CAUZ"}
|
package/dist/outcome.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refusalError } from './failure.js';
|
|
1
2
|
export const UNREADABLE = {
|
|
2
3
|
kind: 'unreadable',
|
|
3
4
|
code: 'room-not-readable',
|
|
@@ -82,3 +83,17 @@ export function historyAnswer(result) {
|
|
|
82
83
|
? result
|
|
83
84
|
: failure(result);
|
|
84
85
|
}
|
|
86
|
+
export const UNANSWERED = { kind: 'transport-uncertainty' };
|
|
87
|
+
export function handedOutcome(retries, attempt, result) {
|
|
88
|
+
if (attempt !== undefined) {
|
|
89
|
+
const { step, instance } = attempt;
|
|
90
|
+
if (result.kind === 'action')
|
|
91
|
+
retries.succeeded(step, instance);
|
|
92
|
+
else if (result.kind === 'transport-uncertainty')
|
|
93
|
+
retries.uncertain(step, instance, result);
|
|
94
|
+
else if (result.kind === 'rejected' && result.retryable) {
|
|
95
|
+
retries.failed(step, instance, refusalError(result));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return calledResult(result);
|
|
99
|
+
}
|
package/dist/overlay.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ApplyResult } from '@agentshouse/mdmodel';
|
|
1
2
|
import type { BinaryFile, HeadChange } from './adapter.js';
|
|
2
3
|
import { type Composition } from './collection.js';
|
|
3
4
|
import type { ChangeBatch } from './change.js';
|
|
@@ -23,5 +24,7 @@ export type Layer = Heads & {
|
|
|
23
24
|
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
24
25
|
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
25
26
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
27
|
+
export declare function composed(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): ApplyResult;
|
|
28
|
+
export declare function compose(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): string;
|
|
26
29
|
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], composition: Composition, unapplied?: () => void): Generator<number, Layer, void>;
|
|
27
30
|
//# 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":"AAAA,OAAO,EAOL,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAC;AAC9B,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,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GAAG,UAAU,CAAC,GAC7C;IACE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ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AAW,GACvB,MAAM,CAIR;AA8ID,wBAAiB,UAAU,CACzB,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,WAAW,EAAE,WAAW,EACxB,SAAS,CAAC,EAAE,MAAM,IAAI,GACrB,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAsChC"}
|
package/dist/overlay.js
CHANGED
|
@@ -53,12 +53,11 @@ function* priorsOf(preconditions) {
|
|
|
53
53
|
preamble: (path) => preambles.get(path) ?? '',
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
export function composed(path, fields, sections, composition) {
|
|
57
57
|
const declared = fields[TYPE_FIELD];
|
|
58
58
|
const type = typeof declared === 'string' && declared !== '' ? declared : undefined;
|
|
59
59
|
const definition = definitionsAt(composition, path)(type);
|
|
60
|
-
|
|
61
|
-
const next = apply(created, [
|
|
60
|
+
return apply(create(type, definition), [
|
|
62
61
|
...Object.entries(fields).flatMap(([name, value]) => (name !== TYPE_FIELD || type === undefined) && frontmatterValue(value)
|
|
63
62
|
? [{ kind: 'field', name, value, prior: undefined }]
|
|
64
63
|
: []),
|
|
@@ -69,7 +68,12 @@ function compose(path, fields, sections, composition) {
|
|
|
69
68
|
prior: undefined,
|
|
70
69
|
})),
|
|
71
70
|
], definition);
|
|
72
|
-
|
|
71
|
+
}
|
|
72
|
+
export function compose(path, fields, sections, composition) {
|
|
73
|
+
const next = composed(path, fields, sections, composition);
|
|
74
|
+
if (next.outcome !== 'applied')
|
|
75
|
+
throw new Error(`the creation of ${path} writes no document`);
|
|
76
|
+
return serialize(next.document);
|
|
73
77
|
}
|
|
74
78
|
function edited(change, priors) {
|
|
75
79
|
if (change.kind === 'field')
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const PAGE_METADATA_WORDS: {
|
|
2
|
+
readonly heading: 'Page metadata';
|
|
3
|
+
readonly app: 'App';
|
|
4
|
+
readonly address: 'Address';
|
|
5
|
+
readonly queries: 'Local Queries';
|
|
6
|
+
};
|
|
7
|
+
export declare function pageMetadataBlock(app: string, address: string, queries: readonly unknown[]): string;
|
|
8
|
+
//# sourceMappingURL=page-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-metadata.d.ts","sourceRoot":"","sources":["../src/page-metadata.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB;aAC9B,OAAO,EAAE,eAAe;aACxB,GAAG,EAAE,KAAK;aACV,OAAO,EAAE,SAAS;aAClB,OAAO,EAAE,eAAe;CAChB,CAAC;AAIX,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,SAAS,OAAO,EAAE,GAC1B,MAAM,CAUR"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { queryKey } from '@agentshouse/mdmodel';
|
|
2
|
+
export const PAGE_METADATA_WORDS = {
|
|
3
|
+
heading: 'Page metadata',
|
|
4
|
+
app: 'App',
|
|
5
|
+
address: 'Address',
|
|
6
|
+
queries: 'Local Queries',
|
|
7
|
+
};
|
|
8
|
+
const PAGE_METADATA_QUERIES = 10;
|
|
9
|
+
export function pageMetadataBlock(app, address, queries) {
|
|
10
|
+
const held = [...new Set(queries.map(queryKey))];
|
|
11
|
+
return [
|
|
12
|
+
PAGE_METADATA_WORDS.heading,
|
|
13
|
+
`${PAGE_METADATA_WORDS.app}: ${app}`,
|
|
14
|
+
`${PAGE_METADATA_WORDS.address}: ${address}`,
|
|
15
|
+
...(held.length === 0 || held.length > PAGE_METADATA_QUERIES
|
|
16
|
+
? []
|
|
17
|
+
: [`${PAGE_METADATA_WORDS.queries}:`, ...held]),
|
|
18
|
+
].join('\n');
|
|
19
|
+
}
|
package/dist/parts.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import { type Part
|
|
2
|
-
export
|
|
3
|
-
readonly kind: 'job' | 'schedule' | 'subagent';
|
|
4
|
-
readonly title: string;
|
|
5
|
-
readonly next: string | null;
|
|
6
|
-
readonly activity: string | null;
|
|
7
|
-
};
|
|
8
|
-
export declare function counted(count: number): string;
|
|
1
|
+
import { type Part } from '@agentshouse/session-content';
|
|
2
|
+
export declare function currentStep(parts: readonly Part[]): string | null;
|
|
9
3
|
export declare function runningLine(parts: readonly Part[]): string | null;
|
|
10
|
-
export declare function workOf(state: SessionState | null): readonly ChatWork[];
|
|
11
4
|
//# 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,EAAS,KAAK,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../src/parts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAGhE,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,MAAM,GAAG,IAAI,CAGjE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,MAAM,GAAG,IAAI,CAKjE"}
|
package/dist/parts.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import { isOwn } from '@agentshouse/session-content';
|
|
2
2
|
import { excerpt } from './read.js';
|
|
3
|
-
export function
|
|
4
|
-
|
|
3
|
+
export function currentStep(parts) {
|
|
4
|
+
const call = [...parts].reverse().find((part) => part.type === 'call');
|
|
5
|
+
return call?.type === 'call' && call.line !== '' ? call.line : null;
|
|
5
6
|
}
|
|
6
7
|
export function runningLine(parts) {
|
|
7
|
-
const
|
|
8
|
-
const note =
|
|
8
|
+
const own = parts.filter(isOwn);
|
|
9
|
+
const note = [...own].reverse().find((part) => part.type === 'text' && part.text.trim() !== '');
|
|
9
10
|
if (note?.type === 'text')
|
|
10
11
|
return excerpt(note.text);
|
|
11
|
-
|
|
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
|
-
}));
|
|
12
|
+
return currentStep(own);
|
|
21
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preparation.d.ts","sourceRoot":"","sources":["../src/preparation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAE3B,KAAK,SAAS,EAEf,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;CAClD,CAAC;
|
|
1
|
+
{"version":3,"file":"preparation.d.ts","sourceRoot":"","sources":["../src/preparation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAA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
31
|
+
async function unprepared({ store }) {
|
|
32
32
|
const held = (await store.covering()).rooms;
|
|
33
|
-
|
|
33
|
+
const { unpreparedDemand, unpreparable } = store.device.now();
|
|
34
|
+
return [...unpreparedDemand, ...held.keys()].find((locator) => !(held.get(locator)?.indexed ?? false) && !unpreparable.has(locator));
|
|
34
35
|
}
|
|
35
|
-
function unpreparedBy({ store
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
function unpreparedBy({ store }, locator) {
|
|
37
|
+
const { unpreparable } = store.device.now();
|
|
38
|
+
store.device.set({ unpreparable: new Set([...unpreparable, locator]) });
|
|
38
39
|
store.readiness.queue();
|
|
39
40
|
}
|
|
40
41
|
export function prepare(runtime, locators = []) {
|
|
41
|
-
const { store, socket
|
|
42
|
+
const { store, socket } = runtime;
|
|
42
43
|
const { device } = store;
|
|
43
44
|
if (locators.length > 0) {
|
|
44
45
|
device.set({ unpreparedDemand: new Set([...device.now().unpreparedDemand, ...locators]) });
|
|
@@ -55,11 +56,10 @@ export function prepare(runtime, locators = []) {
|
|
|
55
56
|
const demand = new Set(device.now().unpreparedDemand);
|
|
56
57
|
demand.delete(waiting);
|
|
57
58
|
device.set({ unpreparedDemand: demand });
|
|
58
|
-
await prepareReplica(runtime, waiting).catch((
|
|
59
|
+
await prepareReplica(runtime, waiting).catch(() => unpreparedBy(runtime, waiting));
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
catch (error) {
|
|
62
|
-
journal.record('preparation failed');
|
|
63
63
|
uncaught(error);
|
|
64
64
|
}
|
|
65
65
|
finally {
|
|
@@ -81,12 +81,9 @@ function requiredRooms(runtime, given, held) {
|
|
|
81
81
|
return { listed: true, rooms: named.filter((room) => listed.has(room)) };
|
|
82
82
|
return { listed: named.every((room) => held.has(room)), rooms: named };
|
|
83
83
|
}
|
|
84
|
-
function roomState({ socket }, locator, held) {
|
|
85
|
-
const listedRoom = socket.rooms.discovered(locator);
|
|
84
|
+
function roomState({ socket, presence }, locator, held) {
|
|
86
85
|
if (socket.session.now().roomsListed &&
|
|
87
|
-
(
|
|
88
|
-
listedRoom.replica.admission !== 'admitted' ||
|
|
89
|
-
socket.rooms.standing(locator).unreadable))
|
|
86
|
+
(presence.room(locator) === undefined || !presence.available(locator)))
|
|
90
87
|
return 'unadmitted';
|
|
91
88
|
const stored = held.get(locator);
|
|
92
89
|
if (stored === undefined)
|
|
@@ -126,8 +123,9 @@ function readinessFor(runtime, port, reach, { held, facts }) {
|
|
|
126
123
|
const { store, socket, usableWhenHeld } = runtime;
|
|
127
124
|
const required = requiredRooms(runtime, reach, held);
|
|
128
125
|
const coverage = required.rooms.map((room) => ({ room, state: roomState(runtime, room, held) }));
|
|
126
|
+
const { unpreparable } = store.device.now();
|
|
129
127
|
const preparing = coverage
|
|
130
|
-
.filter((room) => room.state === 'preparing' && !
|
|
128
|
+
.filter((room) => room.state === 'preparing' && !unpreparable.has(room.room))
|
|
131
129
|
.map(({ room }) => room);
|
|
132
130
|
if (preparing.length > 0)
|
|
133
131
|
prepare(runtime, preparing);
|
|
@@ -154,7 +152,7 @@ function readinessFor(runtime, port, reach, { held, facts }) {
|
|
|
154
152
|
});
|
|
155
153
|
}
|
|
156
154
|
function establish(runtime, name) {
|
|
157
|
-
const { store
|
|
155
|
+
const { store } = runtime;
|
|
158
156
|
const { device } = store;
|
|
159
157
|
if (device.now().establishing.has(name))
|
|
160
158
|
return;
|
|
@@ -167,10 +165,7 @@ function establish(runtime, name) {
|
|
|
167
165
|
.then(() => {
|
|
168
166
|
store.readiness.queue();
|
|
169
167
|
void probeEachMinute(runtime);
|
|
170
|
-
},
|
|
171
|
-
journal.record(`target record failed ${name}`);
|
|
172
|
-
uncaught(error);
|
|
173
|
-
})
|
|
168
|
+
}, uncaught)
|
|
174
169
|
.finally(() => {
|
|
175
170
|
const establishing = new Set(device.now().establishing);
|
|
176
171
|
establishing.delete(name);
|
|
@@ -202,10 +197,9 @@ export function watchReadiness({ store }, port, reach, deliver) {
|
|
|
202
197
|
return stop;
|
|
203
198
|
}
|
|
204
199
|
export function filled(runtime) {
|
|
205
|
-
const { store, socket
|
|
200
|
+
const { store, socket } = runtime;
|
|
206
201
|
if (socket.closed() || !store.space.fill())
|
|
207
202
|
return;
|
|
208
|
-
journal.record('space full');
|
|
209
203
|
store.readiness.queue();
|
|
210
204
|
void probeEachMinute(runtime);
|
|
211
205
|
}
|