@agentshouse/mdruntime 0.1.0-cf1e7fdb9c600 → 0.1.0-cf281e8224a5d
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 +9 -9
- package/dist/acceptance.d.ts +6 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +385 -0
- package/dist/actions.d.ts +20 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +251 -0
- package/dist/adapter.d.ts +24 -25
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +21 -56
- package/dist/bootstrap.d.ts +8 -4
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +207 -76
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/change.d.ts +1 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- package/dist/chat-types.d.ts +5 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +13 -0
- package/dist/client.d.ts +18 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -2
- package/dist/compile.d.ts +5 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +202 -80
- package/dist/connection.d.ts +5 -141
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +101 -5280
- package/dist/conversation-live.d.ts +136 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +248 -0
- package/dist/conversation-row.d.ts +33 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +53 -0
- package/dist/conversation.d.ts +29 -35
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +838 -840
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +175 -0
- package/dist/durability.d.ts +15 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +4 -3
- package/dist/expectation.d.ts +4 -2
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +33 -11
- package/dist/figures.d.ts +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +197 -0
- package/dist/holdings.d.ts +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +1 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +11 -4
- 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 +20 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/install.d.ts +56 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +554 -0
- package/dist/job.d.ts +20 -1
- package/dist/job.d.ts.map +1 -1
- package/dist/job.js +26 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +268 -0
- package/dist/listing.d.ts +53 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +176 -0
- package/dist/live.d.ts +4 -4
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +52 -16
- package/dist/locks.d.ts +9 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +61 -0
- package/dist/log.d.ts +1 -0
- package/dist/log.d.ts.map +1 -1
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +61 -0
- 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 +3 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +45 -6
- package/dist/messages.d.ts +25 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +89 -16
- package/dist/model.d.ts +1 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -6
- package/dist/models.d.ts +14 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +195 -0
- 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 +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +57 -0
- package/dist/outcome.d.ts +4 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +3 -0
- package/dist/overlay.d.ts +1 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +11 -0
- package/dist/parts.d.ts +60 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +126 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +20 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +226 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +272 -0
- package/dist/query.d.ts +10 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +34 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +122 -0
- package/dist/reach.d.ts +8 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +159 -100
- package/dist/react.d.ts +11 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +10 -1
- package/dist/read.d.ts +7 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +17 -0
- package/dist/readiness.d.ts +0 -1
- package/dist/readiness.d.ts.map +1 -1
- package/dist/reads.d.ts +37 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +171 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +9 -1
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +8 -20
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +55 -0
- package/dist/replica.d.ts +7 -7
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +51 -19
- package/dist/room-draft.d.ts +2 -4
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +3 -3
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +217 -0
- package/dist/rows.d.ts +14 -5
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +50 -58
- package/dist/runtime.d.ts +43 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +5 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +21 -20
- package/dist/saves.d.ts +70 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +1005 -0
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -1
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +31 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +292 -0
- package/dist/socket/admission.d.ts +7 -0
- package/dist/socket/admission.d.ts.map +1 -0
- package/dist/socket/admission.js +39 -0
- package/dist/socket/answers.d.ts +6 -0
- package/dist/socket/answers.d.ts.map +1 -0
- package/dist/socket/answers.js +20 -0
- package/dist/socket/lanes.d.ts +20 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +77 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket/rooms.d.ts +44 -0
- package/dist/socket/rooms.d.ts.map +1 -0
- package/dist/socket/rooms.js +90 -0
- package/dist/socket/session.d.ts +38 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +23 -0
- package/dist/socket.d.ts +70 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +175 -0
- package/dist/source.d.ts +61 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +82 -0
- package/dist/status.d.ts +0 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -6
- package/dist/store/fences.d.ts +16 -0
- package/dist/store/fences.d.ts.map +1 -0
- package/dist/store/fences.js +26 -0
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +34 -0
- package/dist/store/readiness.d.ts +10 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +52 -0
- package/dist/store/records.d.ts +212 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +431 -0
- package/dist/store/room-held.d.ts +8 -0
- package/dist/store/room-held.d.ts.map +1 -0
- package/dist/store/room-held.js +17 -0
- package/dist/store/space.d.ts +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +41 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +56 -0
- package/dist/store/writes.d.ts +24 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +125 -0
- package/dist/store.d.ts +107 -153
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +143 -396
- package/dist/stored.d.ts +59 -65
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +255 -149
- package/dist/surface.d.ts +88 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +223 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +532 -0
- package/dist/tables.d.ts +114 -51
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +209 -57
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +129 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +4 -4
- package/dist/wire.d.ts +16 -1
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +6 -0
- package/package.json +2 -2
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../src/questions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,cAAc,CAAC;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAuCF,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAEjD;AA2DD,wBAAgB,WAAW,CACzB,IAAI,EAAE,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,GAAG,IAAI,GAC/C,SAAS,YAAY,EAAE,CAiBzB;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,GAAG,IAAI,CAKzE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,GAAG,IAAI,CAE1E;AAED,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAEtF,wBAAgB,MAAM,CAAC,SAAS,EAAE,SAAS,YAAY,EAAE,GAAG,QAAQ,GAAG,IAAI,CAM1E"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { excerpt, list, record, text } from './read.js';
|
|
2
|
+
const OPTION = 'optionId';
|
|
3
|
+
function choicesOf(schema) {
|
|
4
|
+
const items = record(schema.items);
|
|
5
|
+
const listed = [schema.oneOf, schema.enum, items.anyOf, items.enum].find(Array.isArray) ?? [];
|
|
6
|
+
return listed.flatMap((one) => {
|
|
7
|
+
if (typeof one === 'string')
|
|
8
|
+
return [{ value: one, label: one, about: null }];
|
|
9
|
+
const value = text(record(one), 'const');
|
|
10
|
+
return value === null
|
|
11
|
+
? []
|
|
12
|
+
: [
|
|
13
|
+
{
|
|
14
|
+
value,
|
|
15
|
+
label: text(record(one), 'title') ?? value,
|
|
16
|
+
about: text(record(one), 'description'),
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function fieldOf(name, schema) {
|
|
22
|
+
const type = text(schema, 'type');
|
|
23
|
+
const kind = type === 'boolean' || type === 'number' || type === 'integer'
|
|
24
|
+
? type
|
|
25
|
+
: type === 'array'
|
|
26
|
+
? 'multi-select'
|
|
27
|
+
: 'string';
|
|
28
|
+
return {
|
|
29
|
+
name,
|
|
30
|
+
kind,
|
|
31
|
+
prompt: text(schema, 'title') ?? name,
|
|
32
|
+
about: text(schema, 'description'),
|
|
33
|
+
choices: kind === 'boolean' ? [] : choicesOf(schema),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function entered(field) {
|
|
37
|
+
return field.kind !== 'boolean' && field.choices.length === 0;
|
|
38
|
+
}
|
|
39
|
+
function valueOf(field, raw) {
|
|
40
|
+
return field.kind === 'number' || field.kind === 'integer' ? Number(raw) : raw;
|
|
41
|
+
}
|
|
42
|
+
function typed(fields, answer) {
|
|
43
|
+
return Object.fromEntries(Object.entries(answer).map(([name, value]) => {
|
|
44
|
+
const field = fields.find((one) => one.name === name);
|
|
45
|
+
return [
|
|
46
|
+
name,
|
|
47
|
+
field !== undefined && entered(field) && typeof value === 'string'
|
|
48
|
+
? valueOf(field, value)
|
|
49
|
+
: value,
|
|
50
|
+
];
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
function askedOf(request) {
|
|
54
|
+
const params = record(request.params);
|
|
55
|
+
const method = text(request, 'method');
|
|
56
|
+
if (method === 'session/request_permission') {
|
|
57
|
+
return {
|
|
58
|
+
message: '',
|
|
59
|
+
fields: [
|
|
60
|
+
{
|
|
61
|
+
name: OPTION,
|
|
62
|
+
kind: 'string',
|
|
63
|
+
prompt: text(record(params.toolCall), 'title') ?? '',
|
|
64
|
+
about: null,
|
|
65
|
+
choices: list(params, 'options').flatMap((entry) => {
|
|
66
|
+
const one = record(entry);
|
|
67
|
+
const value = text(one, OPTION);
|
|
68
|
+
return value === null
|
|
69
|
+
? []
|
|
70
|
+
: [{ value, label: text(one, 'name') ?? value, about: null }];
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
accept: (answer) => ({ outcome: { outcome: 'selected', optionId: answer[OPTION] } }),
|
|
75
|
+
decline: null,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (method !== 'elicitation/create')
|
|
79
|
+
return null;
|
|
80
|
+
const fields = Object.entries(record(record(params.requestedSchema).properties)).map(([name, schema]) => fieldOf(name, record(schema)));
|
|
81
|
+
return {
|
|
82
|
+
message: text(params, 'message') ?? '',
|
|
83
|
+
fields,
|
|
84
|
+
accept: (answer) => ({ action: 'accept', content: typed(fields, answer) }),
|
|
85
|
+
decline: { action: 'decline' },
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export function questionsOf(view) {
|
|
89
|
+
return (view?.questions ?? []).flatMap((entry) => {
|
|
90
|
+
const one = record(entry);
|
|
91
|
+
const interaction = text(one, 'interaction_id');
|
|
92
|
+
const asked = askedOf(record(one.request));
|
|
93
|
+
return asked === null || interaction === null
|
|
94
|
+
? []
|
|
95
|
+
: [
|
|
96
|
+
{
|
|
97
|
+
interaction,
|
|
98
|
+
asked: text(one, 'asked_at'),
|
|
99
|
+
secret: one.secret === true,
|
|
100
|
+
undelivered: one.telegram_undelivered === true,
|
|
101
|
+
...asked,
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
export function openQuestion(questions) {
|
|
107
|
+
const [asked] = questionsOf({ questions });
|
|
108
|
+
if (asked === undefined)
|
|
109
|
+
return null;
|
|
110
|
+
const said = asked.message === '' ? asked.fields[0]?.prompt : asked.message;
|
|
111
|
+
return said === undefined || said === '' ? null : excerpt(said);
|
|
112
|
+
}
|
|
113
|
+
export function questionAsked(questions) {
|
|
114
|
+
return questionsOf({ questions })[0]?.asked ?? null;
|
|
115
|
+
}
|
|
116
|
+
export function loneOf(questions) {
|
|
117
|
+
const asked = questions.length === 1 && !questions[0].secret ? questions[0] : undefined;
|
|
118
|
+
const only = asked?.fields.length === 1 ? asked.fields[0] : undefined;
|
|
119
|
+
return asked !== undefined && only !== undefined && entered(only)
|
|
120
|
+
? { question: asked, field: only }
|
|
121
|
+
: null;
|
|
122
|
+
}
|
package/dist/reach.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { AppRoom
|
|
1
|
+
import type { AppRoom } from './listing.js';
|
|
2
|
+
import type { ReadinessPort } from './preparation.js';
|
|
3
|
+
import type { MdRuntime, RuntimeTopic } from './surface.js';
|
|
2
4
|
import type { Plan, PlanReach, QueryResult } from './query.js';
|
|
3
5
|
import type { Readiness } from './readiness.js';
|
|
4
6
|
import type { SearchResult } from './search.js';
|
|
@@ -28,16 +30,16 @@ export type NarrowedView = RuntimeView & {
|
|
|
28
30
|
narrow(reach: PortReach | null): void;
|
|
29
31
|
};
|
|
30
32
|
export type Reachable = RuntimeView & {
|
|
31
|
-
plan(input: unknown, reach: PortReach | null): Plan
|
|
33
|
+
plan(input: unknown, reach: PortReach | null): Promise<Plan>;
|
|
32
34
|
query(plan: Plan): Promise<QueryResult>;
|
|
33
35
|
watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
|
|
34
36
|
search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
|
|
35
37
|
watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
|
|
36
|
-
locked(room: string): boolean
|
|
37
|
-
lockedRooms(): readonly string[]
|
|
38
|
+
locked(room: string): Promise<boolean>;
|
|
39
|
+
lockedRooms(): Promise<readonly string[]>;
|
|
38
40
|
watchLocks(notify: () => void): () => void;
|
|
39
|
-
located(room: string, path: string, destination: string): ReachedDocument | null
|
|
40
|
-
room(locator: string): AppRoom | undefined
|
|
41
|
+
located(room: string, path: string, destination: string): Promise<ReachedDocument | null>;
|
|
42
|
+
room(locator: string): Promise<AppRoom | undefined>;
|
|
41
43
|
};
|
|
42
44
|
export declare function holds(reach: PortReach | null, room: string): boolean;
|
|
43
45
|
export declare function governs(reach: PortReach | null, room: {
|
package/dist/reach.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;AA2BzE,OAAO,KAAK,EAAiB,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAS9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IAC/C,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAA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I,GAAG,MAAM,IAAI,CAAC;IAC3C,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IAC1F,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;CACrD,CAAC;AAsCF,wBAAgB,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMpE;AAMD,wBAAgB,OAAO,CACrB,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,IAAI,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE;QAAE,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GAC/F;IAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAU/D;AAeD,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAcnE;AA2GD,wBAAgB,QAAQ,CACtB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,IAAI,EAAE,aAAa,GAClB,YAAY,CAiYd"}
|
package/dist/reach.js
CHANGED
|
@@ -143,7 +143,7 @@ function lockedError(room) {
|
|
|
143
143
|
return runtimeError(ROOM_LOCKED, `${room} is locked until House confirms its access`, true);
|
|
144
144
|
}
|
|
145
145
|
function deviceUnreached() {
|
|
146
|
-
return runtimeError('device-unreached', 'Only the panel
|
|
146
|
+
return runtimeError('device-unreached', 'Only the panel reaches this device');
|
|
147
147
|
}
|
|
148
148
|
const ATTACH_REQUIRED = 'attach-required';
|
|
149
149
|
function attachRequired() {
|
|
@@ -170,15 +170,65 @@ export function narrowed(runtime, given, port) {
|
|
|
170
170
|
stop();
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
-
const unlocking = (rooms) => {
|
|
174
|
-
const
|
|
175
|
-
return
|
|
176
|
-
? null
|
|
177
|
-
: { pending: locked.map((room) => ({ room, awaits: 'unlock' })) };
|
|
173
|
+
const unlocking = (rooms, locked) => {
|
|
174
|
+
const held = (rooms ?? []).filter((room) => locked.includes(room));
|
|
175
|
+
return held.length === 0 ? null : { pending: held.map((room) => ({ room, awaits: 'unlock' })) };
|
|
178
176
|
};
|
|
179
|
-
const unlocked = (entries) => entries.filter((entry) => !
|
|
180
|
-
const intoLocked = (held) =>
|
|
177
|
+
const unlocked = (entries, locked) => entries.filter((entry) => !locked.includes(entry.room));
|
|
178
|
+
const intoLocked = async (held) => {
|
|
179
|
+
for (const move of held) {
|
|
180
|
+
if (move?.room !== undefined && (await runtime.locked(move.room)))
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
return false;
|
|
184
|
+
};
|
|
185
|
+
function ordered(deliver) {
|
|
186
|
+
let open = true;
|
|
187
|
+
let shown = Promise.resolve();
|
|
188
|
+
return {
|
|
189
|
+
push(making) {
|
|
190
|
+
shown = shown.then(() => making.then((value) => {
|
|
191
|
+
if (open)
|
|
192
|
+
deliver(value);
|
|
193
|
+
}, () => { }), () => { });
|
|
194
|
+
},
|
|
195
|
+
stop() {
|
|
196
|
+
open = false;
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function unlockedWatch(topic, input, deliver, fail, within) {
|
|
201
|
+
const shown = ordered(deliver);
|
|
202
|
+
const stop = watch(topic, input, (message) => {
|
|
203
|
+
shown.push(runtime.lockedRooms().then((locked) => within(message, locked)));
|
|
204
|
+
}, fail);
|
|
205
|
+
return () => {
|
|
206
|
+
shown.stop();
|
|
207
|
+
stop();
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function lockedFirst(room, start, shut) {
|
|
211
|
+
let open = true;
|
|
212
|
+
let stop = () => { };
|
|
213
|
+
void (async () => {
|
|
214
|
+
const closed = !holds(reach, room) || (await runtime.locked(room));
|
|
215
|
+
if (!open)
|
|
216
|
+
return;
|
|
217
|
+
if (closed)
|
|
218
|
+
shut();
|
|
219
|
+
else
|
|
220
|
+
stop = start();
|
|
221
|
+
})();
|
|
222
|
+
return () => {
|
|
223
|
+
open = false;
|
|
224
|
+
stop();
|
|
225
|
+
};
|
|
226
|
+
}
|
|
181
227
|
const within = (topic, input, deliver, fail) => {
|
|
228
|
+
if (topic === 'read' && reach !== null) {
|
|
229
|
+
fail(deviceUnreached());
|
|
230
|
+
return () => { };
|
|
231
|
+
}
|
|
182
232
|
if (topic === 'rooms') {
|
|
183
233
|
return following(() => watch(topic, input, (rooms) => deliver(roomsWithin(reach, rooms)), fail));
|
|
184
234
|
}
|
|
@@ -186,55 +236,59 @@ export function narrowed(runtime, given, port) {
|
|
|
186
236
|
return following(() => runtime.watchReadiness(port, reach, deliver));
|
|
187
237
|
}
|
|
188
238
|
if (topic === 'sync-status') {
|
|
189
|
-
return following(() =>
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
}
|
|
239
|
+
return following(() => unlockedWatch(topic, input, deliver, fail, (status, locked) => {
|
|
240
|
+
const shown = statusWithin(reach, status);
|
|
241
|
+
return { ...shown, attentionRequired: unlocked(shown.attentionRequired, locked) };
|
|
242
|
+
}), true);
|
|
193
243
|
}
|
|
194
244
|
if (topic === 'room-drafts') {
|
|
195
|
-
return following(() =>
|
|
245
|
+
return following(() => unlockedWatch(topic, input, deliver, fail, (drafts, locked) => unlocked(draftsWithin(reach, drafts), locked)), true);
|
|
196
246
|
}
|
|
197
247
|
if (topic === 'queue') {
|
|
198
248
|
const room = input[0];
|
|
199
|
-
return following(() =>
|
|
200
|
-
if (!holds(reach, room) || runtime.locked(room)) {
|
|
201
|
-
deliver([]);
|
|
202
|
-
return () => { };
|
|
203
|
-
}
|
|
204
|
-
return watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)), fail);
|
|
205
|
-
}, true);
|
|
249
|
+
return following(() => lockedFirst(room, () => watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)), fail), () => deliver([])), true);
|
|
206
250
|
}
|
|
207
251
|
if (topic === 'query') {
|
|
208
|
-
const
|
|
252
|
+
const planning = runtime.plan(input[0], reach);
|
|
209
253
|
let held = null;
|
|
210
254
|
return following(() => {
|
|
211
|
-
const locked = unlocking(plan.rooms);
|
|
212
|
-
if (locked !== null) {
|
|
213
|
-
const answer = { result: locked, keys: [] };
|
|
214
|
-
if (held === null || changeOf(held, answer) !== null)
|
|
215
|
-
deliver(answer);
|
|
216
|
-
held = digestOf(answer);
|
|
217
|
-
return () => { };
|
|
218
|
-
}
|
|
219
|
-
let first = true;
|
|
220
255
|
let open = true;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
256
|
+
let stop = () => { };
|
|
257
|
+
void (async () => {
|
|
258
|
+
const plan = await planning;
|
|
259
|
+
const locked = await runtime.lockedRooms();
|
|
260
|
+
if (!open)
|
|
261
|
+
return;
|
|
262
|
+
const pending = unlocking(plan.rooms, locked);
|
|
263
|
+
if (pending !== null) {
|
|
264
|
+
const answer = { result: pending, keys: [] };
|
|
265
|
+
if (held === null || changeOf(held, answer) !== null)
|
|
266
|
+
deliver(answer);
|
|
267
|
+
held = digestOf(answer);
|
|
225
268
|
return;
|
|
226
269
|
}
|
|
227
|
-
first =
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
270
|
+
let first = true;
|
|
271
|
+
const heard = (message) => {
|
|
272
|
+
if (!first) {
|
|
273
|
+
held = digestApplied(held, message);
|
|
274
|
+
deliver(message);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
first = false;
|
|
278
|
+
const change = held === null ? message : changeOf(held, message);
|
|
279
|
+
held = digestOf(message);
|
|
280
|
+
if (change !== null)
|
|
281
|
+
deliver(change);
|
|
282
|
+
};
|
|
283
|
+
const current = { ...plan, reach: planReach(reach), locked };
|
|
284
|
+
stop = runtime.watchPlan(current, (message) => {
|
|
285
|
+
if (open)
|
|
286
|
+
heard(message);
|
|
287
|
+
}, (error) => {
|
|
288
|
+
if (open)
|
|
289
|
+
fail(error);
|
|
290
|
+
});
|
|
291
|
+
})().catch((error) => {
|
|
238
292
|
if (open)
|
|
239
293
|
fail(error);
|
|
240
294
|
});
|
|
@@ -260,6 +314,12 @@ export function narrowed(runtime, given, port) {
|
|
|
260
314
|
return () => { };
|
|
261
315
|
});
|
|
262
316
|
}
|
|
317
|
+
if (topic === 'figures' || topic === 'holdings') {
|
|
318
|
+
if (reach === null)
|
|
319
|
+
return watch(topic, input, deliver, fail);
|
|
320
|
+
fail(deviceUnreached());
|
|
321
|
+
return () => { };
|
|
322
|
+
}
|
|
263
323
|
return watch(topic, input, deliver, fail);
|
|
264
324
|
};
|
|
265
325
|
const files = new Map();
|
|
@@ -278,31 +338,33 @@ export function narrowed(runtime, given, port) {
|
|
|
278
338
|
const view = {
|
|
279
339
|
...md,
|
|
280
340
|
rooms: () => md.rooms().then((rooms) => roomsWithin(reach, rooms)),
|
|
281
|
-
query: ((input) => {
|
|
282
|
-
const plan = runtime.plan(input, reach);
|
|
283
|
-
|
|
341
|
+
query: (async (input) => {
|
|
342
|
+
const plan = await runtime.plan(input, reach);
|
|
343
|
+
const locked = await runtime.lockedRooms();
|
|
344
|
+
return unlocking(plan.rooms, locked) ?? runtime.query({ ...plan, locked });
|
|
284
345
|
}),
|
|
285
346
|
search: (input) => runtime.search(input, reach),
|
|
286
|
-
types(room) {
|
|
287
|
-
if (holds(reach, room) && runtime.locked(room))
|
|
347
|
+
async types(room) {
|
|
348
|
+
if (holds(reach, room) && (await runtime.locked(room)))
|
|
288
349
|
throw lockedError(room);
|
|
289
350
|
if (wholly(reach, room))
|
|
290
351
|
return md.types(room);
|
|
291
352
|
if (!holds(reach, room))
|
|
292
353
|
return structuredClone(UNHELD_TYPES);
|
|
293
|
-
return typesWithin(reach, runtime.room(room), md.types(room));
|
|
354
|
+
return typesWithin(reach, await runtime.room(room), await md.types(room));
|
|
294
355
|
},
|
|
295
356
|
async save(room, roomDrafts, writtenBy) {
|
|
296
357
|
if (!holds(reach, room))
|
|
297
358
|
throw unreached(room);
|
|
298
|
-
if (runtime.locked(room))
|
|
359
|
+
if (await runtime.locked(room)) {
|
|
299
360
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
361
|
+
}
|
|
300
362
|
const held = (await Promise.all(roomDrafts.map(({ path }) => md.roomDraft.read(room, path)))).map((draft) => draft?.parts.move);
|
|
301
363
|
const outside = roomDrafts.find(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]));
|
|
302
364
|
if (outside !== undefined) {
|
|
303
365
|
return { outcome: 'refused', code: 'stale', retryable: false, file: outside.path };
|
|
304
366
|
}
|
|
305
|
-
if (intoLocked(held))
|
|
367
|
+
if (await intoLocked(held))
|
|
306
368
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
307
369
|
return savedWithin(reach, room, await md.save(room, roomDrafts, writtenBy));
|
|
308
370
|
},
|
|
@@ -313,47 +375,48 @@ export function narrowed(runtime, given, port) {
|
|
|
313
375
|
if (filed !== undefined) {
|
|
314
376
|
return { outcome: 'refused', code: ATTACH_REQUIRED, retryable: false, file: filed.path };
|
|
315
377
|
}
|
|
316
|
-
if (runtime.locked(room))
|
|
378
|
+
if (await runtime.locked(room)) {
|
|
317
379
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
380
|
+
}
|
|
318
381
|
const held = parts.map(({ path, parts: one }) => readParts(one, path).move);
|
|
319
382
|
if (parts.some(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]))) {
|
|
320
383
|
throw unreached(room);
|
|
321
384
|
}
|
|
322
|
-
if (intoLocked(held))
|
|
385
|
+
if (await intoLocked(held))
|
|
323
386
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
324
387
|
return savedWithin(reach, room, await md.saveParts(room, parts, writtenBy));
|
|
325
388
|
},
|
|
326
|
-
resolve(room, path, destination) {
|
|
327
|
-
const at = runtime.located(room, path, destination);
|
|
389
|
+
async resolve(room, path, destination) {
|
|
390
|
+
const at = await runtime.located(room, path, destination);
|
|
328
391
|
return at !== null && !covers(reach, at.room, at.path)
|
|
329
|
-
?
|
|
392
|
+
? UNREADABLE
|
|
330
393
|
: md.resolve(room, path, destination);
|
|
331
394
|
},
|
|
332
|
-
history: (room, path, query) => !covers(reach, room, path)
|
|
333
|
-
?
|
|
334
|
-
: runtime.locked(room)
|
|
335
|
-
?
|
|
395
|
+
history: async (room, path, query) => !covers(reach, room, path)
|
|
396
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
397
|
+
: (await runtime.locked(room))
|
|
398
|
+
? lockedRoom(room)
|
|
336
399
|
: md.history(room, path, query),
|
|
337
400
|
binaryFile: {
|
|
338
|
-
read: (room, path, revision) => !covers(reach, room, path)
|
|
339
|
-
?
|
|
340
|
-
: runtime.locked(room)
|
|
341
|
-
?
|
|
401
|
+
read: async (room, path, revision) => !covers(reach, room, path)
|
|
402
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
403
|
+
: (await runtime.locked(room))
|
|
404
|
+
? lockedRoom(room)
|
|
342
405
|
: hand(md.binaryFile.read(room, path, revision)),
|
|
343
|
-
link: (room, path, revision) => !covers(reach, room, path)
|
|
344
|
-
?
|
|
345
|
-
: runtime.locked(room)
|
|
346
|
-
?
|
|
406
|
+
link: async (room, path, revision) => !covers(reach, room, path)
|
|
407
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
408
|
+
: (await runtime.locked(room))
|
|
409
|
+
? lockedRoom(room)
|
|
347
410
|
: md.binaryFile.link(room, path, revision),
|
|
348
|
-
show: (room, path, revision) => !covers(reach, room, path)
|
|
349
|
-
?
|
|
350
|
-
: runtime.locked(room)
|
|
351
|
-
?
|
|
411
|
+
show: async (room, path, revision) => !covers(reach, room, path)
|
|
412
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
413
|
+
: (await runtime.locked(room))
|
|
414
|
+
? lockedRoom(room)
|
|
352
415
|
: hand(md.binaryFile.show(room, path, revision)),
|
|
353
|
-
attach: (room, file) => !wholly(reach, room)
|
|
354
|
-
?
|
|
355
|
-
: runtime.locked(room)
|
|
356
|
-
?
|
|
416
|
+
attach: async (room, file) => !wholly(reach, room)
|
|
417
|
+
? failure({ kind: 'room-not-readable', locator: room })
|
|
418
|
+
: (await runtime.locked(room))
|
|
419
|
+
? lockedRoom(room)
|
|
357
420
|
: md.binaryFile.attach(room, file),
|
|
358
421
|
async part(file, part) {
|
|
359
422
|
const key = files.get(file);
|
|
@@ -366,42 +429,38 @@ export function narrowed(runtime, given, port) {
|
|
|
366
429
|
},
|
|
367
430
|
},
|
|
368
431
|
reached: async (room, roomVersion, path) => (path === undefined ? wholly(reach, room) : covers(reach, room, path)) &&
|
|
369
|
-
!runtime.locked(room) &&
|
|
432
|
+
!(await runtime.locked(room)) &&
|
|
370
433
|
(await md.reached(room, roomVersion, path)),
|
|
371
434
|
log: () => (reach === null ? md.log() : ''),
|
|
372
435
|
cleanUp: () => (reach === null ? md.cleanUp() : Promise.reject(deviceUnreached())),
|
|
436
|
+
unsent: () => (reach === null ? md.unsent() : Promise.reject(deviceUnreached())),
|
|
437
|
+
reset: () => (reach === null ? md.reset() : Promise.reject(deviceUnreached())),
|
|
438
|
+
readAgain: () => (reach === null ? md.readAgain() : Promise.reject(deviceUnreached())),
|
|
373
439
|
roomDraft: {
|
|
374
|
-
list: () => md.roomDraft.list()
|
|
440
|
+
list: async () => unlocked(draftsWithin(reach, await md.roomDraft.list()), await runtime.lockedRooms()),
|
|
375
441
|
async read(room, path) {
|
|
376
442
|
if (!covers(reach, room, path))
|
|
377
443
|
return null;
|
|
378
|
-
if (runtime.locked(room))
|
|
444
|
+
if (await runtime.locked(room))
|
|
379
445
|
throw lockedError(room);
|
|
380
446
|
return shownDraft(reach, await md.roomDraft.read(room, path));
|
|
381
447
|
},
|
|
382
|
-
write(room, path, revision, parts, next) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
catch (error) {
|
|
395
|
-
return Promise.reject(error);
|
|
396
|
-
}
|
|
397
|
-
return md.roomDraft
|
|
398
|
-
.write(room, path, revision, parts, next)
|
|
399
|
-
.then((written) => writeWithin(reach, written));
|
|
448
|
+
async write(room, path, revision, parts, next) {
|
|
449
|
+
if (reach !== null && carriesFile(parts))
|
|
450
|
+
throw attachRequired();
|
|
451
|
+
const move = readParts(parts, path).move;
|
|
452
|
+
if (!covers(reach, room, path) || !moves(reach, room, move))
|
|
453
|
+
throw unreached(room);
|
|
454
|
+
if (await runtime.locked(room))
|
|
455
|
+
throw lockedError(room);
|
|
456
|
+
if (await intoLocked([move]))
|
|
457
|
+
throw lockedError(move.room);
|
|
458
|
+
return writeWithin(reach, await md.roomDraft.write(room, path, revision, parts, next));
|
|
400
459
|
},
|
|
401
460
|
async discard(room, path, revision) {
|
|
402
461
|
if (!covers(reach, room, path))
|
|
403
462
|
return staleWrite(null);
|
|
404
|
-
if (runtime.locked(room))
|
|
463
|
+
if (await runtime.locked(room))
|
|
405
464
|
throw lockedError(room);
|
|
406
465
|
return writeWithin(reach, await md.roomDraft.discard(room, path, revision));
|
|
407
466
|
},
|
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { MdRuntimeClient } from './client.js';
|
|
3
|
-
import type { AppRoom
|
|
3
|
+
import type { AppRoom } from './listing.js';
|
|
4
|
+
import type { ConnectionRefusal } from './socket.js';
|
|
5
|
+
import type { SavedRoomDraft, SaveResult } from './saves.js';
|
|
4
6
|
import type { Member, ServiceMode } from './adapter.js';
|
|
5
7
|
import type { ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
6
8
|
import { type RuntimeError } from './failure.js';
|
|
9
|
+
import type { FiguresResult } from './figures.js';
|
|
10
|
+
import type { Holdings } from './holdings.js';
|
|
11
|
+
import type { Expecting } from './expectation.js';
|
|
7
12
|
import type { QueueEntry } from './outcome.js';
|
|
8
13
|
import type { DocumentResult, GroupResult, PendingResult } from './query.js';
|
|
9
14
|
import type { Readiness } from './readiness.js';
|
|
@@ -33,6 +38,11 @@ export declare function useObserve(client: Client, topic: 'presentation'): Obser
|
|
|
33
38
|
export declare function useObserve(client: Client, topic: 'conversation', conversation: string, options: ConversationOptions): Observed<ConversationView>;
|
|
34
39
|
export declare function useObserve(client: Client, topic: 'conversations'): Observed<readonly ConversationEntry[]>;
|
|
35
40
|
export declare function useObserve(client: Client, topic: 'agents'): Observed<readonly ConversationAgent[]>;
|
|
41
|
+
export declare function useObserve(client: Client, topic: 'figures'): Observed<FiguresResult>;
|
|
42
|
+
export declare function useObserve(client: Client, topic: 'holdings'): Observed<Holdings>;
|
|
43
|
+
export declare function useReading<E extends {
|
|
44
|
+
readonly key: string;
|
|
45
|
+
}>(store: Pick<Expecting<E>, 'reads' | 'heard' | 'left'>, asks: (one: E) => boolean, shown: ((one: E) => boolean) | null): void;
|
|
36
46
|
export type Saving = {
|
|
37
47
|
readonly busy: boolean;
|
|
38
48
|
readonly outcome: SaveResult | null;
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAA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ClF,wBAAgB,UAAU,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAC3D,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC,EACrD,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,EACzB,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,IAAI,GAClC,IAAI,CAON;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IACtC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACpF,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,cAAc,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACvF,CAAC;AAMF,wBAAgB,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CA8BvD"}
|
package/dist/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
|
|
2
2
|
import { failed } from './failure.js';
|
|
3
3
|
const LOADING = { state: 'loading' };
|
|
4
4
|
export function useObserve(client, topic, ...input) {
|
|
@@ -32,6 +32,15 @@ export function useObserve(client, topic, ...input) {
|
|
|
32
32
|
}, [client, key]);
|
|
33
33
|
return held !== null && held.client === client && held.key === key ? held.observed : LOADING;
|
|
34
34
|
}
|
|
35
|
+
export function useReading(store, asks, shown) {
|
|
36
|
+
const reader = useId();
|
|
37
|
+
useLayoutEffect(() => store.reads(reader, asks), [store, reader, asks]);
|
|
38
|
+
useLayoutEffect(() => () => store.left(reader), [store, reader]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (shown !== null)
|
|
41
|
+
store.heard(reader, shown);
|
|
42
|
+
}, [store, reader, shown]);
|
|
43
|
+
}
|
|
35
44
|
const IDLE = { busy: false, outcome: null, failure: null };
|
|
36
45
|
export function useSave(client) {
|
|
37
46
|
const [state, setState] = useState(IDLE);
|
package/dist/read.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type Fields = Readonly<Record<string, unknown>>;
|
|
2
|
+
export declare const EXCERPT = 512;
|
|
3
|
+
export declare function excerpt(said: string): string;
|
|
4
|
+
export declare function record(entry: unknown): Fields;
|
|
5
|
+
export declare function text(fields: Fields, name: string): string | null;
|
|
6
|
+
export declare function list(fields: Fields, name: string): readonly unknown[];
|
|
7
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEvD,eAAO,MAAM,OAAO,MAAM,CAAC;AAE3B,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI7C;AAED,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGhE;AAED,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,OAAO,EAAE,CAGrE"}
|
package/dist/read.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const EXCERPT = 512;
|
|
2
|
+
export function excerpt(said) {
|
|
3
|
+
return [...said.slice(0, EXCERPT * 2)].slice(0, EXCERPT).join('');
|
|
4
|
+
}
|
|
5
|
+
export function record(entry) {
|
|
6
|
+
return typeof entry === 'object' && entry !== null && !Array.isArray(entry)
|
|
7
|
+
? entry
|
|
8
|
+
: {};
|
|
9
|
+
}
|
|
10
|
+
export function text(fields, name) {
|
|
11
|
+
const value = fields[name];
|
|
12
|
+
return typeof value === 'string' && value !== '' ? value : null;
|
|
13
|
+
}
|
|
14
|
+
export function list(fields, name) {
|
|
15
|
+
const value = fields[name];
|
|
16
|
+
return Array.isArray(value) ? value : [];
|
|
17
|
+
}
|