@agentshouse/mdruntime-adapter 0.1.0-cdcec0737ac0e → 0.1.0-cdd0cc6758437
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 +2 -2
- package/dist/actions.d.ts +3 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +23 -7
- package/dist/adapter.d.ts +0 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +155 -168
- package/dist/authored-path.d.ts +66 -0
- package/dist/authored-path.d.ts.map +1 -0
- package/dist/authored-path.js +166 -0
- package/dist/chunks.d.ts +36 -0
- package/dist/chunks.d.ts.map +1 -0
- package/dist/chunks.js +281 -0
- package/dist/digest.d.ts +0 -1
- package/dist/discovery.d.ts +27 -10
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +176 -29
- package/dist/history.d.ts +1 -7
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +22 -29
- package/dist/index.d.ts +7 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -7
- package/dist/map.d.ts +0 -1
- package/dist/model.d.ts +5 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +19 -39
- package/dist/read.d.ts +15 -29
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +88 -180
- package/dist/refusal.d.ts +6 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +28 -7
- package/dist/room-query.d.ts +4 -0
- package/dist/room-query.d.ts.map +1 -0
- package/dist/room-query.js +58 -0
- package/dist/search.d.ts +0 -1
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +5 -5
- package/dist/session-content/check.d.ts +17 -0
- package/dist/session-content/index.d.ts +6 -0
- package/dist/session-content/parts.d.ts +30 -0
- package/dist/session-content/state.d.ts +59 -0
- package/dist/session-content/turn.d.ts +137 -0
- package/dist/site.d.ts +0 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +73 -55
- package/dist/space-schema.d.ts +0 -1
- package/dist/space-schema.d.ts.map +1 -1
- package/dist/space-schema.js +1 -8
- package/dist/stream.d.ts +5 -6
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +147 -83
- package/dist/transport.d.ts +54 -30
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +50 -14
- package/dist/uncertain.d.ts +5 -0
- package/dist/uncertain.d.ts.map +1 -0
- package/dist/uncertain.js +11 -0
- package/dist/upload.d.ts +7 -2
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +49 -6
- package/dist/version.d.ts +0 -1
- package/dist/write.d.ts +0 -2
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +30 -32
- package/package.json +3 -2
- package/dist/app-reference.d.ts +0 -2
- package/dist/app-reference.d.ts.map +0 -1
- package/dist/app-reference.js +0 -2
- package/dist/crockford.d.ts +0 -4
- package/dist/crockford.d.ts.map +0 -1
- package/dist/crockford.js +0 -3
- package/dist/house-model.d.ts +0 -719
- package/dist/house-model.d.ts.map +0 -1
- package/dist/house-model.js +0 -393
- package/dist/part.d.ts +0 -14
- package/dist/part.d.ts.map +0 -1
- package/dist/part.js +0 -90
- package/dist/room-stream.d.ts +0 -20
- package/dist/room-stream.d.ts.map +0 -1
- package/dist/room-stream.js +0 -57
- package/dist/room-types.d.ts +0 -7
- package/dist/room-types.d.ts.map +0 -1
- package/dist/room-types.js +0 -123
package/dist/transport.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
+
import { plain, queryKey } from '@agentshouse/mdmodel';
|
|
1
2
|
export const HOUSE_RUNTIME_READS = {
|
|
2
3
|
acts: [
|
|
3
|
-
'account/push',
|
|
4
|
-
'
|
|
4
|
+
'account/push/set',
|
|
5
|
+
'account/time-zone/set',
|
|
5
6
|
'apps/features/set',
|
|
6
7
|
'apps/source/download',
|
|
7
|
-
'apps/source/top',
|
|
8
|
-
'
|
|
9
|
-
'batch-upload',
|
|
10
|
-
'bootstrap',
|
|
11
|
-
'conversations/history',
|
|
12
|
-
'discover',
|
|
8
|
+
'apps/source/top/read',
|
|
9
|
+
'conversations/history/list',
|
|
13
10
|
'files/attach',
|
|
14
11
|
'files/finish',
|
|
15
|
-
'files/
|
|
16
|
-
'revisions',
|
|
17
|
-
'
|
|
12
|
+
'files/read',
|
|
13
|
+
'files/revisions/list',
|
|
14
|
+
'info',
|
|
15
|
+
'room-chunks/list',
|
|
16
|
+
'rooms/discover',
|
|
17
|
+
'rooms/search',
|
|
18
18
|
'sites/screenshot/read',
|
|
19
|
+
'update',
|
|
19
20
|
],
|
|
20
21
|
frames: [
|
|
22
|
+
'agent',
|
|
21
23
|
'app-message',
|
|
24
|
+
'app-rooms',
|
|
22
25
|
'authority_changed',
|
|
23
26
|
'carried',
|
|
24
27
|
'caught_up',
|
|
@@ -30,17 +33,17 @@ export const HOUSE_RUNTIME_READS = {
|
|
|
30
33
|
'deployment',
|
|
31
34
|
'held',
|
|
32
35
|
'interactions',
|
|
33
|
-
'link',
|
|
34
36
|
'message',
|
|
35
37
|
'opening',
|
|
36
38
|
'options',
|
|
37
39
|
'part',
|
|
38
40
|
'process',
|
|
39
41
|
'received',
|
|
42
|
+
'report',
|
|
40
43
|
'signal',
|
|
41
44
|
'site',
|
|
42
45
|
'starting',
|
|
43
|
-
'
|
|
46
|
+
'state',
|
|
44
47
|
'tab-icon',
|
|
45
48
|
'turn',
|
|
46
49
|
],
|
|
@@ -51,6 +54,39 @@ export function houseDoorRoute(act) {
|
|
|
51
54
|
export function houseSiteRoute(act) {
|
|
52
55
|
return `/_house/door/${act}`;
|
|
53
56
|
}
|
|
54
|
-
export const
|
|
57
|
+
export const SITE_QUERY = 'query';
|
|
58
|
+
export const SITE_FRESH_QUERY = 'fresh';
|
|
59
|
+
export const SITE_QUERY_ROUTE_CHARACTERS = 12_000;
|
|
60
|
+
function addressed(text) {
|
|
61
|
+
let binary = '';
|
|
62
|
+
for (const byte of new TextEncoder().encode(text))
|
|
63
|
+
binary += String.fromCharCode(byte);
|
|
64
|
+
return btoa(binary).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/u, '');
|
|
65
|
+
}
|
|
66
|
+
export function siteQueryRoute(room, query, fresh = false) {
|
|
67
|
+
const canonical = queryKey(JSON.parse(JSON.stringify(query)));
|
|
68
|
+
const named = fresh ? SITE_FRESH_QUERY : SITE_QUERY;
|
|
69
|
+
return `${houseSiteRoute('query')}/${room}?${named}=${addressed(canonical)}`;
|
|
70
|
+
}
|
|
71
|
+
export function siteQueryAsked(address) {
|
|
72
|
+
let asked;
|
|
73
|
+
try {
|
|
74
|
+
const binary = atob(address.replaceAll('-', '+').replaceAll('_', '/'));
|
|
75
|
+
const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
76
|
+
asked = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return plain(asked) && addressed(queryKey(asked)) === address ? asked : null;
|
|
82
|
+
}
|
|
83
|
+
export const SITES_SUBMISSIONS_CREATE = 'sites/submissions/create';
|
|
55
84
|
export const SITE_DOOR_SUBMIT = '/_house/door/submit';
|
|
85
|
+
export const SITES_FUNCTIONS_CALL = 'sites/functions/call';
|
|
86
|
+
export const SITE_DOOR_FUNCTION = '/_house/door/function';
|
|
87
|
+
export const SITE_DOOR_ACTS = {
|
|
88
|
+
[SITES_SUBMISSIONS_CREATE]: SITE_DOOR_SUBMIT,
|
|
89
|
+
[SITES_FUNCTIONS_CALL]: SITE_DOOR_FUNCTION,
|
|
90
|
+
};
|
|
56
91
|
export const SITE_FILES = '/_house/files/';
|
|
92
|
+
export const SITE_IMAGE_COPIES_HEADER = 'X-House-Image-Copies';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ProviderRefusal, type TransportUncertainty } from '@agentshouse/mdruntime';
|
|
2
|
+
export declare const UNANSWERED: TransportUncertainty;
|
|
3
|
+
export declare function failedOn(failure: unknown): TransportUncertainty;
|
|
4
|
+
export declare function unusable(): TransportUncertainty;
|
|
5
|
+
export declare function refusedFor(refusal: ProviderRefusal): TransportUncertainty;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uncertain.d.ts","sourceRoot":"","sources":["../src/uncertain.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,UAAU,EAAE,oBAAwD,CAAC;AAElF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,oBAAoB,CAE/D;AAED,wBAAgB,QAAQ,IAAI,oBAAoB,CAE/C;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,oBAAoB,CAEzE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { refusalError, } from '@agentshouse/mdruntime';
|
|
2
|
+
export const UNANSWERED = { kind: 'transport-uncertainty' };
|
|
3
|
+
export function failedOn(failure) {
|
|
4
|
+
return { kind: 'transport-uncertainty', failure };
|
|
5
|
+
}
|
|
6
|
+
export function unusable() {
|
|
7
|
+
return failedOn(new Error());
|
|
8
|
+
}
|
|
9
|
+
export function refusedFor(refusal) {
|
|
10
|
+
return failedOn(refusalError(refusal));
|
|
11
|
+
}
|
package/dist/upload.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TransportUncertainty } from '@agentshouse/mdruntime';
|
|
1
2
|
import { type HouseDoorAnswer, type HouseTransport } from './transport.js';
|
|
2
3
|
export type HouseUpload = {
|
|
3
4
|
readonly id: string;
|
|
@@ -8,5 +9,9 @@ export type HouseUpload = {
|
|
|
8
9
|
}[];
|
|
9
10
|
};
|
|
10
11
|
export declare function houseUpload(value: unknown): HouseUpload | null;
|
|
11
|
-
export declare function finishedUpload(transport: HouseTransport, first: HouseUpload, blob: Blob): Promise<HouseDoorAnswer |
|
|
12
|
-
|
|
12
|
+
export declare function finishedUpload(transport: HouseTransport, first: HouseUpload, blob: Blob): Promise<HouseDoorAnswer | {
|
|
13
|
+
readonly unfinished: number;
|
|
14
|
+
}>;
|
|
15
|
+
type StagedFile = (sha256: unknown) => Promise<Blob> | null;
|
|
16
|
+
export declare function stagedBatch(transport: HouseTransport, body: Readonly<Record<string, unknown>>, file: StagedFile): Promise<HouseDoorAnswer | TransportUncertainty>;
|
|
17
|
+
export {};
|
package/dist/upload.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGpF,OAAO,EAAkB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG3F,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC5E,CAAC;AAeF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAQ9D;AA+BD,wBAAsB,cAAc,CAClC,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,eAAe,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAgB5D;AAED,KAAK,UAAU,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAsB5D,wBAAsB,WAAW,CAC/B,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACvC,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,eAAe,GAAG,oBAAoB,CAAC,CAoBjD"}
|
package/dist/upload.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { sha256 } from '@agentshouse/mdruntime/digest';
|
|
2
|
+
import { answeredFailure, doorRefusal } from './refusal.js';
|
|
2
3
|
import { houseDoorRoute } from './transport.js';
|
|
4
|
+
import { unusable } from './uncertain.js';
|
|
3
5
|
const FINISHING_ROUNDS = 24;
|
|
4
6
|
function record(value) {
|
|
5
7
|
return value !== null && typeof value === 'object' ? value : {};
|
|
@@ -37,17 +39,19 @@ async function sent(transport, upload, blob, digests) {
|
|
|
37
39
|
for (const { part: number, url } of upload.parts) {
|
|
38
40
|
const start = (number - 1) * upload.partBytes;
|
|
39
41
|
const slice = blob.slice(start, start + upload.partBytes);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const stored = await transport.put(url, slice, checksum(digests[number - 1]));
|
|
43
|
+
if (stored !== 200)
|
|
44
|
+
return stored;
|
|
42
45
|
}
|
|
43
|
-
return
|
|
46
|
+
return 200;
|
|
44
47
|
}
|
|
45
48
|
export async function finishedUpload(transport, first, blob) {
|
|
46
49
|
const digests = await partSha256(blob, first.partBytes);
|
|
47
50
|
let upload = first;
|
|
48
51
|
for (let round = 0; round < FINISHING_ROUNDS; round += 1) {
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
const stored = await sent(transport, upload, blob, digests);
|
|
53
|
+
if (stored !== 200)
|
|
54
|
+
return { unfinished: stored };
|
|
51
55
|
const answer = await transport.door(houseDoorRoute('files/finish'), {
|
|
52
56
|
upload: upload.id,
|
|
53
57
|
part_sha256: digests,
|
|
@@ -59,5 +63,44 @@ export async function finishedUpload(transport, first, blob) {
|
|
|
59
63
|
return answer;
|
|
60
64
|
upload = missing;
|
|
61
65
|
}
|
|
62
|
-
return
|
|
66
|
+
return { unfinished: 200 };
|
|
67
|
+
}
|
|
68
|
+
function unstagedRefusal(answer) {
|
|
69
|
+
const refusal = doorRefusal(answer.body);
|
|
70
|
+
return refusal?.code === 'files_unstaged' ? refusal : null;
|
|
71
|
+
}
|
|
72
|
+
async function staged(transport, named, file) {
|
|
73
|
+
const upload = houseUpload(named);
|
|
74
|
+
if (upload === null)
|
|
75
|
+
return unusable();
|
|
76
|
+
const blob = file(record(named).sha256);
|
|
77
|
+
if (blob === null)
|
|
78
|
+
return unusable();
|
|
79
|
+
const sent = await finishedUpload(transport, upload, await blob);
|
|
80
|
+
if ('unfinished' in sent)
|
|
81
|
+
return answeredFailure(sent.unfinished, null);
|
|
82
|
+
if (sent.status !== 200)
|
|
83
|
+
return answeredFailure(sent.status, sent.body);
|
|
84
|
+
return record(sent.body).staged === true ? null : unusable();
|
|
85
|
+
}
|
|
86
|
+
export async function stagedBatch(transport, body, file) {
|
|
87
|
+
let answer = await transport.door(houseDoorRoute('update'), body);
|
|
88
|
+
const finished = new Set();
|
|
89
|
+
for (let unstaged = unstagedRefusal(answer); unstaged !== null; unstaged = unstagedRefusal(answer)) {
|
|
90
|
+
const named = unstaged.fields.upload;
|
|
91
|
+
if (!Array.isArray(named))
|
|
92
|
+
return unusable();
|
|
93
|
+
const fresh = named.filter((upload) => !finished.has(record(upload).id));
|
|
94
|
+
if (fresh.length === 0)
|
|
95
|
+
return answeredFailure(answer.status, answer.body);
|
|
96
|
+
for (const upload of fresh) {
|
|
97
|
+
const staging = await staged(transport, upload, file);
|
|
98
|
+
if (staging !== null)
|
|
99
|
+
return staging;
|
|
100
|
+
}
|
|
101
|
+
for (const upload of fresh)
|
|
102
|
+
finished.add(record(upload).id);
|
|
103
|
+
answer = await transport.door(houseDoorRoute('update'), body);
|
|
104
|
+
}
|
|
105
|
+
return answer;
|
|
63
106
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -14,4 +14,3 @@ export declare function presented(authority: string, at: LogPosition): Presented
|
|
|
14
14
|
export declare const DECIMAL: RegExp;
|
|
15
15
|
export declare function reachedVersion(roomVersion: string, target: string, currentEpoch: string | undefined): boolean;
|
|
16
16
|
export declare function followsVersion(roomVersion: string, next: string): boolean;
|
|
17
|
-
//# sourceMappingURL=version.d.ts.map
|
package/dist/write.d.ts
CHANGED
|
@@ -56,7 +56,5 @@ export declare function revisionBody(input: {
|
|
|
56
56
|
pageToken?: string;
|
|
57
57
|
}): Record<string, unknown>;
|
|
58
58
|
export declare function historyOutcome(status: number, body: unknown, locator: string, request: {
|
|
59
|
-
path: string;
|
|
60
59
|
revision?: string;
|
|
61
60
|
}): HistoryResult;
|
|
62
|
-
//# sourceMappingURL=write.d.ts.map
|
package/dist/write.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAElB,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAElB,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAQlD,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE/D,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,UAAU,CAAC;IAA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ROW_WEIGHT, } from '@agentshouse/mdruntime';
|
|
2
|
-
import { answered, answering,
|
|
2
|
+
import { answered, answering, attachmentOf, headChange, revised } from './read.js';
|
|
3
3
|
import { sha256Hex, textBytes } from './digest.js';
|
|
4
4
|
import { nativePath, roomLocalPath } from './map.js';
|
|
5
|
-
import { classifyDoor, doorRefusal, scopedRefusal } from './refusal.js';
|
|
5
|
+
import { answeredFailure, classifyDoor, doorRefusal, resetOf, scopedRefusal } from './refusal.js';
|
|
6
6
|
import { readPosition, roomVersion } from './version.js';
|
|
7
|
+
import { unusable } from './uncertain.js';
|
|
7
8
|
function priorField(batch, path, name) {
|
|
8
9
|
return batch.preconditions.find((precondition) => precondition.kind === 'field' && precondition.path === path && precondition.name === name);
|
|
9
10
|
}
|
|
@@ -28,7 +29,7 @@ function created(change, path) {
|
|
|
28
29
|
const { type, ...fields } = change.fields;
|
|
29
30
|
if (typeof type !== 'string' || type.length === 0)
|
|
30
31
|
return null;
|
|
31
|
-
return { op: 'create_typed', path, type, fields
|
|
32
|
+
return { op: 'create_typed', path, type, fields };
|
|
32
33
|
}
|
|
33
34
|
function operationOf(batch, change, handle) {
|
|
34
35
|
const path = nativePath(change.path, handle);
|
|
@@ -181,7 +182,7 @@ function* material(value, handle, within = () => true) {
|
|
|
181
182
|
return null;
|
|
182
183
|
if (file.revision !== null && file.revision !== undefined && typeof file.revision !== 'string')
|
|
183
184
|
return null;
|
|
184
|
-
const binary =
|
|
185
|
+
const binary = attachmentOf(file);
|
|
185
186
|
if (binary === null)
|
|
186
187
|
return null;
|
|
187
188
|
const head = headChange(file);
|
|
@@ -224,14 +225,14 @@ function* acceptedOf(at, contents) {
|
|
|
224
225
|
if (entry.content !== null)
|
|
225
226
|
answer.documents.set(entry.path, entry.content);
|
|
226
227
|
if (entry.binary !== undefined)
|
|
227
|
-
answer.
|
|
228
|
+
answer.attachments.set(entry.path, entry.binary);
|
|
228
229
|
revised(answer, entry.path, entry.revision);
|
|
229
230
|
if (entry.head !== undefined)
|
|
230
231
|
answer.changes.set(entry.path, entry.head);
|
|
231
232
|
}
|
|
232
|
-
const unbinaried = answer.
|
|
233
|
-
const {
|
|
234
|
-
return { roomVersion: roomVersion(at), ...room, ...(unbinaried ? {} : {
|
|
233
|
+
const unbinaried = answer.attachments.size === 0;
|
|
234
|
+
const { attachments, facts: _facts, ...room } = yield* answered(answer);
|
|
235
|
+
return { roomVersion: roomVersion(at), ...room, ...(unbinaried ? {} : { attachments }) };
|
|
235
236
|
}
|
|
236
237
|
function* movedOutcome(held, move) {
|
|
237
238
|
const authorities = Array.isArray(held.authorities) ? held.authorities : [];
|
|
@@ -244,12 +245,12 @@ function* movedOutcome(held, move) {
|
|
|
244
245
|
const left = at(move.source.authority);
|
|
245
246
|
const arrived = at(move.destination.authority);
|
|
246
247
|
if (left === null || arrived === null)
|
|
247
|
-
return
|
|
248
|
+
return unusable();
|
|
248
249
|
const under = (handle) => (path) => path.startsWith(`/rooms/${handle}/`);
|
|
249
250
|
const leaving = yield* material(held.contents, move.source.handle, under(move.source.handle));
|
|
250
251
|
const arriving = yield* material(held.contents, move.destination.handle, under(move.destination.handle));
|
|
251
252
|
if (leaving === null || arriving === null)
|
|
252
|
-
return
|
|
253
|
+
return unusable();
|
|
253
254
|
return {
|
|
254
255
|
kind: 'accepted',
|
|
255
256
|
...(yield* acceptedOf(left, leaving)),
|
|
@@ -276,10 +277,8 @@ export function* mutationOutcome(status, body, locator, handle, move) {
|
|
|
276
277
|
return scopedRefusal(locator, 'undisclosed', refusal);
|
|
277
278
|
}
|
|
278
279
|
const classified = classifyDoor(status, body, locator);
|
|
279
|
-
const reset = refusal
|
|
280
|
-
if (refusal?.
|
|
281
|
-
typeof reset === 'string' &&
|
|
282
|
-
classified?.kind === 'transport-uncertainty') {
|
|
280
|
+
const reset = resetOf(refusal);
|
|
281
|
+
if (refusal !== null && reset !== undefined && classified?.kind === 'transport-uncertainty') {
|
|
283
282
|
return {
|
|
284
283
|
kind: 'retryable-refusal',
|
|
285
284
|
code: refusal.code,
|
|
@@ -302,18 +301,19 @@ export function* mutationOutcome(status, body, locator, handle, move) {
|
|
|
302
301
|
retryable: refusal.retryable,
|
|
303
302
|
};
|
|
304
303
|
}
|
|
305
|
-
if (status !== 200
|
|
306
|
-
return
|
|
307
|
-
|
|
304
|
+
if (status !== 200)
|
|
305
|
+
return answeredFailure(status, body);
|
|
306
|
+
if (typeof body !== 'object' || body === null)
|
|
307
|
+
return unusable();
|
|
308
308
|
const held = body;
|
|
309
309
|
if (move !== undefined)
|
|
310
310
|
return yield* movedOutcome(held, move);
|
|
311
311
|
const at = readPosition(held);
|
|
312
312
|
if (at === null)
|
|
313
|
-
return
|
|
313
|
+
return unusable();
|
|
314
314
|
const contents = yield* material(held.contents, handle);
|
|
315
315
|
if (contents === null)
|
|
316
|
-
return
|
|
316
|
+
return unusable();
|
|
317
317
|
return { kind: 'accepted', ...(yield* acceptedOf(at, contents)) };
|
|
318
318
|
}
|
|
319
319
|
export function rejectedMapping(mapping) {
|
|
@@ -362,25 +362,23 @@ export function historyOutcome(status, body, locator, request) {
|
|
|
362
362
|
if (classified !== null)
|
|
363
363
|
return classified;
|
|
364
364
|
if (status !== 200 || typeof body !== 'object' || body === null) {
|
|
365
|
-
return
|
|
365
|
+
return unusable();
|
|
366
366
|
}
|
|
367
367
|
const held = body;
|
|
368
368
|
if (!Array.isArray(held.revisions))
|
|
369
|
-
return
|
|
369
|
+
return unusable();
|
|
370
370
|
const entries = [];
|
|
371
371
|
for (const entry of held.revisions) {
|
|
372
372
|
if (typeof entry !== 'object' || entry === null)
|
|
373
|
-
return
|
|
373
|
+
return unusable();
|
|
374
374
|
entries.push(entry);
|
|
375
375
|
}
|
|
376
|
-
|
|
377
|
-
|
|
376
|
+
const named = entries[0];
|
|
377
|
+
if (request.revision !== undefined && typeof named?.media_type !== 'string') {
|
|
378
378
|
if (named === undefined)
|
|
379
379
|
return { kind: 'no-history' };
|
|
380
|
-
if (typeof named.media_type === 'string')
|
|
381
|
-
return { kind: 'no-history' };
|
|
382
380
|
if (typeof named.content !== 'string')
|
|
383
|
-
return
|
|
381
|
+
return unusable();
|
|
384
382
|
return { kind: 'revision', content: named.content };
|
|
385
383
|
}
|
|
386
384
|
if (entries.length === 0)
|
|
@@ -391,16 +389,16 @@ export function historyOutcome(status, body, locator, request) {
|
|
|
391
389
|
if (typeof entry.revision !== 'string' ||
|
|
392
390
|
author === null ||
|
|
393
391
|
typeof entry.created_at !== 'string') {
|
|
394
|
-
return
|
|
392
|
+
return unusable();
|
|
395
393
|
}
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
398
|
-
return
|
|
394
|
+
const attachment = attachmentOf(entry);
|
|
395
|
+
if (attachment === null)
|
|
396
|
+
return unusable();
|
|
399
397
|
revisions.push({
|
|
400
398
|
revision: entry.revision,
|
|
401
399
|
author,
|
|
402
400
|
time: entry.created_at,
|
|
403
|
-
...(
|
|
401
|
+
...(attachment === undefined ? {} : { attachment }),
|
|
404
402
|
});
|
|
405
403
|
}
|
|
406
404
|
const next = held.next_before;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdruntime-adapter",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-cdd0cc6758437",
|
|
4
4
|
"description": "Agents House Adapter for the MD Runtime",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"LICENSE"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@agentshouse/
|
|
27
|
+
"@agentshouse/mdmodel": "0.1.0-c91b41b1477d7",
|
|
28
|
+
"@agentshouse/mdruntime": "0.1.0-c3b445fa731c0"
|
|
28
29
|
},
|
|
29
30
|
"repository": {
|
|
30
31
|
"type": "git",
|
package/dist/app-reference.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-reference.d.ts","sourceRoot":"","sources":["../src/app-reference.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,QAEjC,CAAC"}
|
package/dist/app-reference.js
DELETED
package/dist/crockford.d.ts
DELETED
package/dist/crockford.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crockford.d.ts","sourceRoot":"","sources":["../src/crockford.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAErE,eAAO,MAAM,mBAAmB,uCAA4B,CAAC;AAE7D,eAAO,MAAM,2BAA2B,QAAqC,CAAC"}
|
package/dist/crockford.js
DELETED