@agentshouse/mdruntime 0.1.0-c89b819f8a6bf → 0.1.0-c8a9c5beaa50b
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 +1 -1
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +30 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +25 -5
- package/dist/adapter.d.ts +67 -17
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -2
- package/dist/{binary.d.ts → attachment.d.ts} +4 -4
- package/dist/attachment.d.ts.map +1 -0
- package/dist/{binary.js → attachment.js} +2 -2
- package/dist/authored.d.ts.map +1 -1
- package/dist/authored.js +2 -0
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change.d.ts +2 -2
- package/dist/client.d.ts +13 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +12 -11
- package/dist/collection.d.ts +1 -0
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +7 -1
- package/dist/compile.d.ts +2 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +71 -39
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +2 -0
- package/dist/conversation-live.d.ts +1 -0
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +2 -1
- package/dist/conversation-row.d.ts +12 -0
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +10 -0
- package/dist/conversation.d.ts +12 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +37 -30
- package/dist/declaration.js +2 -2
- package/dist/download.d.ts +2 -2
- package/dist/download.d.ts.map +1 -1
- package/dist/entry.d.ts +13 -3
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +72 -24
- package/dist/figures.d.ts +1 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +2 -2
- package/dist/host.d.ts +1 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +27 -16
- package/dist/house-query.d.ts +8 -2
- package/dist/house-query.d.ts.map +1 -1
- package/dist/house-query.js +53 -5
- package/dist/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/index.d.ts +14 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +2 -0
- package/dist/live.d.ts +14 -0
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +29 -12
- package/dist/loaded.d.ts +5 -3
- package/dist/loaded.d.ts.map +1 -1
- package/dist/loaded.js +12 -6
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +19 -6
- package/dist/memory.d.ts +2 -2
- package/dist/memory.js +9 -9
- package/dist/messages.d.ts +5 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +14 -3
- package/dist/model.d.ts +6 -5
- package/dist/model.d.ts.map +1 -1
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/opened.d.ts +5 -5
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +2 -2
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +2 -0
- package/dist/outcome.d.ts +16 -16
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +5 -5
- package/dist/overlay.d.ts +19 -8
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +108 -37
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +56 -13
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +29 -13
- package/dist/react.d.ts +6 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +4 -1
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +2 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +15 -4
- package/dist/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +3 -3
- package/dist/room-draft.d.ts +1 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +4 -4
- package/dist/room-drafts.js +2 -2
- package/dist/room-list.d.ts.map +1 -1
- package/dist/room-list.js +2 -0
- package/dist/rows.d.ts +9 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +18 -4
- package/dist/run-tables.d.ts +25 -0
- package/dist/run-tables.d.ts.map +1 -0
- package/dist/run-tables.js +94 -0
- package/dist/runs.d.ts +27 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +90 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +1 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +6 -6
- package/dist/saves.d.ts +5 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +51 -45
- package/dist/selector.d.ts +3 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +22 -0
- package/dist/socket.d.ts +3 -1
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +7 -0
- package/dist/source.d.ts +13 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +23 -0
- package/dist/store/records.d.ts +12 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +10 -4
- package/dist/store.d.ts +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/stored.d.ts +9 -2
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +33 -11
- package/dist/surface.d.ts +9 -3
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +5 -2
- package/dist/sync.js +1 -1
- package/dist/tables.d.ts +27 -2
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +25 -3
- package/dist/tallies.js +2 -2
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +49 -3
- package/dist/wire.d.ts +7 -6
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +7 -6
- package/package.json +4 -4
- package/dist/binary.d.ts.map +0 -1
package/dist/messages.js
CHANGED
|
@@ -4,6 +4,7 @@ import { EXCERPT } from './read.js';
|
|
|
4
4
|
import { tablesOf } from './stored.js';
|
|
5
5
|
const SAID_BY_HOUSE = `json_extract(message, '$.role') = 'house'`;
|
|
6
6
|
const ANSWERS_THE_TURN = `json_extract(message, '$.role') = 'assistant'`;
|
|
7
|
+
const WAITING_PROPOSAL = `json_extract(message, '$.source.kind') = 'instructions_proposal' AND json_extract(message, '$.source.state') = 'waiting'`;
|
|
7
8
|
export const MESSAGE_TABLES = [
|
|
8
9
|
'CREATE TABLE conversation_reads (conversation TEXT PRIMARY KEY, read TEXT, partial INTEGER NOT NULL) WITHOUT ROWID',
|
|
9
10
|
'CREATE TABLE conversation_messages (id INTEGER PRIMARY KEY, conversation TEXT NOT NULL, identity TEXT NOT NULL, turn TEXT NOT NULL, position TEXT NOT NULL, change TEXT NOT NULL, message TEXT NOT NULL, text TEXT NOT NULL)',
|
|
@@ -22,7 +23,8 @@ export const ROWS = `WITH chosen AS (
|
|
|
22
23
|
(${OF_THE_ROW} AND ${ANSWERS_THE_TURN} ${NEWEST_FIRST}) AS answer,
|
|
23
24
|
(${OF_THE_ROW} AND text <> '' ${NEWEST_FIRST}) AS said,
|
|
24
25
|
(${OF_THE_ROW} AND ${SAID_BY_HOUSE} ${OLDEST_FIRST}) AS opened,
|
|
25
|
-
(${OF_THE_ROW} AND ${SAID_BY_HOUSE} AND json_extract(message, '$.waiting') = 1 ${OLDEST_FIRST}) AS asking
|
|
26
|
+
(${OF_THE_ROW} AND ${SAID_BY_HOUSE} AND json_extract(message, '$.waiting') = 1 ${OLDEST_FIRST}) AS asking,
|
|
27
|
+
(${OF_THE_ROW} AND ${SAID_BY_HOUSE} AND ${WAITING_PROPOSAL} ${NEWEST_FIRST}) AS proposing
|
|
26
28
|
FROM json_each(?) AS listed
|
|
27
29
|
)
|
|
28
30
|
SELECT chosen.conversation AS conversation,
|
|
@@ -43,12 +45,15 @@ export const ROWS = `WITH chosen AS (
|
|
|
43
45
|
asking.text AS asking_text,
|
|
44
46
|
json_extract(asking.message, '$.accepted_at') AS asking_at,
|
|
45
47
|
json_extract(asking.message, '$.source') AS asking_source,
|
|
46
|
-
json_extract(asking.message, '$.sender') AS asking_sender
|
|
48
|
+
json_extract(asking.message, '$.sender') AS asking_sender,
|
|
49
|
+
json_extract(proposing.message, '$.source') AS proposing_source,
|
|
50
|
+
json_extract(proposing.message, '$.accepted_at') AS proposing_at
|
|
47
51
|
FROM chosen
|
|
48
52
|
LEFT JOIN conversation_messages said ON said.id = chosen.said
|
|
49
53
|
LEFT JOIN conversation_messages answer ON answer.id = chosen.answer
|
|
50
54
|
LEFT JOIN conversation_messages opened ON opened.id = chosen.opened
|
|
51
|
-
LEFT JOIN conversation_messages asking ON asking.id = chosen.asking
|
|
55
|
+
LEFT JOIN conversation_messages asking ON asking.id = chosen.asking
|
|
56
|
+
LEFT JOIN conversation_messages proposing ON proposing.id = chosen.proposing`;
|
|
52
57
|
export function heldConversations(connection, conversations) {
|
|
53
58
|
const named = conversations === null ? '' : ' AND conversation IN (SELECT value FROM json_each(?))';
|
|
54
59
|
const bound = conversations === null ? [] : [JSON.stringify(conversations)];
|
|
@@ -147,6 +152,12 @@ export function conversationRows(connection, conversations) {
|
|
|
147
152
|
text: text(row.asking_text),
|
|
148
153
|
at: textOrNull(row.asking_at),
|
|
149
154
|
},
|
|
155
|
+
proposing: row.proposing_source === null
|
|
156
|
+
? null
|
|
157
|
+
: {
|
|
158
|
+
source: JSON.parse(text(row.proposing_source)),
|
|
159
|
+
at: textOrNull(row.proposing_at),
|
|
160
|
+
},
|
|
150
161
|
}));
|
|
151
162
|
}
|
|
152
163
|
export function turnArrived(connection, conversation, turn) {
|
package/dist/model.d.ts
CHANGED
|
@@ -17,20 +17,21 @@ export type ModelResult = {
|
|
|
17
17
|
reason: ModelUnavailableReason;
|
|
18
18
|
};
|
|
19
19
|
export type MdType = Definition;
|
|
20
|
-
export type
|
|
20
|
+
export type StoredModel = {
|
|
21
21
|
status: 'unavailable';
|
|
22
22
|
reason: ModelUnavailableReason;
|
|
23
23
|
} | {
|
|
24
24
|
status: 'current' | 'cached';
|
|
25
25
|
snapshot: ModelSnapshot;
|
|
26
26
|
verifiedWith: ModelIdentity;
|
|
27
|
-
types: VerifiedModel['types'];
|
|
28
27
|
};
|
|
29
|
-
export type
|
|
28
|
+
export type ModelState = Extract<StoredModel, {
|
|
30
29
|
status: 'unavailable';
|
|
31
|
-
}> |
|
|
30
|
+
}> | (Extract<StoredModel, {
|
|
32
31
|
status: 'current' | 'cached';
|
|
33
|
-
}
|
|
32
|
+
}> & {
|
|
33
|
+
types: VerifiedModel['types'];
|
|
34
|
+
});
|
|
34
35
|
export type TypesResult<Types = readonly MdType[]> = {
|
|
35
36
|
status: Open<'unavailable'>;
|
|
36
37
|
reason: ModelUnavailableReason;
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAA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,EAAE,UAAU,GAAG,WAAW,CAEzD;AACD,wBAAgB,WAAW,CAAC,KAAK,EAC/B,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,KAAK,KAAK,GAC7C,WAAW,CAAC,KAAK,CAAC,CAYpB;AACD,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAI1D"}
|
package/dist/name.d.ts
CHANGED
package/dist/name.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../src/name.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../src/name.ts"],"names":[],"mappings":"AA+GA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK9C;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
package/dist/name.js
CHANGED
|
@@ -97,22 +97,18 @@ function lowerLetterOf(character) {
|
|
|
97
97
|
function codePoint(character) {
|
|
98
98
|
return WORDLIKE.test(character) ? `-u${character.codePointAt(0)?.toString(16) ?? ''}-` : '-';
|
|
99
99
|
}
|
|
100
|
-
function latin(text
|
|
100
|
+
function latin(text) {
|
|
101
101
|
return [...text]
|
|
102
102
|
.map((character) => {
|
|
103
103
|
if ((character.codePointAt(0) ?? 0) < 0x80)
|
|
104
104
|
return character;
|
|
105
105
|
const lower = character.toLowerCase();
|
|
106
|
-
|
|
107
|
-
return lower === character ? letter : `${letter.charAt(0).toUpperCase()}${letter.slice(1)}`;
|
|
106
|
+
return lowerLetterOf(lower) ?? codePoint(lower);
|
|
108
107
|
})
|
|
109
108
|
.join('');
|
|
110
109
|
}
|
|
111
|
-
export function transliterated(text) {
|
|
112
|
-
return latin(text, () => '-');
|
|
113
|
-
}
|
|
114
110
|
export function nameFrom(title) {
|
|
115
|
-
return latin(title
|
|
111
|
+
return latin(title)
|
|
116
112
|
.toLowerCase()
|
|
117
113
|
.replace(/[^a-z0-9]+/g, '-')
|
|
118
114
|
.replace(/^-+|-+$/g, '');
|
package/dist/opened.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AttachmentResult } from './adapter.js';
|
|
2
2
|
import { type RuntimeDatabase } from './tables.js';
|
|
3
3
|
export type OpenedName = {
|
|
4
4
|
readonly locator: string;
|
|
5
5
|
readonly path: string;
|
|
6
6
|
readonly revision: string;
|
|
7
7
|
};
|
|
8
|
-
export type
|
|
8
|
+
export type KeptAttachment = {
|
|
9
9
|
readonly kind: 'binary';
|
|
10
10
|
readonly file: string;
|
|
11
11
|
readonly byteLength: number;
|
|
12
12
|
readonly mediaType: string;
|
|
13
13
|
};
|
|
14
|
-
export type KeptResult =
|
|
14
|
+
export type KeptResult = KeptAttachment | Exclude<AttachmentResult, {
|
|
15
15
|
kind: 'binary';
|
|
16
16
|
}>;
|
|
17
17
|
export type OpenedFiles = {
|
|
18
|
-
find(name: OpenedName): Promise<
|
|
19
|
-
fetch(name: OpenedName, read: () => Promise<
|
|
18
|
+
find(name: OpenedName): Promise<KeptAttachment | null>;
|
|
19
|
+
fetch(name: OpenedName, read: () => Promise<AttachmentResult>): Promise<KeptResult>;
|
|
20
20
|
};
|
|
21
21
|
export declare function openedFiles(database: RuntimeDatabase, lost: (locator: string) => boolean): OpenedFiles;
|
|
22
22
|
//# sourceMappingURL=opened.d.ts.map
|
package/dist/opened.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../src/opened.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../src/opened.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAErF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,OAAO,CAAC,gBAAgB,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAExF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACvD,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACrF,CAAC;AAsBF,wBAAgB,WAAW,CACzB,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,GACjC,WAAW,CAsFb"}
|
package/dist/opened.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { digest } from './digest.js';
|
|
2
|
-
import {
|
|
2
|
+
import { attachmentLocalId } from './identity.js';
|
|
3
3
|
import { FILE_PART_BYTES } from './tables.js';
|
|
4
4
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
5
5
|
function kept({ key, byteLength, mediaType }) {
|
|
@@ -27,7 +27,7 @@ export function openedFiles(database, lost) {
|
|
|
27
27
|
return held === null ? null : kept(held);
|
|
28
28
|
}
|
|
29
29
|
async function written(name, { body, mediaType, sha256 }) {
|
|
30
|
-
const key =
|
|
30
|
+
const key = attachmentLocalId();
|
|
31
31
|
const reader = body.getReader();
|
|
32
32
|
const hashed = digest();
|
|
33
33
|
const chunks = [];
|
package/dist/opening.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAuCxF"}
|
package/dist/opening.js
CHANGED
|
@@ -5,6 +5,7 @@ import { sweep } from './install.js';
|
|
|
5
5
|
import { eraseFenced } from './lost.js';
|
|
6
6
|
import { prepare } from './preparation.js';
|
|
7
7
|
import { unpair } from './queue.js';
|
|
8
|
+
import { runsOpened } from './runs.js';
|
|
8
9
|
import { emitRooms, emitStorageLoss, statusShown } from './shown.js';
|
|
9
10
|
export async function open(runtime, opened) {
|
|
10
11
|
const { store, socket, shell, conversations, build } = runtime;
|
|
@@ -40,6 +41,7 @@ export async function open(runtime, opened) {
|
|
|
40
41
|
if (held.erasing || held.orphans.length > 0)
|
|
41
42
|
queueMicrotask(() => sweep(runtime));
|
|
42
43
|
await conversationsOpened(conversations, opened);
|
|
44
|
+
await runsOpened(runtime);
|
|
43
45
|
if (interrupted.length > 0) {
|
|
44
46
|
queueMicrotask(() => {
|
|
45
47
|
void eraseFenced(runtime, interrupted).catch(uncaught);
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ActionResult, AdapterFailure, AttachResult,
|
|
1
|
+
import type { ActionResult, AdapterFailure, AttachResult, AttachmentCopy, AttachmentLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
3
|
import type { Attempt, Retries } from './retried.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { KeptAttachment, KeptResult } from './opened.js';
|
|
5
5
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
6
6
|
kind: Kind;
|
|
7
7
|
};
|
|
@@ -20,30 +20,30 @@ export type CallResult = {
|
|
|
20
20
|
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
21
21
|
kind: Failure['kind'];
|
|
22
22
|
}> | Failure;
|
|
23
|
-
type
|
|
24
|
-
export type
|
|
23
|
+
type AttachmentRefusal = Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
24
|
+
export type AttachmentAnswer = {
|
|
25
25
|
kind: 'binary';
|
|
26
26
|
stream: ReadableStream<Uint8Array>;
|
|
27
27
|
byteLength: number;
|
|
28
28
|
mediaType: string;
|
|
29
|
-
} |
|
|
30
|
-
export type
|
|
31
|
-
export type
|
|
29
|
+
} | AttachmentRefusal;
|
|
30
|
+
export type HeldAttachmentAnswer = KeptAttachment | AttachmentRefusal;
|
|
31
|
+
export type AttachmentLinkAnswer = {
|
|
32
32
|
kind: 'link';
|
|
33
33
|
url: string;
|
|
34
34
|
name: string;
|
|
35
35
|
mediaType: string;
|
|
36
36
|
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
37
|
-
export type ShownLinkAnswer = Extract<
|
|
37
|
+
export type ShownLinkAnswer = Extract<AttachmentLinkAnswer, {
|
|
38
38
|
kind: 'link';
|
|
39
39
|
}> & {
|
|
40
|
-
copies: readonly
|
|
40
|
+
copies: readonly AttachmentCopy[];
|
|
41
41
|
};
|
|
42
|
-
type ShownRefusal = Exclude<
|
|
42
|
+
type ShownRefusal = Exclude<AttachmentLinkAnswer, {
|
|
43
43
|
kind: 'link';
|
|
44
44
|
}>;
|
|
45
|
-
export type HeldShownAnswer =
|
|
46
|
-
export type ShownAnswer =
|
|
45
|
+
export type HeldShownAnswer = KeptAttachment | ShownLinkAnswer | ShownRefusal;
|
|
46
|
+
export type ShownAnswer = AttachmentAnswer | ShownLinkAnswer | ShownRefusal;
|
|
47
47
|
export type AttachAnswer = {
|
|
48
48
|
kind: 'attached';
|
|
49
49
|
path: string;
|
|
@@ -68,13 +68,13 @@ export type Resolution = {
|
|
|
68
68
|
export declare const UNREADABLE: Refused<'unreadable'>;
|
|
69
69
|
export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
70
70
|
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
71
|
-
export declare function
|
|
71
|
+
export declare function absentAttachment(path: string): Refused<'absent'>;
|
|
72
72
|
export declare function declaredType(blob: Blob): string;
|
|
73
|
-
export declare function
|
|
73
|
+
export declare function attachmentBlob(binary: Extract<AttachmentAnswer, {
|
|
74
74
|
kind: 'binary';
|
|
75
75
|
}>): Promise<Blob>;
|
|
76
|
-
export declare function
|
|
77
|
-
export declare function
|
|
76
|
+
export declare function attachmentAnswer(result: KeptResult): HeldAttachmentAnswer;
|
|
77
|
+
export declare function attachmentLinkAnswer(result: AttachmentLinkResult, held?: string): AttachmentLinkAnswer;
|
|
78
78
|
export declare function attachAnswer(result: AttachResult): AttachAnswer;
|
|
79
79
|
export declare function linkedAnswer(result: AttachResult): ConversationAttachAnswer;
|
|
80
80
|
export declare const ROOM_LOCKED = "room-locked";
|
package/dist/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"outcome.d.ts","sourceRoot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AO,MAAM,UAAU,EAAE,YAAgD,CAAC;AAE1E,wBAAgB,aAAa,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,MAAM,EAAE,YAAY,GACnB,UAAU,CAUZ"}
|
package/dist/outcome.js
CHANGED
|
@@ -18,19 +18,19 @@ export const ABSENT_TARGET = {
|
|
|
18
18
|
fields: {},
|
|
19
19
|
retryable: false,
|
|
20
20
|
};
|
|
21
|
-
export function
|
|
22
|
-
return { kind: 'absent', code: '
|
|
21
|
+
export function absentAttachment(path) {
|
|
22
|
+
return { kind: 'absent', code: 'attachment-absent', fields: { path }, retryable: false };
|
|
23
23
|
}
|
|
24
24
|
export function declaredType(blob) {
|
|
25
25
|
return blob.type === '' ? MEDIA_TYPES.octetStream : blob.type;
|
|
26
26
|
}
|
|
27
|
-
export function
|
|
27
|
+
export function attachmentBlob(binary) {
|
|
28
28
|
return new Response(binary.stream, { headers: { 'content-type': binary.mediaType } }).blob();
|
|
29
29
|
}
|
|
30
|
-
export function
|
|
30
|
+
export function attachmentAnswer(result) {
|
|
31
31
|
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
32
32
|
}
|
|
33
|
-
export function
|
|
33
|
+
export function attachmentLinkAnswer(result, held) {
|
|
34
34
|
if (result.kind === 'link') {
|
|
35
35
|
return {
|
|
36
36
|
kind: 'link',
|
package/dist/overlay.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ApplyResult } from '@agentshouse/mdmodel';
|
|
2
|
-
import type {
|
|
1
|
+
import { type ApplyResult, type Refusal as ModelRefusal } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { Attachment, HeadChange } from './adapter.js';
|
|
3
3
|
import { type Composition } from './collection.js';
|
|
4
4
|
import { type ChangeBatch } from './change.js';
|
|
5
5
|
export type Heads = {
|
|
@@ -8,9 +8,9 @@ export type Heads = {
|
|
|
8
8
|
created: Readonly<Record<string, string>>;
|
|
9
9
|
changes: Readonly<Record<string, HeadChange>>;
|
|
10
10
|
};
|
|
11
|
-
export type
|
|
11
|
+
export type HeldAttachment = ({
|
|
12
12
|
readonly state: 'accepted';
|
|
13
|
-
} &
|
|
13
|
+
} & Attachment) | {
|
|
14
14
|
readonly state: 'pending';
|
|
15
15
|
readonly localId: string;
|
|
16
16
|
readonly byteLength: number;
|
|
@@ -19,12 +19,23 @@ export type HeldBinary = ({
|
|
|
19
19
|
};
|
|
20
20
|
export type Layer = Heads & {
|
|
21
21
|
documents: Readonly<Record<string, string>>;
|
|
22
|
-
binaries: Readonly<Record<string,
|
|
22
|
+
binaries: Readonly<Record<string, HeldAttachment>>;
|
|
23
23
|
};
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
24
|
+
export declare function acceptedAttachments(files: Readonly<Record<string, Attachment>>): Generator<readonly [string, HeldAttachment]>;
|
|
25
|
+
export declare function sameAttachment(left: HeldAttachment | undefined, right: HeldAttachment | undefined): boolean;
|
|
26
26
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
27
27
|
export declare function composed(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): ApplyResult;
|
|
28
|
-
export declare function compose(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): string;
|
|
29
28
|
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], composition: Composition, unapplied?: () => void): Generator<number, Layer, void>;
|
|
29
|
+
export type WrittenDocument = {
|
|
30
|
+
readonly stale: true;
|
|
31
|
+
readonly refusal?: ModelRefusal;
|
|
32
|
+
} | {
|
|
33
|
+
readonly stale: false;
|
|
34
|
+
readonly content: string;
|
|
35
|
+
readonly base: string | null;
|
|
36
|
+
readonly created: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type Written = readonly (WrittenDocument | null)[];
|
|
39
|
+
export declare function unreadDocuments(batch: ChangeBatch, base: string): Written;
|
|
40
|
+
export declare function writtenDocuments(base: Layer, batch: ChangeBatch, composition: Composition): Generator<number, Written, void>;
|
|
30
41
|
//# sourceMappingURL=overlay.d.ts.map
|
package/dist/overlay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,WAAW,EAEhB,KAAK,OAAO,IAAI,YAAY,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAIL,KAAK,WAAW,EAGjB,MAAM,aAAa,CAAC;AAIrB,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,cAAc,GACtB,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GAAG,UAAU,CAAC,GAC7C;IACE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,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AA;CAAE,GACzD;IACE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEN,MAAM,MAAM,OAAO,GAAG,SAAS,CAAC,eAAe,GAAG,IAAI,CAAC,EAAE,CAAC;AAmB1D,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAQzE;AAED,wBAAiB,gBAAgB,CAC/B,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,WAAW,EAClB,WAAW,EAAE,WAAW,GACvB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAoClC"}
|
package/dist/overlay.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { apply, create, documentValue, parse, serialize, TYPE_FIELD, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { definitionsAt } from './collection.js';
|
|
3
|
-
import { isPart, } from './change.js';
|
|
3
|
+
import { departure, isPart, } from './change.js';
|
|
4
4
|
import { drafted, entriesIn, settling } from './shared.js';
|
|
5
5
|
import { ROW_WEIGHT } from './turn.js';
|
|
6
|
-
export function*
|
|
6
|
+
export function* acceptedAttachments(files) {
|
|
7
7
|
for (const [path, file] of entriesIn(files))
|
|
8
8
|
yield [path, { state: 'accepted', ...file }];
|
|
9
9
|
}
|
|
10
|
-
export function
|
|
10
|
+
export function sameAttachment(left, right) {
|
|
11
11
|
if (left === undefined || right === undefined)
|
|
12
12
|
return left === right;
|
|
13
13
|
return (left.state === right.state &&
|
|
@@ -67,12 +67,6 @@ export function composed(path, fields, sections, composition) {
|
|
|
67
67
|
})),
|
|
68
68
|
], definition);
|
|
69
69
|
}
|
|
70
|
-
export function compose(path, fields, sections, composition) {
|
|
71
|
-
const next = composed(path, fields, sections, composition);
|
|
72
|
-
if (next.outcome !== 'applied')
|
|
73
|
-
throw new Error(`the creation of ${path} writes no document`);
|
|
74
|
-
return serialize(next.document);
|
|
75
|
-
}
|
|
76
70
|
function edited(change, priors) {
|
|
77
71
|
if (change.kind === 'field')
|
|
78
72
|
return {
|
|
@@ -104,7 +98,7 @@ function edit(staged, changes, priors, composition) {
|
|
|
104
98
|
const wanted = changes.map((change) => edited(change, priors));
|
|
105
99
|
const first = apply(parsed.document, wanted, definition);
|
|
106
100
|
if (first.outcome === 'refuse')
|
|
107
|
-
return
|
|
101
|
+
return { refusal: first.refusal };
|
|
108
102
|
if (first.outcome === 'applied') {
|
|
109
103
|
staged.documents[path] = serialize(first.document);
|
|
110
104
|
return 0;
|
|
@@ -164,10 +158,16 @@ function erase(staged, path) {
|
|
|
164
158
|
}
|
|
165
159
|
function stage(staged, change, composition) {
|
|
166
160
|
if (change.kind === 'create') {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
161
|
+
if ('content' in change)
|
|
162
|
+
staged.documents[change.path] = change.content;
|
|
163
|
+
else {
|
|
164
|
+
const next = composed(change.path, change.fields, change.sections, composition);
|
|
165
|
+
if (next.outcome === 'refuse')
|
|
166
|
+
return { refusal: next.refusal };
|
|
167
|
+
if (next.outcome === 'stale')
|
|
168
|
+
throw new Error(`the creation of ${change.path} writes no document`);
|
|
169
|
+
staged.documents[change.path] = serialize(next.document);
|
|
170
|
+
}
|
|
171
171
|
delete staged.fileIds[change.path];
|
|
172
172
|
delete staged.created[change.path];
|
|
173
173
|
delete staged.changes[change.path];
|
|
@@ -219,8 +219,38 @@ function arrive(heads, change) {
|
|
|
219
219
|
if (change.change !== undefined)
|
|
220
220
|
heads.changes[change.path] = change.change;
|
|
221
221
|
}
|
|
222
|
-
|
|
223
|
-
const
|
|
222
|
+
function* stagedBatch(staged, batch, composition, settled) {
|
|
223
|
+
const priors = yield* priorsOf(batch.preconditions);
|
|
224
|
+
for (let index = 0; index < batch.changes.length; index += 1) {
|
|
225
|
+
const change = batch.changes[index];
|
|
226
|
+
if (!isPart(change)) {
|
|
227
|
+
const staging = stage(staged, change, composition);
|
|
228
|
+
if (typeof staging === 'boolean')
|
|
229
|
+
settled(index, change.path, staging ? 0 : 1);
|
|
230
|
+
else
|
|
231
|
+
settled(index, change.path, 1, staging.refusal);
|
|
232
|
+
yield ROW_WEIGHT;
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const run = [change];
|
|
236
|
+
while (index + 1 < batch.changes.length) {
|
|
237
|
+
const next = batch.changes[index + 1];
|
|
238
|
+
if (!isPart(next) || next.path !== change.path)
|
|
239
|
+
break;
|
|
240
|
+
run.push(next);
|
|
241
|
+
index += 1;
|
|
242
|
+
}
|
|
243
|
+
const text = staged.documents[change.path] ?? '';
|
|
244
|
+
const edited = edit(staged, run, priors, composition);
|
|
245
|
+
if (typeof edited === 'number')
|
|
246
|
+
settled(index, change.path, edited);
|
|
247
|
+
else
|
|
248
|
+
settled(index, change.path, run.length, edited.refusal);
|
|
249
|
+
yield ROW_WEIGHT + text.length;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function stagedOf(base) {
|
|
253
|
+
return {
|
|
224
254
|
documents: drafted(base.documents),
|
|
225
255
|
binaries: drafted(base.binaries),
|
|
226
256
|
revisions: drafted(base.revisions),
|
|
@@ -228,29 +258,14 @@ export function* overlaying(base, queue, composition, unapplied) {
|
|
|
228
258
|
created: drafted(base.created),
|
|
229
259
|
changes: drafted(base.changes),
|
|
230
260
|
};
|
|
261
|
+
}
|
|
262
|
+
export function* overlaying(base, queue, composition, unapplied) {
|
|
263
|
+
const staged = stagedOf(base);
|
|
231
264
|
for (const batch of queue) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const change = batch.changes[index];
|
|
235
|
-
if (!isPart(change)) {
|
|
236
|
-
if (!stage(staged, change, composition))
|
|
237
|
-
unapplied?.();
|
|
238
|
-
yield ROW_WEIGHT;
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
const run = [change];
|
|
242
|
-
while (index + 1 < batch.changes.length) {
|
|
243
|
-
const next = batch.changes[index + 1];
|
|
244
|
-
if (!isPart(next) || next.path !== change.path)
|
|
245
|
-
break;
|
|
246
|
-
run.push(next);
|
|
247
|
-
index += 1;
|
|
248
|
-
}
|
|
249
|
-
const text = staged.documents[change.path] ?? '';
|
|
250
|
-
for (let left = edit(staged, run, priors, composition); left > 0; left -= 1)
|
|
265
|
+
yield* stagedBatch(staged, batch, composition, (_index, _path, left) => {
|
|
266
|
+
for (let count = left; count > 0; count -= 1)
|
|
251
267
|
unapplied?.();
|
|
252
|
-
|
|
253
|
-
}
|
|
268
|
+
});
|
|
254
269
|
}
|
|
255
270
|
return {
|
|
256
271
|
documents: yield* settling(staged.documents),
|
|
@@ -261,3 +276,59 @@ export function* overlaying(base, queue, composition, unapplied) {
|
|
|
261
276
|
changes: yield* settling(staged.changes),
|
|
262
277
|
};
|
|
263
278
|
}
|
|
279
|
+
function writesText(change) {
|
|
280
|
+
return isPart(change) || change.kind === 'create' || change.kind === 'replace';
|
|
281
|
+
}
|
|
282
|
+
function textWrites(changes) {
|
|
283
|
+
const identities = changes.map((_, index) => departure(changes, index));
|
|
284
|
+
const created = new Set(changes.flatMap((change, index) => (change.kind === 'create' ? [identities[index]] : [])));
|
|
285
|
+
const last = new Map(changes.flatMap((change, index) => writesText(change) ? [[identities[index], index]] : []));
|
|
286
|
+
return { identities, created, last };
|
|
287
|
+
}
|
|
288
|
+
export function unreadDocuments(batch, base) {
|
|
289
|
+
const { identities, created, last } = textWrites(batch.changes);
|
|
290
|
+
return batch.changes.map((_, index) => {
|
|
291
|
+
const identity = identities[index];
|
|
292
|
+
if (last.get(identity) !== index)
|
|
293
|
+
return null;
|
|
294
|
+
const made = created.has(identity);
|
|
295
|
+
return { stale: false, content: '', base: made ? null : base, created: made };
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
export function* writtenDocuments(base, batch, composition) {
|
|
299
|
+
const { changes } = batch;
|
|
300
|
+
const { identities, created, last } = textWrites(changes);
|
|
301
|
+
const read = new Map(batch.preconditions.flatMap((precondition) => precondition.kind === 'revision' ? [[precondition.path, precondition.revision]] : []));
|
|
302
|
+
const stale = new Set();
|
|
303
|
+
const refused = new Map();
|
|
304
|
+
const texts = new Map();
|
|
305
|
+
const staged = stagedOf(base);
|
|
306
|
+
yield* stagedBatch(staged, batch, composition, (index, path, unapplied, refusal) => {
|
|
307
|
+
if (!writesText(changes[index]))
|
|
308
|
+
return;
|
|
309
|
+
const identity = identities[index];
|
|
310
|
+
if (unapplied > 0)
|
|
311
|
+
stale.add(identity);
|
|
312
|
+
if (refusal !== undefined && !refused.has(identity))
|
|
313
|
+
refused.set(identity, refusal);
|
|
314
|
+
const text = staged.documents[path];
|
|
315
|
+
if (text !== undefined)
|
|
316
|
+
texts.set(index, text);
|
|
317
|
+
});
|
|
318
|
+
return changes.map((_, index) => {
|
|
319
|
+
const identity = identities[index];
|
|
320
|
+
if (last.get(identity) !== index)
|
|
321
|
+
return null;
|
|
322
|
+
const content = texts.get(index);
|
|
323
|
+
if (content === undefined || stale.has(identity)) {
|
|
324
|
+
const refusal = refused.get(identity);
|
|
325
|
+
return refusal === undefined ? { stale: true } : { stale: true, refusal };
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
stale: false,
|
|
329
|
+
content,
|
|
330
|
+
base: read.get(changes[index].path) ?? read.get(identity) ?? base.revisions[identity] ?? null,
|
|
331
|
+
created: created.has(identity),
|
|
332
|
+
};
|
|
333
|
+
});
|
|
334
|
+
}
|
package/dist/paths.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare function normalize(path: string): string | null;
|
|
2
2
|
export declare function beneath(prefix: string, path: string): boolean;
|
|
3
3
|
export declare function covered(prefixes: readonly string[], path: string): boolean;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function documentAt(patterns: readonly string[], path: string): boolean;
|
|
5
5
|
export declare function ancestors(path: string): readonly string[];
|
|
6
6
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.js
CHANGED
|
@@ -41,7 +41,7 @@ function matched(pattern, path) {
|
|
|
41
41
|
return ((open ? names.length > fixed.length : names.length === fixed.length) &&
|
|
42
42
|
fixed.every((one, at) => named(one, names[at])));
|
|
43
43
|
}
|
|
44
|
-
export function
|
|
44
|
+
export function documentAt(patterns, path) {
|
|
45
45
|
return patterns.some((pattern) => matched(pattern, path));
|
|
46
46
|
}
|
|
47
47
|
export function ancestors(path) {
|
package/dist/queries.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAIL,KAAK,KAAK,EAGV,KAAK,GAAG,EACT,MAAM,WAAW,CAAC;AAMnB,OAAO,EAKL,KAAK,IAAI,EACT,KAAK,WAAW,EAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAa,KAAK,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAEhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,KAAK,EAAa,SAAS,EAAgB,MAAM,YAAY,CAAC;AA4IrE,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAa1E;AAqID,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,E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