@agentshouse/mdruntime 0.1.0-alpha.24 → 0.1.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +61 -4
- package/dist/change-set.d.ts +4 -11
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +8 -16
- package/dist/change-set.js.map +1 -1
- package/dist/client.d.ts +9 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -2
- package/dist/client.js.map +1 -1
- package/dist/collection.d.ts +0 -2
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +0 -5
- package/dist/collection.js.map +1 -1
- package/dist/connection.d.ts +9 -5
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +67 -67
- package/dist/connection.js.map +1 -1
- package/dist/conversation.d.ts +7 -4
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +29 -6
- package/dist/conversation.js.map +1 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +2 -0
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +8 -0
- package/dist/paths.js.map +1 -1
- package/dist/query.d.ts +206 -10
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +463 -14
- package/dist/query.js.map +1 -1
- package/dist/read-side.d.ts +13 -0
- package/dist/read-side.d.ts.map +1 -0
- package/dist/read-side.js +393 -0
- package/dist/read-side.js.map +1 -0
- package/dist/rows.d.ts +39 -0
- package/dist/rows.d.ts.map +1 -0
- package/dist/rows.js +85 -0
- package/dist/rows.js.map +1 -0
- package/dist/search.d.ts +61 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +155 -0
- package/dist/search.js.map +1 -0
- package/dist/wire.d.ts +2 -2
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -1
- package/dist/wire.js.map +1 -1
- package/package.json +3 -2
package/AGENTS.md
CHANGED
|
@@ -7,7 +7,7 @@ enforcement.
|
|
|
7
7
|
## The MD Runtime API
|
|
8
8
|
|
|
9
9
|
App code reaches the MD Runtime through the remote client. The surfaces are
|
|
10
|
-
Rooms, Slots, Query, Observe, Types, Room Draft, Save, History, Call, Log,
|
|
10
|
+
Rooms, Slots, Query, Search, Observe, Types, Room Draft, Save, History, Call, Log,
|
|
11
11
|
storage loss, the reported persistence answer, deployment facts, Sync Status, reauthorization,
|
|
12
12
|
conversation, the chat draft, and Presentation State.
|
|
13
13
|
|
|
@@ -22,7 +22,8 @@ queued.
|
|
|
22
22
|
Slots answers each Slot the Provider declares, in its order, with its entries
|
|
23
23
|
in order, each a Room and its segment; a Room two Slots list is the same Room.
|
|
24
24
|
|
|
25
|
-
Rooms, Slots, Query, Observe, Types, Room Draft, and Save never touch the
|
|
25
|
+
Rooms, Slots, Query, Search, Observe, Types, Room Draft, and Save never touch the
|
|
26
|
+
network.
|
|
26
27
|
History and Call go to the Provider through the Adapter. Every member of the
|
|
27
28
|
client is asynchronous. Results are detached snapshots. Nothing in this
|
|
28
29
|
surface returns the authorization, performs a request the App's code
|
|
@@ -36,6 +37,62 @@ owns their boundary.
|
|
|
36
37
|
The in-memory Adapter at `@agentshouse/mdruntime/memory` is for tests and
|
|
37
38
|
ships in no bundle.
|
|
38
39
|
|
|
40
|
+
## Local Query rules
|
|
41
|
+
|
|
42
|
+
`query(q)` answers once from local state; `observe('query', q, listener)` hears
|
|
43
|
+
the whole result at once and again only when it changes. A query is data:
|
|
44
|
+
|
|
45
|
+
- **Filter.** `rooms` names Room locators and defaults to every Room. `types`
|
|
46
|
+
names MD Types, and `any` names the untyped Documents. `pathPrefix` is a
|
|
47
|
+
directory: `notes` keeps `notes/a.md` and not `notes2/a.md`.
|
|
48
|
+
- **Fields.** `where` names frontmatter fields, ANDs them, and nests `$and` and
|
|
49
|
+
`$or`. A bare value is equality; the operators are `$eq`, `$ne`, `$in`, `$nin`,
|
|
50
|
+
`$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size` and `$exists`. Equality on a list
|
|
51
|
+
asks whether it contains the value. Missing, null and empty differ:
|
|
52
|
+
`$exists: false` keeps a missing field, `null` an explicit null, `''` empty
|
|
53
|
+
text and `$size: 0` an empty list. A date compares in calendar order and never
|
|
54
|
+
with a date-time. A reference compares by the Room Path it resolves to.
|
|
55
|
+
Untyped frontmatter is plain values. There is no text containment or regular
|
|
56
|
+
expression.
|
|
57
|
+
- **Relations.** `hop: { field, types, where, pathPrefix }` keeps Documents whose
|
|
58
|
+
reference `field` points to a matching Document of the same Room.
|
|
59
|
+
`backlinks: { field, types, where, pathPrefix }` keeps Documents that a
|
|
60
|
+
matching Document of the same Room references. Each keeps a Document once.
|
|
61
|
+
- **Parts.** A Document query must `select`: `'all'`, or `fields`, `sections`,
|
|
62
|
+
`preamble`, `markdown` and `backlinks`, where `fields` and `sections` are
|
|
63
|
+
`'all'` or a list of names. Room, Path and MD Type always return, and an
|
|
64
|
+
unselected part is absent. Select only what a screen shows: a list that selects
|
|
65
|
+
the Markdown hears every edit of it.
|
|
66
|
+
- **Order and groups.** `orderBy` sorts by `room`, `path`, `type` or `{ field }`
|
|
67
|
+
with TanStack DB's own options, and ties end with Room, then Path. `groupBy` by
|
|
68
|
+
`room`, `type` or `{ field }` answers `{ groups: [{ key, count }] }`, counted
|
|
69
|
+
over every match and ordered by `count` or a key. `limit` bounds the Documents
|
|
70
|
+
or the groups.
|
|
71
|
+
- **Results and errors.** A result carries no Room Version: read freshness from
|
|
72
|
+
Rooms and Sync Status. An invalid query fails with `invalid-query`,
|
|
73
|
+
`unknown-type`, `unknown-field` or `wrong-kind`, naming where, and never
|
|
74
|
+
answers an empty result in its place.
|
|
75
|
+
|
|
76
|
+
## Local Search rules
|
|
77
|
+
|
|
78
|
+
`search({ text, documents, conversations, limit })` answers once, by words, from
|
|
79
|
+
local state, with MiniSearch at its default configuration. There is no observed
|
|
80
|
+
search.
|
|
81
|
+
|
|
82
|
+
- **What is found.** A Document by its field values, its sections' headings and
|
|
83
|
+
text, its preamble and its Path; a message by its text. Frontmatter keys, Room
|
|
84
|
+
Drafts, chat drafts and growing text are never found. There are no phrases,
|
|
85
|
+
word forms, typo tolerance or prefix matching.
|
|
86
|
+
- **Narrowing.** `documents` is a Local Query filter: `rooms`, `types`, `where`,
|
|
87
|
+
`pathPrefix`, `hop` and `backlinks`. `conversations` names conversations. Both
|
|
88
|
+
apply before `limit`, which bounds each list; without it every hit returns.
|
|
89
|
+
- **Results.** `{ documents, messages }`, each ranked by `score`, which compares
|
|
90
|
+
hits of one list of one search. A Document hit names its `room`, `path` and
|
|
91
|
+
`type`, a message hit its `conversation` and `identity`, and `matches` maps each
|
|
92
|
+
matched word to the parts it matched in: `fields`, `sections`, `preamble` or
|
|
93
|
+
`path`, or `text`. A hit carries no position; mark the words in the text you
|
|
94
|
+
show. An invalid filter fails with its Local Query error.
|
|
95
|
+
|
|
39
96
|
## Room Draft, Save, and outcome rules
|
|
40
97
|
|
|
41
98
|
The MD Runtime owns one Room Draft per Room and Path, shared by every App and
|
|
@@ -94,8 +151,8 @@ a desktop. Its strings are English only, dates and numbers follow the
|
|
|
94
151
|
browser locale, and content is never translated. Light and dark themes come
|
|
95
152
|
from CSS custom properties with the browser's preference as the default and
|
|
96
153
|
an App's override respected. What an App Creator's agent adds carries none
|
|
97
|
-
of these promises by itself. Reading and
|
|
98
|
-
network. Data lives only in the App Creator's browser and with the Provider.
|
|
154
|
+
of these promises by itself. Reading, querying and searching never wait for
|
|
155
|
+
the network. Data lives only in the App Creator's browser and with the Provider.
|
|
99
156
|
|
|
100
157
|
## App code imports only the client entry and never constructs a Runtime
|
|
101
158
|
|
package/dist/change-set.d.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
export type VisibleDocument = {
|
|
4
|
-
content: string;
|
|
5
|
-
revision: string | null;
|
|
6
|
-
document: Document;
|
|
7
|
-
};
|
|
1
|
+
import { type Replica } from './replica.js';
|
|
2
|
+
import { type Row } from './rows.js';
|
|
8
3
|
export type DocumentChange = {
|
|
9
4
|
locator: string;
|
|
10
5
|
path: string;
|
|
11
|
-
before:
|
|
12
|
-
after:
|
|
6
|
+
before: readonly Row[];
|
|
7
|
+
after: readonly Row[];
|
|
13
8
|
};
|
|
14
9
|
export type MessageChange = {
|
|
15
10
|
conversation: string;
|
|
@@ -24,7 +19,6 @@ export type ChangeSet = {
|
|
|
24
19
|
rooms: readonly string[];
|
|
25
20
|
queues: readonly string[];
|
|
26
21
|
presentations: readonly string[];
|
|
27
|
-
query: boolean;
|
|
28
22
|
messages: readonly MessageChange[];
|
|
29
23
|
conversations: readonly string[];
|
|
30
24
|
};
|
|
@@ -33,7 +27,6 @@ export declare function changeSet(locator: string, before: Replica | null, after
|
|
|
33
27
|
room?: boolean;
|
|
34
28
|
queue?: boolean;
|
|
35
29
|
presentation?: string;
|
|
36
|
-
query?: boolean;
|
|
37
30
|
}): ChangeSet;
|
|
38
31
|
export declare function conversationChangeSet(messages: readonly MessageChange[], conversations: readonly string[]): ChangeSet;
|
|
39
32
|
export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
|
package/dist/change-set.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change-set.d.ts","sourceRoot":"","sources":["../src/change-set.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"change-set.d.ts","sourceRoot":"","sources":["../src/change-set.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAU,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,GAAG,EAAE,CAAC;IACvB,KAAK,EAAE,SAAS,GAAG,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,SAAS,cAAc,EAAE,CAAC;IACrC,MAAM,EAAE,SAAS;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC,CAAC;AAYF,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,GAAG,IAAI,EACtB,KAAK,EAAE,OAAO,GAAG,IAAI,EACrB,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CAClB,GACL,SAAS,CA4CX;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,aAAa,EAAE,SAAS,MAAM,EAAE,GAC/B,SAAS,CAUX;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAUrE"}
|
package/dist/change-set.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { beneath } from './paths.js';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { compositionOf } from './replica.js';
|
|
3
|
+
import { rowsOf } from './rows.js';
|
|
4
|
+
function rowsAt(locator, replica, path) {
|
|
4
5
|
const document = replica?.visible.collection.documents[path];
|
|
5
|
-
if (
|
|
6
|
-
return
|
|
7
|
-
content,
|
|
8
|
-
revision: replica?.visible.revisions[path] ?? null,
|
|
9
|
-
document
|
|
10
|
-
};
|
|
6
|
+
if (replica === null || document === undefined) return [];
|
|
7
|
+
return rowsOf(locator, path, document, compositionOf(replica.confirmed.record));
|
|
11
8
|
}
|
|
12
9
|
function modelShape(model) {
|
|
13
10
|
return model.status === 'unavailable' ? 'unavailable' : JSON.stringify(model.types);
|
|
@@ -23,17 +20,15 @@ export function changeSet(locator, before, after, changed = {}) {
|
|
|
23
20
|
const collectionChanged = oldRoom !== undefined && newRoom !== undefined && modelShape(oldRoom.model) !== modelShape(newRoom.model);
|
|
24
21
|
const selectionChanged = oldRoom !== undefined && newRoom !== undefined && modelShape(oldRoom.selectionModel) !== modelShape(newRoom.selectionModel);
|
|
25
22
|
for (const path of paths){
|
|
26
|
-
const prior = documentAt(before, path);
|
|
27
|
-
const next = documentAt(after, path);
|
|
28
23
|
const selected = newRoom?.typedSelection?.roots.some((root)=>beneath(root, path)) ?? false;
|
|
29
24
|
const inCollection = newRoom !== undefined && (newRoom.collectionRoot === '' || beneath(newRoom.collectionRoot, path));
|
|
30
25
|
const retyped = selected ? selectionChanged : inCollection && collectionChanged;
|
|
31
|
-
if (
|
|
26
|
+
if (before?.visible.documents[path] === after?.visible.documents[path] && before?.visible.revisions[path] === after?.visible.revisions[path] && !retyped) continue;
|
|
32
27
|
documents.push({
|
|
33
28
|
locator,
|
|
34
29
|
path,
|
|
35
|
-
before:
|
|
36
|
-
after:
|
|
30
|
+
before: rowsAt(locator, before, path),
|
|
31
|
+
after: rowsAt(locator, after, path)
|
|
37
32
|
});
|
|
38
33
|
}
|
|
39
34
|
return {
|
|
@@ -51,7 +46,6 @@ export function changeSet(locator, before, after, changed = {}) {
|
|
|
51
46
|
presentations: changed.presentation === undefined ? [] : [
|
|
52
47
|
changed.presentation
|
|
53
48
|
],
|
|
54
|
-
query: changed.query ?? false,
|
|
55
49
|
messages: [],
|
|
56
50
|
conversations: []
|
|
57
51
|
};
|
|
@@ -63,7 +57,6 @@ export function conversationChangeSet(messages, conversations) {
|
|
|
63
57
|
rooms: [],
|
|
64
58
|
queues: [],
|
|
65
59
|
presentations: [],
|
|
66
|
-
query: false,
|
|
67
60
|
messages,
|
|
68
61
|
conversations: [
|
|
69
62
|
...new Set(conversations)
|
|
@@ -83,7 +76,6 @@ export function mergeChangeSets(sets) {
|
|
|
83
76
|
presentations: [
|
|
84
77
|
...new Set(sets.flatMap((set)=>set.presentations))
|
|
85
78
|
],
|
|
86
|
-
query: sets.some((set)=>set.query),
|
|
87
79
|
messages: sets.flatMap((set)=>set.messages),
|
|
88
80
|
conversations: [
|
|
89
81
|
...new Set(sets.flatMap((set)=>set.conversations))
|
package/dist/change-set.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/change-set.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/change-set.ts"],"sourcesContent":["import { beneath } from './paths.js';\nimport { compositionOf, type Replica } from './replica.js';\nimport { rowsOf, type Row } from './rows.js';\n\nexport type DocumentChange = {\n locator: string;\n path: string;\n before: readonly Row[];\n after: readonly Row[];\n};\n\nexport type MessageChange = { conversation: string; identity: string };\n\nexport type ChangeSet = {\n documents: readonly DocumentChange[];\n drafts: readonly { locator: string; path: string }[];\n rooms: readonly string[];\n queues: readonly string[];\n presentations: readonly string[];\n messages: readonly MessageChange[];\n conversations: readonly string[];\n};\n\nfunction rowsAt(locator: string, replica: Replica | null, path: string): readonly Row[] {\n const document = replica?.visible.collection.documents[path];\n if (replica === null || document === undefined) return [];\n return rowsOf(locator, path, document, compositionOf(replica.confirmed.record));\n}\n\nfunction modelShape(model: Replica['confirmed']['record']['model']): string {\n return model.status === 'unavailable' ? 'unavailable' : JSON.stringify(model.types);\n}\n\nexport function changeSet(\n locator: string,\n before: Replica | null,\n after: Replica | null,\n changed: {\n drafts?: readonly string[];\n room?: boolean;\n queue?: boolean;\n presentation?: string;\n } = {},\n): ChangeSet {\n const paths = new Set([\n ...Object.keys(before?.visible.documents ?? {}),\n ...Object.keys(after?.visible.documents ?? {}),\n ]);\n const documents: DocumentChange[] = [];\n const oldRoom = before?.confirmed.record;\n const newRoom = after?.confirmed.record;\n const collectionChanged =\n oldRoom !== undefined &&\n newRoom !== undefined &&\n modelShape(oldRoom.model) !== modelShape(newRoom.model);\n const selectionChanged =\n oldRoom !== undefined &&\n newRoom !== undefined &&\n modelShape(oldRoom.selectionModel) !== modelShape(newRoom.selectionModel);\n for (const path of paths) {\n const selected = newRoom?.typedSelection?.roots.some((root) => beneath(root, path)) ?? false;\n const inCollection =\n newRoom !== undefined &&\n (newRoom.collectionRoot === '' || beneath(newRoom.collectionRoot, path));\n const retyped = selected ? selectionChanged : inCollection && collectionChanged;\n if (\n before?.visible.documents[path] === after?.visible.documents[path] &&\n before?.visible.revisions[path] === after?.visible.revisions[path] &&\n !retyped\n )\n continue;\n documents.push({\n locator,\n path,\n before: rowsAt(locator, before, path),\n after: rowsAt(locator, after, path),\n });\n }\n return {\n documents,\n drafts: (changed.drafts ?? []).map((path) => ({ locator, path })),\n rooms: changed.room ? [locator] : [],\n queues: changed.queue ? [locator] : [],\n presentations: changed.presentation === undefined ? [] : [changed.presentation],\n messages: [],\n conversations: [],\n };\n}\n\nexport function conversationChangeSet(\n messages: readonly MessageChange[],\n conversations: readonly string[],\n): ChangeSet {\n return {\n documents: [],\n drafts: [],\n rooms: [],\n queues: [],\n presentations: [],\n messages,\n conversations: [...new Set(conversations)],\n };\n}\n\nexport function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet {\n return {\n documents: sets.flatMap((set) => set.documents),\n drafts: sets.flatMap((set) => set.drafts),\n rooms: [...new Set(sets.flatMap((set) => set.rooms))],\n queues: [...new Set(sets.flatMap((set) => set.queues))],\n presentations: [...new Set(sets.flatMap((set) => set.presentations))],\n messages: sets.flatMap((set) => set.messages),\n conversations: [...new Set(sets.flatMap((set) => set.conversations))],\n };\n}\n"],"names":["beneath","compositionOf","rowsOf","rowsAt","locator","replica","path","document","visible","collection","documents","undefined","confirmed","record","modelShape","model","status","JSON","stringify","types","changeSet","before","after","changed","paths","Set","Object","keys","oldRoom","newRoom","collectionChanged","selectionChanged","selectionModel","selected","typedSelection","roots","some","root","inCollection","collectionRoot","retyped","revisions","push","drafts","map","rooms","room","queues","queue","presentations","presentation","messages","conversations","conversationChangeSet","mergeChangeSets","sets","flatMap","set"],"mappings":"AAAA,SAASA,OAAO,QAAQ,aAAa;AACrC,SAASC,aAAa,QAAsB,eAAe;AAC3D,SAASC,MAAM,QAAkB,YAAY;AAqB7C,SAASC,OAAOC,OAAe,EAAEC,OAAuB,EAAEC,IAAY;IACpE,MAAMC,WAAWF,SAASG,QAAQC,WAAWC,SAAS,CAACJ,KAAK;IAC5D,IAAID,YAAY,QAAQE,aAAaI,WAAW,OAAO,EAAE;IACzD,OAAOT,OAAOE,SAASE,MAAMC,UAAUN,cAAcI,QAAQO,SAAS,CAACC,MAAM;AAC/E;AAEA,SAASC,WAAWC,KAA8C;IAChE,OAAOA,MAAMC,MAAM,KAAK,gBAAgB,gBAAgBC,KAAKC,SAAS,CAACH,MAAMI,KAAK;AACpF;AAEA,OAAO,SAASC,UACdhB,OAAe,EACfiB,MAAsB,EACtBC,KAAqB,EACrBC,UAKI,CAAC,CAAC;IAEN,MAAMC,QAAQ,IAAIC,IAAI;WACjBC,OAAOC,IAAI,CAACN,QAAQb,QAAQE,aAAa,CAAC;WAC1CgB,OAAOC,IAAI,CAACL,OAAOd,QAAQE,aAAa,CAAC;KAC7C;IACD,MAAMA,YAA8B,EAAE;IACtC,MAAMkB,UAAUP,QAAQT,UAAUC;IAClC,MAAMgB,UAAUP,OAAOV,UAAUC;IACjC,MAAMiB,oBACJF,YAAYjB,aACZkB,YA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ACL1C,WAAW,EAAE;QACbiC,QAAQ,EAAE;QACVE,OAAO,EAAE;QACTE,QAAQ,EAAE;QACVE,eAAe,EAAE;QACjBE;QACAC,eAAe;eAAI,IAAI3B,IAAI2B;SAAe;IAC5C;AACF;AAEA,OAAO,SAASE,gBAAgBC,IAA0B;IACxD,OAAO;QACL7C,WAAW6C,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAI/C,SAAS;QAC9CiC,QAAQY,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAId,MAAM;QACxCE,OAAO;eAAI,IAAIpB,IAAI8B,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIZ,KAAK;SAAG;QACrDE,QAAQ;eAAI,IAAItB,IAAI8B,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIV,MAAM;SAAG;QACvDE,eAAe;eAAI,IAAIxB,IAAI8B,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIR,aAAa;SAAG;QACrEE,UAAUI,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIN,QAAQ;QAC5CC,eAAe;eAAI,IAAI3B,IAAI8B,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIL,aAAa;SAAG;IACvE;AACF"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import type { QueryOptions, QueryResult } from '@agentshouse/query';
|
|
2
1
|
import type { AppRoom, AppSlot, ConnectionRefusal, HistoryQuery, RoomTypes, SavedRoomDraft, SaveResult } from './connection.js';
|
|
3
2
|
import type { HistoryResult } from './adapter.js';
|
|
4
3
|
import type { ChatDraft, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
5
4
|
import type { CallResult, QueueEntry, SubmissionOutcome } from './outcome.js';
|
|
5
|
+
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult } from './query.js';
|
|
6
6
|
import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
|
|
7
|
+
import type { SearchRequest, SearchResult } from './search.js';
|
|
7
8
|
import type { SyncStatus } from './status.js';
|
|
8
9
|
import { type RuntimePort } from './wire.js';
|
|
9
10
|
export type MdRuntimeClient = {
|
|
10
11
|
rooms(): Promise<readonly AppRoom[]>;
|
|
11
12
|
slots(): Promise<readonly AppSlot[]>;
|
|
12
|
-
query
|
|
13
|
+
query: {
|
|
14
|
+
(query: DocumentQuery): Promise<DocumentResult>;
|
|
15
|
+
(query: GroupQuery): Promise<GroupResult>;
|
|
16
|
+
};
|
|
17
|
+
search(request: SearchRequest): Promise<SearchResult>;
|
|
13
18
|
types(locator: string): Promise<RoomTypes>;
|
|
14
19
|
syncStatus(): Promise<SyncStatus>;
|
|
15
20
|
roomDraft: {
|
|
@@ -51,7 +56,8 @@ export type MdRuntimeClient = {
|
|
|
51
56
|
(topic: 'connection-refusal', listener: (refusal: ConnectionRefusal | null) => void): Promise<() => void>;
|
|
52
57
|
(topic: 'storage-loss', listener: (statement: string | null) => void): Promise<() => void>;
|
|
53
58
|
(topic: 'sync-status', listener: (status: SyncStatus) => void): Promise<() => void>;
|
|
54
|
-
(topic: 'query', query:
|
|
59
|
+
(topic: 'query', query: DocumentQuery, listener: (result: DocumentResult) => void): Promise<() => void>;
|
|
60
|
+
(topic: 'query', query: GroupQuery, listener: (result: GroupResult) => void): Promise<() => void>;
|
|
55
61
|
(topic: 'queue', locator: string, listener: (entries: readonly QueueEntry[]) => void): Promise<() => void>;
|
|
56
62
|
(topic: 'room-drafts', listener: (roomDrafts: readonly RoomDraft[]) => void): Promise<() => void>;
|
|
57
63
|
(topic: 'presentation', listener: (value: unknown) => void): Promise<() => void>;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,E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AAI,EAAE,gBAAgB,KAAK,IAAI,GACzC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;KACxB,CAAC;IACF,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,CA6KnE;AAED,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/client.js
CHANGED
|
@@ -120,8 +120,11 @@ export function connectMdRuntime(port) {
|
|
|
120
120
|
return {
|
|
121
121
|
rooms: ()=>ask('rooms', []),
|
|
122
122
|
slots: ()=>ask('slots', []),
|
|
123
|
-
query: (
|
|
124
|
-
|
|
123
|
+
query: (query)=>ask('query', [
|
|
124
|
+
query
|
|
125
|
+
]),
|
|
126
|
+
search: (request)=>ask('search', [
|
|
127
|
+
request
|
|
125
128
|
]),
|
|
126
129
|
types: (locator)=>ask('types', [
|
|
127
130
|
locator
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/client.ts"],"sourcesContent":["import type { QueryOptions, QueryResult } from '@agentshouse/query';\nimport type {\n AppRoom,\n AppSlot,\n ConnectionRefusal,\n HistoryQuery,\n RoomTypes,\n SavedRoomDraft,\n SaveResult,\n} from './connection.js';\nimport type { HistoryResult } from './adapter.js';\nimport type {\n ChatDraft,\n ConversationEntry,\n ConversationOptions,\n ConversationView,\n} from './conversation.js';\nimport type { CallResult, QueueEntry, SubmissionOutcome } from './outcome.js';\nimport type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';\nimport type { SyncStatus } from './status.js';\nimport {\n answer,\n AUTHORIZATION_ENDED,\n carried,\n envelope,\n PROTOCOL_MISMATCH,\n type RuntimePort,\n type WireMember,\n type WireRequest,\n type WireTopic,\n} from './wire.js';\n\nexport type MdRuntimeClient = {\n rooms(): Promise<readonly AppRoom[]>;\n slots(): Promise<readonly AppSlot[]>;\n query(options?: QueryOptions): Promise<QueryResult>;\n types(locator: string): Promise<RoomTypes>;\n syncStatus(): Promise<SyncStatus>;\n roomDraft: {\n list(): Promise<readonly RoomDraft[]>;\n read(room: string, path: string): Promise<RoomDraft | null>;\n write(\n room: string,\n path: string,\n revision: string | null,\n parts: RoomDraftParts,\n ): Promise<RoomDraftWrite>;\n discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;\n };\n save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;\n outcome(identifier: string): Promise<SubmissionOutcome | null>;\n presentation: {\n read(): Promise<unknown>;\n write(value: unknown): Promise<void>;\n };\n conversation: {\n list(): Promise<readonly ConversationEntry[]>;\n read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;\n create(input: unknown): Promise<CallResult>;\n send(conversation: string): Promise<CallResult>;\n answer(conversation: string, answer: unknown): Promise<CallResult>;\n interrupt(conversation: string): Promise<CallResult>;\n kill(conversation: string): Promise<CallResult>;\n cancel(conversation: string, turn: string): Promise<CallResult>;\n delete(conversation: string): Promise<CallResult>;\n };\n chatDraft: {\n write(conversation: string, draft: ChatDraft): Promise<void>;\n discard(conversation: string): Promise<void>;\n };\n history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryResult>;\n call(name: string, input: unknown): Promise<CallResult>;\n log(): Promise<string>;\n storageLoss(): Promise<string | null>;\n persistence(): Promise<boolean>;\n deploymentFacts(): Promise<unknown>;\n observe: {\n (topic: 'deployment-facts', listener: (value: unknown) => void): Promise<() => void>;\n (topic: 'rooms', listener: (rooms: readonly AppRoom[]) => void): Promise<() => void>;\n (\n topic: 'connection-refusal',\n listener: (refusal: ConnectionRefusal | null) => void,\n ): Promise<() => void>;\n (topic: 'storage-loss', listener: (statement: string | null) => void): Promise<() => void>;\n (topic: 'sync-status', listener: (status: SyncStatus) => void): Promise<() => void>;\n (\n topic: 'query',\n query: QueryOptions,\n listener: (result: QueryResult) => void,\n ): Promise<() => void>;\n (\n topic: 'queue',\n locator: string,\n listener: (entries: readonly QueueEntry[]) => void,\n ): Promise<() => void>;\n (\n topic: 'room-drafts',\n listener: (roomDrafts: readonly RoomDraft[]) => void,\n ): Promise<() => void>;\n (topic: 'presentation', listener: (value: unknown) => void): Promise<() => void>;\n (\n topic: 'conversation',\n conversation: string,\n options: ConversationOptions,\n listener: (view: ConversationView) => void,\n ): Promise<() => void>;\n };\n reauthorize(): Promise<void>;\n};\n\nexport function connectMdRuntime(port: RuntimePort): MdRuntimeClient {\n let sequence = 0;\n let refusal: ConnectionRefusal | null = null;\n let ended = false;\n const calls = new Map<\n number,\n { settle: (value: unknown) => void; fail: (error: Error) => void }\n >();\n const acks = new Map<number, { settle: () => void; fail: (error: Error) => void }>();\n const listeners = new Map<number, { topic: WireTopic; notify: (value: unknown) => void }>();\n\n const send = (message: WireRequest) => {\n port.postMessage(envelope(message));\n };\n\n function refuse(reported: ConnectionRefusal) {\n refusal = reported;\n for (const waiting of acks.values()) waiting.settle();\n acks.clear();\n const failure = new Error(reported.reason);\n for (const waiting of calls.values()) waiting.fail(failure);\n calls.clear();\n for (const listener of listeners.values()) {\n if (listener.topic === 'connection-refusal') listener.notify(reported);\n }\n }\n\n function end() {\n ended = true;\n const failure = new Error(AUTHORIZATION_ENDED);\n for (const waiting of acks.values()) waiting.fail(failure);\n acks.clear();\n for (const waiting of calls.values()) waiting.fail(failure);\n calls.clear();\n listeners.clear();\n }\n\n port.addEventListener('message', (event) => {\n const wire = carried(event.data);\n if (wire === null) return;\n if (!wire.matching) {\n refuse(PROTOCOL_MISMATCH);\n return;\n }\n const message = answer(wire.message);\n if (message === null) return;\n if (message.kind === 'refusal') {\n refuse(message.refusal);\n return;\n }\n if (message.kind === 'ended') {\n end();\n return;\n }\n if (message.kind === 'event') {\n listeners.get(message.id)?.notify(message.value);\n return;\n }\n const subscribing = acks.get(message.id);\n if (subscribing !== undefined) {\n acks.delete(message.id);\n if (message.kind === 'failure') {\n listeners.delete(message.id);\n subscribing.fail(new Error(message.message));\n } else subscribing.settle();\n return;\n }\n const waiting = calls.get(message.id);\n if (waiting === undefined) return;\n calls.delete(message.id);\n if (message.kind === 'failure') waiting.fail(new Error(message.message));\n else waiting.settle(message.value);\n });\n port.start();\n send({ kind: 'hello' });\n\n function ask<T>(member: WireMember, input: readonly unknown[]): Promise<T> {\n if (ended) return Promise.reject(new Error(AUTHORIZATION_ENDED));\n if (refusal !== null) return Promise.reject(new Error(refusal.reason));\n const id = (sequence += 1);\n return new Promise<T>((settle, fail) => {\n calls.set(id, { settle: settle as (value: unknown) => void, fail });\n send({ kind: 'call', id, member, input });\n });\n }\n\n function watch(\n topic: WireTopic,\n input: readonly unknown[],\n notify: (value: unknown) => void,\n ): Promise<() => void> {\n if (ended) return Promise.reject(new Error(AUTHORIZATION_ENDED));\n const id = (sequence += 1);\n listeners.set(id, { topic, notify });\n const end = () => {\n if (!listeners.delete(id)) return;\n if (refusal === null) send({ kind: 'stop', id });\n };\n if (refusal !== null) {\n if (topic === 'connection-refusal') notify(refusal);\n return Promise.resolve(end);\n }\n return new Promise<() => void>((settle, fail) => {\n acks.set(id, { settle: () => settle(end), fail });\n send({ kind: 'observe', id, topic, input });\n });\n }\n\n return {\n rooms: () => ask<readonly AppRoom[]>('rooms', []),\n slots: () => ask<readonly AppSlot[]>('slots', []),\n query: (options?: QueryOptions) => ask<QueryResult>('query', [options]),\n types: (locator: string) => ask<RoomTypes>('types', [locator]),\n syncStatus: () => ask<SyncStatus>('syncStatus', []),\n roomDraft: {\n list: () => ask<readonly RoomDraft[]>('roomDraft.list', []),\n read: (room: string, path: string) => ask<RoomDraft | null>('roomDraft.read', [room, path]),\n write: (room: string, path: string, revision: string | null, parts: RoomDraftParts) =>\n ask<RoomDraftWrite>('roomDraft.write', [room, path, revision, parts]),\n discard: (room: string, path: string, revision: string) =>\n ask<RoomDraftWrite>('roomDraft.discard', [room, path, revision]),\n },\n save: (room: string, roomDrafts: readonly SavedRoomDraft[]) =>\n ask<SaveResult>('save', [room, roomDrafts]),\n outcome: (identifier: string) => ask<SubmissionOutcome | null>('outcome', [identifier]),\n presentation: {\n read: () => ask<unknown>('presentation.read', []),\n write: (value: unknown) => ask<void>('presentation.write', [value]),\n },\n conversation: {\n list: () => ask<readonly ConversationEntry[]>('conversation.list', []),\n read: (conversation: string, options?: ConversationOptions) =>\n ask<ConversationView>('conversation.read', [conversation, options]),\n create: (input: unknown) => ask<CallResult>('conversation.create', [input]),\n send: (conversation: string) => ask<CallResult>('conversation.send', [conversation]),\n answer: (conversation: string, answer: unknown) =>\n ask<CallResult>('conversation.answer', [conversation, answer]),\n interrupt: (conversation: string) =>\n ask<CallResult>('conversation.interrupt', [conversation]),\n kill: (conversation: string) => ask<CallResult>('conversation.kill', [conversation]),\n cancel: (conversation: string, turn: string) =>\n ask<CallResult>('conversation.cancel', [conversation, turn]),\n delete: (conversation: string) => ask<CallResult>('conversation.delete', [conversation]),\n },\n chatDraft: {\n write: (conversation: string, draft: ChatDraft) =>\n ask<void>('chatDraft.write', [conversation, draft]),\n discard: (conversation: string) => ask<void>('chatDraft.discard', [conversation]),\n },\n history: (locator: string, path: string, query?: HistoryQuery) =>\n ask<HistoryResult>('history', [locator, path, query]),\n call: (name: string, input: unknown) => ask<CallResult>('call', [name, input]),\n log: () => ask<string>('log', []),\n storageLoss: () => ask<string | null>('storageLoss', []),\n persistence: () => ask<boolean>('persistence', []),\n deploymentFacts: () => ask<unknown>('deploymentFacts', []),\n observe(\n topic: WireTopic,\n second: QueryOptions | string | ((value: never) => void),\n third?: ConversationOptions | ((value: never) => void),\n fourth?: (value: never) => void,\n ) {\n if (topic === 'conversation') {\n return watch(topic, [second, third], fourth as (value: unknown) => void);\n }\n const positional = topic === 'query' || topic === 'queue';\n const notify = (positional ? third : second) as (value: unknown) => void;\n return watch(topic, positional ? [second] : [], notify);\n },\n reauthorize: () => ask<void>('reauthorize', []),\n };\n}\n\nexport type { RuntimePort } from './wire.js';\n"],"names":["answer","AUTHORIZATION_ENDED","carried","envelope","PROTOCOL_MISMATCH","connectMdRuntime","port","sequence","refusal","ended","calls","Map","acks","listeners","send","message","postMessage","refuse","reported","waiting","values","settle","clear","failure","Error","reason","fail","listener","topic","notify","end","addEventListener","event","wire","data","matching","kind","get","id","value","subscribing","undefined","delete","start","ask","member","input","Promise","reject","set","watch","resolve","rooms","slots","query","options","types","locator","syncStatus","roomDraft","list","read","room","path","write","revision","parts","discard","save","roomDrafts","outcome","identifier","presentation","conversation","create","interrupt","kill","cancel","turn","chatDraft","draft","history","call","name","log","storageLoss","persistence","deploymentFacts","observe","second","third","fourth","positional","reauthorize"],"mappings":"AAoBA,SACEA,MAAM,EACNC,mBAAmB,EACnBC,OAAO,EACPC,QAAQ,EACRC,iBAAiB,QAKZ,YAAY;AAgFnB,OAAO,SAASC,iBAAiBC,IAAiB;IAChD,IAAIC,WAAW;IACf,IAAIC,UAAoC;IACxC,IAAIC,QAAQ;IACZ,MAAMC,QAAQ,IAAIC;IAIlB,MAAMC,OAAO,IAAID;IACjB,MAAME,YAAY,IAAIF;IAEtB,MAAMG,OAAO,CAACC;QACZT,KAAKU,WAAW,CAACb,SAASY;IAC5B;IAEA,SAASE,OAAOC,QAA2B;QACzCV,UAAUU;QACV,KAAK,MAAMC,WAAWP,KAAKQ,MAAM,GAAID,QAAQE,MAAM;QACnDT,KAAKU,KAAK;QACV,MAAMC,UAAU,IAAIC,MAAMN,SAASO,MAAM;QACzC,KAAK,MAAMN,WAAWT,MAAMU,MAAM,GAAID,QAAQO,IAAI,CAACH;QACnDb,MAAMY,KAAK;QACX,KAAK,MAAMK,YAAYd,UAAUO,MAAM,GAAI;YACzC,IAAIO,SAASC,KAAK,KAAK,sBAAsBD,SAASE,MAAM,CAACX;QAC/D;IACF;IAEA,SAASY;QACPrB,QAAQ;QACR,MAAMc,UAAU,IAAIC,MAAMvB;QAC1B,KAAK,MAAMkB,WAAWP,KAAKQ,MAAM,GAAID,QAAQO,IAAI,CAACH;QAClDX,KAAKU,KAAK;QACV,KAAK,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AAC+B,eAAyB7B,IAAgB,uBAAuB;oBAAC6B;iBAAa;QACzF;QACAM,WAAW;YACTf,OAAO,CAACS,cAAsBO,QAC5BpC,IAAU,mBAAmB;oBAAC6B;oBAAcO;iBAAM;YACpDb,SAAS,CAACM,eAAyB7B,IAAU,qBAAqB;oBAAC6B;iBAAa;QAClF;QACAQ,SAAS,CAACxB,SAAiBM,MAAcT,QACvCV,IAAmB,WAAW;gBAACa;gBAASM;gBAAMT;aAAM;QACtD4B,MAAM,CAACC,MAAcrC,QAAmBF,IAAgB,QAAQ;gBAACuC;gBAAMrC;aAAM;QAC7EsC,KAAK,IAAMxC,IAAY,OAAO,EAAE;QAChCyC,aAAa,IAAMzC,IAAmB,eAAe,EAAE;QACvD0C,aAAa,IAAM1C,IAAa,eAAe,EAAE;QACjD2C,iBAAiB,IAAM3C,IAAa,mBAAmB,EAAE;QACzD4C,SACE5D,KAAgB,EAChB6D,MAAwD,EACxDC,KAAsD,EACtDC,MAA+B;YAE/B,IAAI/D,UAAU,gBAAgB;gBAC5B,OAAOsB,MAAMtB,OAAO;oBAAC6D;oBAAQC;iBAAM,EAAEC;YACvC;YACA,MAAMC,aAAahE,UAAU,WAAWA,UAAU;YAClD,MAAMC,SAAU+D,aAAaF,QAAQD;YACrC,OAAOvC,MAAMtB,OAAOgE,aAAa;gBAACH;aAAO,GAAG,EAAE,EAAE5D;QAClD;QACAgE,aAAa,IAAMjD,IAAU,eAAe,EAAE;IAChD;AACF"}
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/client.ts"],"sourcesContent":["import type {\n AppRoom,\n AppSlot,\n ConnectionRefusal,\n HistoryQuery,\n RoomTypes,\n SavedRoomDraft,\n SaveResult,\n} from './connection.js';\nimport type { HistoryResult } from './adapter.js';\nimport type {\n ChatDraft,\n ConversationEntry,\n ConversationOptions,\n ConversationView,\n} from './conversation.js';\nimport type { CallResult, QueueEntry, SubmissionOutcome } from './outcome.js';\nimport type { DocumentQuery, DocumentResult, GroupQuery, GroupResult } from './query.js';\nimport type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';\nimport type { SearchRequest, SearchResult } from './search.js';\nimport type { SyncStatus } from './status.js';\nimport {\n answer,\n AUTHORIZATION_ENDED,\n carried,\n envelope,\n PROTOCOL_MISMATCH,\n type RuntimePort,\n type WireMember,\n type WireRequest,\n type WireTopic,\n} from './wire.js';\n\nexport type MdRuntimeClient = {\n rooms(): Promise<readonly AppRoom[]>;\n slots(): Promise<readonly AppSlot[]>;\n query: {\n (query: DocumentQuery): Promise<DocumentResult>;\n (query: GroupQuery): Promise<GroupResult>;\n };\n search(request: SearchRequest): Promise<SearchResult>;\n types(locator: string): Promise<RoomTypes>;\n syncStatus(): Promise<SyncStatus>;\n roomDraft: {\n list(): Promise<readonly RoomDraft[]>;\n read(room: string, path: string): Promise<RoomDraft | null>;\n write(\n room: string,\n path: string,\n revision: string | null,\n parts: RoomDraftParts,\n ): Promise<RoomDraftWrite>;\n discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;\n };\n save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;\n outcome(identifier: string): Promise<SubmissionOutcome | null>;\n presentation: {\n read(): Promise<unknown>;\n write(value: unknown): Promise<void>;\n };\n conversation: {\n list(): Promise<readonly ConversationEntry[]>;\n read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;\n create(input: unknown): Promise<CallResult>;\n send(conversation: string): Promise<CallResult>;\n answer(conversation: string, answer: unknown): Promise<CallResult>;\n interrupt(conversation: string): Promise<CallResult>;\n kill(conversation: string): Promise<CallResult>;\n cancel(conversation: string, turn: string): Promise<CallResult>;\n delete(conversation: string): Promise<CallResult>;\n };\n chatDraft: {\n write(conversation: string, draft: ChatDraft): Promise<void>;\n discard(conversation: string): Promise<void>;\n };\n history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryResult>;\n call(name: string, input: unknown): Promise<CallResult>;\n log(): Promise<string>;\n storageLoss(): Promise<string | null>;\n persistence(): Promise<boolean>;\n deploymentFacts(): Promise<unknown>;\n observe: {\n (topic: 'deployment-facts', listener: (value: unknown) => void): Promise<() => void>;\n (topic: 'rooms', listener: (rooms: readonly AppRoom[]) => void): Promise<() => void>;\n (\n topic: 'connection-refusal',\n listener: (refusal: ConnectionRefusal | null) => void,\n ): Promise<() => void>;\n (topic: 'storage-loss', listener: (statement: string | null) => void): Promise<() => void>;\n (topic: 'sync-status', listener: (status: SyncStatus) => void): Promise<() => void>;\n (\n topic: 'query',\n query: DocumentQuery,\n listener: (result: DocumentResult) => void,\n ): Promise<() => void>;\n (\n topic: 'query',\n query: GroupQuery,\n listener: (result: GroupResult) => void,\n ): Promise<() => void>;\n (\n topic: 'queue',\n locator: string,\n listener: (entries: readonly QueueEntry[]) => void,\n ): Promise<() => void>;\n (\n topic: 'room-drafts',\n listener: (roomDrafts: readonly RoomDraft[]) => void,\n ): Promise<() => void>;\n (topic: 'presentation', listener: (value: unknown) => void): Promise<() => void>;\n (\n topic: 'conversation',\n conversation: string,\n options: ConversationOptions,\n listener: (view: ConversationView) => void,\n ): Promise<() => void>;\n };\n reauthorize(): Promise<void>;\n};\n\nexport function connectMdRuntime(port: RuntimePort): MdRuntimeClient {\n let sequence = 0;\n let refusal: ConnectionRefusal | null = null;\n let ended = false;\n const calls = new Map<\n number,\n { settle: (value: unknown) => void; fail: (error: Error) => void }\n >();\n const acks = new Map<number, { settle: () => void; fail: (error: Error) => void }>();\n const listeners = new Map<number, { topic: WireTopic; notify: (value: unknown) => void }>();\n\n const send = (message: WireRequest) => {\n port.postMessage(envelope(message));\n };\n\n function refuse(reported: ConnectionRefusal) {\n refusal = reported;\n for (const waiting of acks.values()) waiting.settle();\n acks.clear();\n const failure = new Error(reported.reason);\n for (const waiting of calls.values()) waiting.fail(failure);\n calls.clear();\n for (const listener of listeners.values()) {\n if (listener.topic === 'connection-refusal') listener.notify(reported);\n }\n }\n\n function end() {\n ended = true;\n const failure = new Error(AUTHORIZATION_ENDED);\n for (const waiting of acks.values()) waiting.fail(failure);\n acks.clear();\n for (const waiting of calls.values()) waiting.fail(failure);\n calls.clear();\n listeners.clear();\n }\n\n port.addEventListener('message', (event) => {\n const wire = carried(event.data);\n if (wire === null) return;\n if (!wire.matching) {\n refuse(PROTOCOL_MISMATCH);\n return;\n }\n const message = answer(wire.message);\n if (message === null) return;\n if (message.kind === 'refusal') {\n refuse(message.refusal);\n return;\n }\n if (message.kind === 'ended') {\n end();\n return;\n }\n if (message.kind === 'event') {\n listeners.get(message.id)?.notify(message.value);\n return;\n }\n const subscribing = acks.get(message.id);\n if (subscribing !== undefined) {\n acks.delete(message.id);\n if (message.kind === 'failure') {\n listeners.delete(message.id);\n subscribing.fail(new Error(message.message));\n } else subscribing.settle();\n return;\n }\n const waiting = calls.get(message.id);\n if (waiting === undefined) return;\n calls.delete(message.id);\n if (message.kind === 'failure') waiting.fail(new Error(message.message));\n else waiting.settle(message.value);\n });\n port.start();\n send({ kind: 'hello' });\n\n function ask<T>(member: WireMember, input: readonly unknown[]): Promise<T> {\n if (ended) return Promise.reject(new Error(AUTHORIZATION_ENDED));\n if (refusal !== null) return Promise.reject(new Error(refusal.reason));\n const id = (sequence += 1);\n return new Promise<T>((settle, fail) => {\n calls.set(id, { settle: settle as (value: unknown) => void, fail });\n send({ kind: 'call', id, member, input });\n });\n }\n\n function watch(\n topic: WireTopic,\n input: readonly unknown[],\n notify: (value: unknown) => void,\n ): Promise<() => void> {\n if (ended) return Promise.reject(new Error(AUTHORIZATION_ENDED));\n const id = (sequence += 1);\n listeners.set(id, { topic, notify });\n const end = () => {\n if (!listeners.delete(id)) return;\n if (refusal === null) send({ kind: 'stop', id });\n };\n if (refusal !== null) {\n if (topic === 'connection-refusal') notify(refusal);\n return Promise.resolve(end);\n }\n return new Promise<() => void>((settle, fail) => {\n acks.set(id, { settle: () => settle(end), fail });\n send({ kind: 'observe', id, topic, input });\n });\n }\n\n return {\n rooms: () => ask<readonly AppRoom[]>('rooms', []),\n slots: () => ask<readonly AppSlot[]>('slots', []),\n query: ((query: DocumentQuery | GroupQuery) =>\n ask('query', [query])) as MdRuntimeClient['query'],\n search: (request: SearchRequest) => ask<SearchResult>('search', [request]),\n types: (locator: string) => ask<RoomTypes>('types', [locator]),\n syncStatus: () => ask<SyncStatus>('syncStatus', []),\n roomDraft: {\n list: () => ask<readonly RoomDraft[]>('roomDraft.list', []),\n read: (room: string, path: string) => ask<RoomDraft | null>('roomDraft.read', [room, path]),\n write: (room: string, path: string, revision: string | null, parts: RoomDraftParts) =>\n ask<RoomDraftWrite>('roomDraft.write', [room, path, revision, parts]),\n discard: (room: string, path: string, revision: string) =>\n ask<RoomDraftWrite>('roomDraft.discard', [room, path, revision]),\n },\n save: (room: string, roomDrafts: readonly SavedRoomDraft[]) =>\n ask<SaveResult>('save', [room, roomDrafts]),\n outcome: (identifier: string) => ask<SubmissionOutcome | null>('outcome', [identifier]),\n presentation: {\n read: () => ask<unknown>('presentation.read', []),\n write: (value: unknown) => ask<void>('presentation.write', [value]),\n },\n conversation: {\n list: () => ask<readonly ConversationEntry[]>('conversation.list', []),\n read: (conversation: string, options?: ConversationOptions) =>\n ask<ConversationView>('conversation.read', [conversation, options]),\n create: (input: unknown) => ask<CallResult>('conversation.create', [input]),\n send: (conversation: string) => ask<CallResult>('conversation.send', [conversation]),\n answer: (conversation: string, answer: unknown) =>\n ask<CallResult>('conversation.answer', [conversation, answer]),\n interrupt: (conversation: string) =>\n ask<CallResult>('conversation.interrupt', [conversation]),\n kill: (conversation: string) => ask<CallResult>('conversation.kill', [conversation]),\n cancel: (conversation: string, turn: string) =>\n ask<CallResult>('conversation.cancel', [conversation, turn]),\n delete: (conversation: string) => ask<CallResult>('conversation.delete', [conversation]),\n },\n chatDraft: {\n write: (conversation: string, draft: ChatDraft) =>\n ask<void>('chatDraft.write', [conversation, draft]),\n discard: (conversation: string) => ask<void>('chatDraft.discard', [conversation]),\n },\n history: (locator: string, path: string, query?: HistoryQuery) =>\n ask<HistoryResult>('history', [locator, path, query]),\n call: (name: string, input: unknown) => ask<CallResult>('call', [name, input]),\n log: () => ask<string>('log', []),\n storageLoss: () => ask<string | null>('storageLoss', []),\n persistence: () => ask<boolean>('persistence', []),\n deploymentFacts: () => ask<unknown>('deploymentFacts', []),\n observe(\n topic: WireTopic,\n second: unknown,\n third?: ConversationOptions | ((value: never) => void),\n fourth?: (value: never) => void,\n ) {\n if (topic === 'conversation') {\n return watch(topic, [second, third], fourth as (value: unknown) => void);\n }\n const positional = topic === 'query' || topic === 'queue';\n const notify = (positional ? third : second) as (value: unknown) => void;\n return watch(topic, positional ? [second] : [], notify);\n },\n reauthorize: () => ask<void>('reauthorize', []),\n };\n}\n\nexport type { RuntimePort } from './wire.js';\n"],"names":["answer","AUTHORIZATION_ENDED","carried","envelope","PROTOCOL_MISMATCH","connectMdRuntime","port","sequence","refusal","ended","calls","Map","acks","listeners","send","message","postMessage","refuse","reported","waiting","values","settle","clear","failure","Error","reason","fail","listener","topic","notify","end","addEventListener","event","wire","data","matching","kind","get","id","value","subscribing","undefined","delete","start","ask","member","input","Promise","reject","set","watch","resolve","rooms","slots","query","search","request","types","locator","syncStatus","roomDraft","list","read","room","path","write","revision","parts","discard","save","roomDrafts","outcome","identifier","presentation","conversation","options","create","interrupt","kill","cancel","turn","chatDraft","draft","history","call","name","log","storageLoss","persistence","deploymentFacts","observe","second","third","fourth","positional","reauthorize"],"mappings":"AAqBA,SACEA,MAAM,EACNC,mBAAmB,EACnBC,OAAO,EACPC,QAAQ,EACRC,iBAAiB,QAKZ,YAAY;AAyFnB,OAAO,SAASC,iBAAiBC,IAAiB;IAChD,IAAIC,WAAW;IACf,IAAIC,UAAoC;IACxC,IAAIC,QAAQ;IACZ,MAAMC,QAAQ,IAAIC;IAIlB,MAAMC,OAAO,IAAID;IACjB,MAAME,YAAY,IAAIF;IAEtB,MAAMG,OAAO,CAACC;QACZT,KAAKU,WAAW,CAACb,SAASY;IAC5B;IAEA,SAASE,OAAOC,QAA2B;QACzC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AAQC;iBAAM,EAAEC;YACvC;YACA,MAAMC,aAAalE,UAAU,WAAWA,UAAU;YAClD,MAAMC,SAAUiE,aAAaF,QAAQD;YACrC,OAAOzC,MAAMtB,OAAOkE,aAAa;gBAACH;aAAO,GAAG,EAAE,EAAE9D;QAClD;QACAkE,aAAa,IAAMnD,IAAU,eAAe,EAAE;IAChD;AACF"}
|
package/dist/collection.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { type Document, type Validation } from '@agentshouse/mdmodel';
|
|
2
|
-
import type { Selector } from '@agentshouse/query';
|
|
3
2
|
import type { ModelState } from './model.js';
|
|
4
3
|
import type { MdModelIdentity } from './adapter.js';
|
|
5
4
|
export declare const MD_MODEL: MdModelIdentity;
|
|
6
|
-
export declare const PRESENTED: Selector;
|
|
7
5
|
export type Collection = {
|
|
8
6
|
documents: Readonly<Record<string, Document>>;
|
|
9
7
|
composition: Composition;
|
package/dist/collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,UAAU,EAEhB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,UAAU,EAEhB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,QAAQ,EAAE,eAAwE,CAAC;AAIhG,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC9C,WAAW,EAAE,WAAW,CAAC;CAC1B,C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runtime/src/collection.ts"],"sourcesContent":["import {\n parse,\n validate,\n VERSION,\n type Document,\n type Validation,\n type VerifiedModel,\n} from '@agentshouse/mdmodel';\nimport type { Selector } from '@agentshouse/query';\nimport { beneath, normalize } from './paths.js';\nimport type { ModelState } from './model.js';\nimport type { MdModelIdentity } from './adapter.js';\n\nexport const MD_MODEL: MdModelIdentity = { identity: '@agentshouse/mdmodel', version: VERSION };\n\nexport const PRESENTED: Selector = { path: { $regex: '\\\\.md$' } };\n\nconst NO_TYPES: VerifiedModel = { types: {} };\n\nexport type Collection = {\n documents: Readonly<Record<string, Document>>;\n composition: Composition;\n};\n\nexport type Composition = {\n collectionRoot: string;\n model: ModelState;\n selection: { roots: readonly string[]; model: ModelState } | null;\n};\n\nfunction selected(composition: Composition, path: string): boolean {\n return (\n composition.selection !== null &&\n composition.selection.roots.some((root) => beneath(root, path))\n );\n}\n\nexport function governing(composition: Composition, path: string): ModelState {\n return composition.selection !== null && selected(composition, path)\n ? composition.selection.model\n : composition.model;\n}\n\nexport function parseCollection(\n text: Readonly<Record<string, string>>,\n composition: Composition,\n previous?: { text: Readonly<Record<string, string>>; collection: Collection },\n): Collection {\n const documents: Record<string, Document> = {};\n for (const path of Object.keys(text).sort()) {\n const retained = previous?.collection.documents[path];\n if (retained !== undefined && previous?.text[path] === text[path]) {\n documents[path] = retained;\n continue;\n }\n const parsed = parse(text[path], path);\n if (parsed.ok) documents[path] = parsed.document;\n }\n return { documents, composition };\n}\n\nexport function readCollection(\n text: Readonly<Record<string, string>>,\n composition: Composition,\n previous?: { text: Readonly<Record<string, string>>; collection: Collection },\n): Collection | null {\n if (!validRoot(composition.collectionRoot)) return null;\n const collection = parseCollection(text, composition, previous);\n if (Object.keys(collection.documents).length !== Object.keys(text).length) return null;\n if (\n Object.entries(collection.documents).some(\n ([path, document]) =>\n !member(path, composition.collectionRoot) &&\n !selected(composition, path) &&\n document.type !== undefined &&\n document.type !== 'any',\n )\n )\n return null;\n return collection;\n}\n\nexport function validRoot(root: unknown): root is string {\n return typeof root === 'string' && normalize(root) === root;\n}\n\nfunction member(path: string, root: string): boolean {\n return root === '' || path.startsWith(`${root}/`);\n}\n\ntype Refusal = Extract<Validation, { verdict: 'refuse' }>;\n\nfunction validateAgainst(\n documents: Readonly<Record<string, string>>,\n binaryTargets: readonly string[],\n prefix: string,\n model: ModelState,\n): Validation {\n if (model.status === 'unavailable') {\n const typed = Object.entries(documents).find(([, content]) => {\n const parsed = parse(content);\n return parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any';\n });\n if (typed !== undefined)\n return {\n verdict: 'refuse',\n rule: 'model-unavailable',\n file: `${prefix}${typed[0]}`,\n version: VERSION,\n };\n }\n const verdict = validate(\n documents,\n { binaryTargets },\n model.status === 'unavailable' ? NO_TYPES : { types: model.types },\n );\n if (verdict.verdict === 'accept') return verdict;\n return {\n ...verdict,\n file: `${prefix}${verdict.file}`,\n ...(verdict.referrers === undefined\n ? {}\n : { referrers: verdict.referrers.map((path) => `${prefix}${path}`) }),\n };\n}\n\nexport function validateCollection(\n text: Readonly<Record<string, string>>,\n binaryTargets: readonly string[],\n composition: Composition,\n): Validation {\n const prefix = composition.collectionRoot === '' ? '' : `${composition.collectionRoot}/`;\n const collection: Record<string, string> = {};\n const selection: Record<string, string> = {};\n for (const [path, content] of Object.entries(text)) {\n if (member(path, composition.collectionRoot)) {\n collection[path.slice(prefix.length)] = content;\n continue;\n }\n if (selected(composition, path)) {\n selection[path] = content;\n continue;\n }\n const parsed = parse(content, path);\n if (!parsed.ok) return { verdict: 'refuse', ...parsed.refusal };\n if (Object.hasOwn(parsed.document.fields, 'type') && parsed.document.fields.type !== 'any') {\n return { verdict: 'refuse', rule: 'outside-collection-type', file: path, version: VERSION };\n }\n }\n const verdicts = [\n validateAgainst(\n collection,\n binaryTargets\n .filter((path) => member(path, composition.collectionRoot))\n .map((path) => path.slice(prefix.length)),\n prefix,\n composition.model,\n ),\n ];\n if (composition.selection !== null) {\n verdicts.push(\n validateAgainst(\n selection,\n binaryTargets.filter((path) => selected(composition, path)),\n '',\n composition.selection.model,\n ),\n );\n }\n const refusals = verdicts.filter((verdict): verdict is Refusal => verdict.verdict === 'refuse');\n if (refusals.length === 0) return verdicts[0];\n return refusals.find((refusal) => refusal.rule !== 'model-unavailable') ?? refusals[0];\n}\n"],"names":["parse","validate","VERSION","beneath","normalize","MD_MODEL","identity","version","PRESENTED","path","$regex","NO_TYPES","types","selected","composition","selection","roots","some","root","governing","model","parseCollection","text","previous","documents","Object","keys","sort","retained","collection","undefined","parsed","ok","document","readCollection","validRoot","collectionRoot","length","entries","member","type","startsWith","validateAgainst","binaryTargets","prefix","status","typed","find","content","verdict","rule","file","referrers","map","validateCollection","slice","refusal","hasOwn","fields","verdicts","filter","push","refusals"],"mappings":"AAAA,SACEA,KAAK,EACLC,QAAQ,EACRC,OAAO,QAIF,uBAAuB;AAE9B,SAASC,OAAO,EAAEC,SAAS,QAAQ,aAAa;AAIhD,OAAO,MAAMC,WAA4B;IAAEC,UAAU;IAAwBC,SAASL;AAAQ,EAAE;AAEhG,OAAO,MAAMM,YAAsB;IAAEC,MAAM;QAAEC,QAAQ;IAAS;AAAE,EAAE;AAElE,MAAMC,WAA0B;IAAEC,OAAO,CAAC;AAAE;AAa5C,SAASC,SAASC,WAAwB,EAAEL,IAAY;IACtD,OACEK,YAAYC,SAAS,KAAK,QAC1BD,YAAYC,SAAS,CAACC,KAAK,CAACC,IAAI,CAAC,CAACC,OAASf,QAAQe,MAAMT;AAE7D;AAEA,OAAO,SAASU,UAAUL,WAAwB,EAAEL,IAAY;IAC9D,OAAOK,YAAYC,SAAS,KAAK,QAAQF,SAASC,aAAaL,QAC3DK,YAAYC,SAAS,CAACK,KAAK,GAC3BN,YAAYM,KAAK;AACvB;AAEA,OAAO,SAASC,gBACdC,IAAsC,EACtCR,WAAwB,EACxBS,QAA6E;IAE7E,MAAMC,YAAsC,CAAC;IAC7C,KAAK,MAAMf,QAAQgB,OAAOC,IAAI,CAACJ,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;YAClB;QACF;QACA,MAAMjB,SAAS/B,MAAMgD,SAASvC;QAC9B,IAAI,CAACsB,OAAOC,EAAE,EAAE,OAAO;YAAEiB,SAAS;YAAU,GAAGlB,OAAOyB,OAAO;QAAC;QAC9D,IAAI/B,OAAOgC,MAAM,CAAC1B,OAAOE,QAAQ,CAACyB,MAAM,EAAE,WAAW3B,OAAOE,QAAQ,CAACyB,MAAM,CAAClB,IAAI,KAAK,OAAO;YAC1F,OAAO;gBAAES,SAAS;gBAAUC,MAAM;gBAA2BC,MAAM1C;gBAAMF,SAASL;YAAQ;QAC5F;IACF;IACA,MAAMyD,WAAW;QACfjB,gBACEb,YACAc,cACGiB,MAAM,CAAC,CAACnD,OAAS8B,OAAO9B,MAAMK,YAAYsB,cAAc,GACxDiB,GAAG,CAAC,CAAC5C,OAASA,KAAK8C,KAAK,CAACX,OAAOP,MAAM,IACzCO,QACA9B,YAAYM,KAAK;KAEpB;IACD,IAAIN,YAAYC,SAAS,KAAK,MAAM;QAClC4C,SAASE,IAAI,CACXnB,gBACE3B,WACA4B,cAAciB,MAAM,CAAC,CAACnD,OAASI,SAASC,aAAaL,QACrD,IACAK,YAAYC,SAAS,CAACK,KAAK;IAGjC;IACA,MAAM0C,WAAWH,SAASC,MAAM,CAAC,CAACX,UAAgCA,QAAQA,OAAO,KAAK;IACtF,IAAIa,SAASzB,MAAM,KAAK,GAAG,OAAOsB,QAAQ,CAAC,EAAE;IAC7C,OAAOG,SAASf,IAAI,CAAC,CAACS,UAAYA,QAAQN,IAAI,KAAK,wBAAwBY,QAAQ,CAAC,EAAE;AACxF"}
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/collection.ts"],"sourcesContent":["import {\n parse,\n validate,\n VERSION,\n type Document,\n type Validation,\n type VerifiedModel,\n} from '@agentshouse/mdmodel';\nimport { beneath, normalize } from './paths.js';\nimport type { ModelState } from './model.js';\nimport type { MdModelIdentity } from './adapter.js';\n\nexport const MD_MODEL: MdModelIdentity = { identity: '@agentshouse/mdmodel', version: VERSION };\n\nconst NO_TYPES: VerifiedModel = { types: {} };\n\nexport type Collection = {\n documents: Readonly<Record<string, Document>>;\n composition: Composition;\n};\n\nexport type Composition = {\n collectionRoot: string;\n model: ModelState;\n selection: { roots: readonly string[]; model: ModelState } | null;\n};\n\nfunction selected(composition: Composition, path: string): boolean {\n return (\n composition.selection !== null &&\n composition.selection.roots.some((root) => beneath(root, path))\n );\n}\n\nexport function governing(composition: Composition, path: string): ModelState {\n return composition.selection !== null && selected(composition, path)\n ? composition.selection.model\n : composition.model;\n}\n\nexport function parseCollection(\n text: Readonly<Record<string, string>>,\n composition: Composition,\n previous?: { text: Readonly<Record<string, string>>; collection: Collection },\n): Collection {\n const documents: Record<string, Document> = {};\n for (const path of Object.keys(text).sort()) {\n const retained = previous?.collection.documents[path];\n if (retained !== undefined && previous?.text[path] === text[path]) {\n documents[path] = retained;\n continue;\n }\n const parsed = parse(text[path], path);\n if (parsed.ok) documents[path] = parsed.document;\n }\n return { documents, composition };\n}\n\nexport function readCollection(\n text: Readonly<Record<string, string>>,\n composition: Composition,\n previous?: { text: Readonly<Record<string, string>>; collection: Collection },\n): Collection | null {\n if (!validRoot(composition.collectionRoot)) return null;\n const collection = parseCollection(text, composition, previous);\n if (Object.keys(collection.documents).length !== Object.keys(text).length) return null;\n if (\n Object.entries(collection.documents).some(\n ([path, document]) =>\n !member(path, composition.collectionRoot) &&\n !selected(composition, path) &&\n document.type !== undefined &&\n document.type !== 'any',\n )\n )\n return null;\n return collection;\n}\n\nexport function validRoot(root: unknown): root is string {\n return typeof root === 'string' && normalize(root) === root;\n}\n\nfunction member(path: string, root: string): boolean {\n return root === '' || path.startsWith(`${root}/`);\n}\n\ntype Refusal = Extract<Validation, { verdict: 'refuse' }>;\n\nfunction validateAgainst(\n documents: Readonly<Record<string, string>>,\n binaryTargets: readonly string[],\n prefix: string,\n model: ModelState,\n): Validation {\n if (model.status === 'unavailable') {\n const typed = Object.entries(documents).find(([, content]) => {\n const parsed = parse(content);\n return parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any';\n });\n if (typed !== undefined)\n return {\n verdict: 'refuse',\n rule: 'model-unavailable',\n file: `${prefix}${typed[0]}`,\n version: VERSION,\n };\n }\n const verdict = validate(\n documents,\n { binaryTargets },\n model.status === 'unavailable' ? NO_TYPES : { types: model.types },\n );\n if (verdict.verdict === 'accept') return verdict;\n return {\n ...verdict,\n file: `${prefix}${verdict.file}`,\n ...(verdict.referrers === undefined\n ? {}\n : { referrers: verdict.referrers.map((path) => `${prefix}${path}`) }),\n };\n}\n\nexport function validateCollection(\n text: Readonly<Record<string, string>>,\n binaryTargets: readonly string[],\n composition: Composition,\n): Validation {\n const prefix = composition.collectionRoot === '' ? '' : `${composition.collectionRoot}/`;\n const collection: Record<string, string> = {};\n const selection: Record<string, string> = {};\n for (const [path, content] of Object.entries(text)) {\n if (member(path, composition.collectionRoot)) {\n collection[path.slice(prefix.length)] = content;\n continue;\n }\n if (selected(composition, path)) {\n selection[path] = content;\n continue;\n }\n const parsed = parse(content, path);\n if (!parsed.ok) return { verdict: 'refuse', ...parsed.refusal };\n if (Object.hasOwn(parsed.document.fields, 'type') && parsed.document.fields.type !== 'any') {\n return { verdict: 'refuse', rule: 'outside-collection-type', file: path, version: VERSION };\n }\n }\n const verdicts = [\n validateAgainst(\n collection,\n binaryTargets\n .filter((path) => member(path, composition.collectionRoot))\n .map((path) => path.slice(prefix.length)),\n prefix,\n composition.model,\n ),\n ];\n if (composition.selection !== null) {\n verdicts.push(\n validateAgainst(\n selection,\n binaryTargets.filter((path) => selected(composition, path)),\n '',\n composition.selection.model,\n ),\n );\n }\n const refusals = verdicts.filter((verdict): verdict is Refusal => verdict.verdict === 'refuse');\n if (refusals.length === 0) return verdicts[0];\n return refusals.find((refusal) => refusal.rule !== 'model-unavailable') ?? refusals[0];\n}\n"],"names":["parse","validate","VERSION","beneath","normalize","MD_MODEL","identity","version","NO_TYPES","types","selected","composition","path","selection","roots","some","root","governing","model","parseCollection","text","previous","documents","Object","keys","sort","retained","collection","undefined","parsed","ok","document","readCollection","validRoot","collectionRoot","length","entries","member","type","startsWith","validateAgainst","binaryTargets","prefix","status","typed","find","content","verdict","rule","file","referrers","map","validateCollection","slice","refusal","hasOwn","fields","verdicts","filter","push","refusals"],"mappings":"AAAA,SACEA,KAAK,EACLC,QAAQ,EACRC,OAAO,QAIF,uBAAuB;AAC9B,SAASC,OAAO,EAAEC,SAAS,QAAQ,aAAa;AAIhD,OAAO,MAAMC,WAA4B;IAAEC,UAAU;IAAwBC,SAASL;AAAQ,EAAE;AAEhG,MAAMM,WAA0B;IAAEC,OAAO,CAAC;AAAE;AAa5C,SAASC,SAASC,WAAwB,EAAEC,IAAY;IACtD,OACED,YAAYE,SAAS,KAAK,QAC1BF,YAAYE,SAAS,CAACC,KAAK,CAACC,IAAI,CAAC,CAACC,OAASb,QAAQa,MAAMJ;AAE7D;AAEA,OAAO,SAASK,UAAUN,WAAwB,EAAEC,IAAY;IAC9D,OAAOD,YAAYE,SAAS,KAAK,QAAQH,SAASC,aAAaC,QAC3DD,YAAYE,SAAS,CAACK,KAAK,GAC3BP,YAAYO,KAAK;AACvB;AAEA,OAAO,SAASC,gBACdC,IAAsC,EACtCT,WAAwB,EACxBU,QAA6E;IAE7E,MAAMC,YAAsC,CAAC;IAC7C,KAAK,MAAMV,QAAQW,OAAOC,IAAI,CAACJ,MAAMK,IAAI,GAAI;QAC3C,MAAMC,WAAWL,UAAUM,WAAWL,SAAS,CAACV,KAAK;QACrD,IAAIc,aAAaE,aAAaP,UAAUD,IAAI,CAACR,KAAK,KAAKQ,IAAI,CAACR,KAAK,EAAE;YACjEU,SAAS,CAACV,KAAK,GAAGc;YAClB;QACF;QACA,MAAMG,SAAS7B,MAAMoB,IAAI,CAACR,KAAK,EAAEA;QACjC,IAAIiB,OAAOC,EAAE,EAAER,SAAS,CAACV,KAAK,GAAGiB,OAAOE,QAAQ;IAClD;IACA,OAAO;QAAET;QAAWX;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AC5F;IACF;IACA,MAAMuD,WAAW;QACfjB,gBACEb,YACAc,cACGiB,MAAM,CAAC,CAAC9C,OAASyB,OAAOzB,MAAMD,YAAYuB,cAAc,GACxDiB,GAAG,CAAC,CAACvC,OAASA,KAAKyC,KAAK,CAACX,OAAOP,MAAM,IACzCO,QACA/B,YAAYO,KAAK;KAEpB;IACD,IAAIP,YAAYE,SAAS,KAAK,MAAM;QAClC4C,SAASE,IAAI,CACXnB,gBACE3B,WACA4B,cAAciB,MAAM,CAAC,CAAC9C,OAASF,SAASC,aAAaC,QACrD,IACAD,YAAYE,SAAS,CAACK,KAAK;IAGjC;IACA,MAAM0C,WAAWH,SAASC,MAAM,CAAC,CAACX,UAAgCA,QAAQA,OAAO,KAAK;IACtF,IAAIa,SAASzB,MAAM,KAAK,GAAG,OAAOsB,QAAQ,CAAC,EAAE;IAC7C,OAAOG,SAASf,IAAI,CAAC,CAACS,UAAYA,QAAQN,IAAI,KAAK,wBAAwBY,QAAQ,CAAC,EAAE;AACxF"}
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type QueryBinding } from './query.js';
|
|
2
1
|
import { type TypesResult } from './model.js';
|
|
3
|
-
import { type
|
|
2
|
+
import { type DocumentQuery, type DocumentResult, type GroupQuery, type GroupResult } from './query.js';
|
|
3
|
+
import { type SearchRequest, type SearchResult } from './search.js';
|
|
4
4
|
import { type Adapter, type Authorization, type HistoryResult, type ProviderRefusal } from './adapter.js';
|
|
5
5
|
import { type ChatDraftSurface, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
|
|
6
6
|
import type { WrittenBy } from './change.js';
|
|
@@ -49,7 +49,6 @@ export type ConnectionRefusal = {
|
|
|
49
49
|
export type MdRuntimeOptions = {
|
|
50
50
|
adapter: Adapter;
|
|
51
51
|
shell: RuntimeShell;
|
|
52
|
-
queryBinding: QueryBinding | null;
|
|
53
52
|
requiredGuarantees: readonly string[];
|
|
54
53
|
authorization?: Authorization;
|
|
55
54
|
discoveryIntervalMs?: number;
|
|
@@ -83,7 +82,11 @@ export type MdRuntime = {
|
|
|
83
82
|
loaded(): Promise<void>;
|
|
84
83
|
rooms(): readonly AppRoom[];
|
|
85
84
|
slots(): readonly AppSlot[];
|
|
86
|
-
query
|
|
85
|
+
query: {
|
|
86
|
+
(query: DocumentQuery): Promise<DocumentResult>;
|
|
87
|
+
(query: GroupQuery): Promise<GroupResult>;
|
|
88
|
+
};
|
|
89
|
+
search(request: SearchRequest): Promise<SearchResult>;
|
|
87
90
|
types(locator: string): RoomTypes;
|
|
88
91
|
syncStatus(): SyncStatus;
|
|
89
92
|
roomDraft: RoomDraftSurface;
|
|
@@ -102,7 +105,8 @@ export type MdRuntime = {
|
|
|
102
105
|
(topic: 'connection-refusal', listener: (refusal: ConnectionRefusal | null) => void): () => void;
|
|
103
106
|
(topic: 'storage-loss', listener: (statement: string | null) => void): () => void;
|
|
104
107
|
(topic: 'sync-status', listener: (status: SyncStatus) => void): () => void;
|
|
105
|
-
(topic: 'query', query:
|
|
108
|
+
(topic: 'query', query: DocumentQuery, listener: (result: DocumentResult) => void): () => void;
|
|
109
|
+
(topic: 'query', query: GroupQuery, listener: (result: GroupResult) => void): () => void;
|
|
106
110
|
(topic: 'queue', locator: string, listener: (entries: readonly QueueEntry[]) => void): () => void;
|
|
107
111
|
(topic: 'room-drafts', listener: (roomDrafts: readonly RoomDraft[]) => void): () => void;
|
|
108
112
|
(topic: 'presentation', app: string, listener: (value: unknown) => void): () => void;
|
package/dist/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,cA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