@agentshouse/mdruntime-adapter 0.1.0-c8d322eea4abd → 0.1.0-c8d6935639fda
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/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +7 -7
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +62 -49
- package/dist/authored-path.d.ts +0 -1
- package/dist/authored-path.d.ts.map +1 -1
- package/dist/authored-path.js +2 -3
- package/dist/chunks.d.ts +2 -3
- package/dist/chunks.d.ts.map +1 -1
- package/dist/chunks.js +71 -37
- package/dist/discovery.d.ts +16 -5
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +127 -6
- package/dist/history.d.ts +1 -6
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +21 -28
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -6
- package/dist/model.d.ts +5 -5
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +17 -27
- package/dist/read.d.ts +5 -19
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +34 -35
- package/dist/refusal.d.ts +2 -1
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +12 -6
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +4 -4
- package/dist/session-content/index.d.ts +1 -1
- package/dist/session-content/parts.d.ts +4 -3
- package/dist/session-content/turn.d.ts +3 -3
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +15 -17
- package/dist/space-schema.d.ts.map +1 -1
- package/dist/space-schema.js +1 -8
- package/dist/stream.d.ts +2 -3
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +79 -72
- package/dist/transport.d.ts +28 -11
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +3 -1
- 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 +3 -1
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +8 -6
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +17 -15
- package/package.json +3 -2
- package/dist/app-reference.d.ts +0 -1
- package/dist/app-reference.d.ts.map +0 -1
- package/dist/app-reference.js +0 -2
- package/dist/crockford.d.ts +0 -3
- package/dist/crockford.d.ts.map +0 -1
- package/dist/crockford.js +0 -3
- package/dist/house-model.d.ts +0 -697
- package/dist/house-model.d.ts.map +0 -1
- package/dist/house-model.js +0 -405
- package/dist/room-types.d.ts +0 -4
- package/dist/room-types.d.ts.map +0 -1
- package/dist/room-types.js +0 -120
package/dist/read.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { patching, ROW_WEIGHT, } from '@agentshouse/mdruntime';
|
|
2
|
+
import { REVISION_REFERENCE_PATTERN } from '@agentshouse/mdmodel';
|
|
2
3
|
import { roomVersion } from './version.js';
|
|
3
|
-
const REVISION_FILE = /^fr_([0-9a-z]+)\.[0-9a-z]+\.[0-9a-z]$/u;
|
|
4
4
|
function fileOf(revision) {
|
|
5
|
-
return
|
|
5
|
+
return REVISION_REFERENCE_PATTERN.exec(revision)?.[1];
|
|
6
6
|
}
|
|
7
7
|
export function answering() {
|
|
8
8
|
return {
|
|
@@ -129,7 +129,7 @@ export function headChange(held) {
|
|
|
129
129
|
return null;
|
|
130
130
|
return { author, time: held.changed_at };
|
|
131
131
|
}
|
|
132
|
-
|
|
132
|
+
function createdOf(held) {
|
|
133
133
|
if (held.created_at === undefined)
|
|
134
134
|
return undefined;
|
|
135
135
|
return typeof held.created_at === 'string' ? held.created_at : null;
|
|
@@ -151,23 +151,26 @@ export function binaryFileOf(held) {
|
|
|
151
151
|
function binaried(binary) {
|
|
152
152
|
return binary === undefined ? {} : { binary };
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
function carriedFacts(held) {
|
|
155
155
|
return held.facts === undefined ? {} : { facts: held.facts };
|
|
156
156
|
}
|
|
157
157
|
function carriedSpace(held) {
|
|
158
158
|
return typeof held.space === 'string' ? { space: held.space } : {};
|
|
159
159
|
}
|
|
160
|
-
export function
|
|
160
|
+
export function documentEntry(value, mode) {
|
|
161
161
|
if (typeof value !== 'object' || value === null)
|
|
162
162
|
return null;
|
|
163
163
|
const file = value;
|
|
164
164
|
if (typeof file.path !== 'string')
|
|
165
165
|
return null;
|
|
166
|
+
if (file.content !== undefined && typeof file.content !== 'string')
|
|
167
|
+
return null;
|
|
166
168
|
const head = headChange(file);
|
|
167
169
|
const created = createdOf(file);
|
|
168
170
|
const binary = binaryFileOf(file);
|
|
169
171
|
if (head === null || created === null || binary === null)
|
|
170
172
|
return null;
|
|
173
|
+
const content = file.content === undefined ? {} : { content: file.content };
|
|
171
174
|
if (mode === 'site') {
|
|
172
175
|
if (typeof file.sha256 !== 'string')
|
|
173
176
|
return null;
|
|
@@ -178,6 +181,7 @@ export function parseFile(value, mode) {
|
|
|
178
181
|
...headed(head),
|
|
179
182
|
...binaried(binary),
|
|
180
183
|
...carriedFacts(file),
|
|
184
|
+
...content,
|
|
181
185
|
};
|
|
182
186
|
}
|
|
183
187
|
if (typeof file.revision !== 'string')
|
|
@@ -186,64 +190,59 @@ export function parseFile(value, mode) {
|
|
|
186
190
|
path: file.path,
|
|
187
191
|
revision: file.revision,
|
|
188
192
|
version: file.revision,
|
|
189
|
-
...(typeof file.sha256 === 'string' ? { sha256: file.sha256 } : {}),
|
|
190
193
|
...headed(head),
|
|
191
194
|
...createdHeld(created),
|
|
192
195
|
...binaried(binary),
|
|
193
196
|
...carriedFacts(file),
|
|
194
197
|
...carriedSpace(file),
|
|
198
|
+
...content,
|
|
195
199
|
};
|
|
196
200
|
}
|
|
201
|
+
export function kept(answer, file) {
|
|
202
|
+
if (file.head !== undefined)
|
|
203
|
+
answer.changes.set(file.path, file.head);
|
|
204
|
+
if (file.created !== undefined)
|
|
205
|
+
answer.created.set(file.path, file.created);
|
|
206
|
+
if (file.binary !== undefined)
|
|
207
|
+
answer.binaryFiles.set(file.path, file.binary);
|
|
208
|
+
else if (file.content !== undefined)
|
|
209
|
+
answer.documents.set(file.path, file.content);
|
|
210
|
+
if (file.binary === undefined && file.facts !== undefined)
|
|
211
|
+
answer.facts.set(file.path, file.facts);
|
|
212
|
+
if (file.revision !== undefined)
|
|
213
|
+
revised(answer, file.path, file.revision);
|
|
214
|
+
}
|
|
197
215
|
export function modelScope(room) {
|
|
198
216
|
return {
|
|
199
217
|
anchor: room.anchor,
|
|
200
218
|
position: room.position,
|
|
201
219
|
logEpoch: room.logEpoch,
|
|
202
|
-
files: room.models
|
|
203
|
-
contents: room.models.contents,
|
|
220
|
+
files: room.models,
|
|
204
221
|
};
|
|
205
222
|
}
|
|
206
223
|
export function* bootstrapping(scope) {
|
|
207
|
-
const contents = new Map();
|
|
208
|
-
for (const entry of scope.contents) {
|
|
209
|
-
contents.set(entry.path, entry.content);
|
|
210
|
-
yield ROW_WEIGHT;
|
|
211
|
-
}
|
|
212
224
|
const answer = answering();
|
|
213
225
|
for (const file of scope.files) {
|
|
214
226
|
yield ROW_WEIGHT;
|
|
215
|
-
if (file.space
|
|
216
|
-
|
|
217
|
-
if (file.head !== undefined)
|
|
218
|
-
answer.changes.set(file.path, file.head);
|
|
219
|
-
if (file.created !== undefined)
|
|
220
|
-
answer.created.set(file.path, file.created);
|
|
221
|
-
const content = contents.get(file.path);
|
|
222
|
-
if (file.binary !== undefined)
|
|
223
|
-
answer.binaryFiles.set(file.path, file.binary);
|
|
224
|
-
else if (content !== undefined)
|
|
225
|
-
answer.documents.set(file.path, content);
|
|
226
|
-
if (file.binary === undefined && file.facts !== undefined)
|
|
227
|
-
answer.facts.set(file.path, file.facts);
|
|
228
|
-
if (file.revision !== undefined)
|
|
229
|
-
revised(answer, file.path, file.revision);
|
|
227
|
+
if (file.space === undefined)
|
|
228
|
+
kept(answer, file);
|
|
230
229
|
}
|
|
231
230
|
for (const folder of scope.folders ?? [])
|
|
232
231
|
folded(answer, folder, false);
|
|
233
232
|
const { removals: _removals, folderRemovals: _folderRemovals, ...page } = yield* answered(answer);
|
|
234
233
|
return { kind: 'bootstrap', roomVersion: roomVersion(scope), ...page };
|
|
235
234
|
}
|
|
236
|
-
export function
|
|
237
|
-
|
|
238
|
-
if (file === undefined)
|
|
239
|
-
return { schema: null, version: null, revision: null };
|
|
240
|
-
const content = scope.contents.find((entry) => entry.path === schema);
|
|
241
|
-
return content === undefined
|
|
235
|
+
export function schemaFile(file) {
|
|
236
|
+
return file.content === undefined
|
|
242
237
|
? null
|
|
243
238
|
: {
|
|
244
|
-
schema:
|
|
239
|
+
schema: file.content,
|
|
245
240
|
version: file.version,
|
|
246
241
|
revision: file.revision ?? null,
|
|
247
242
|
...(file.space === undefined ? {} : { space: file.space }),
|
|
248
243
|
};
|
|
249
244
|
}
|
|
245
|
+
export function schemaOf(scope, schema) {
|
|
246
|
+
const file = scope.files.find((entry) => entry.path === schema);
|
|
247
|
+
return file === undefined ? { schema: null, version: null, revision: null } : schemaFile(file);
|
|
248
|
+
}
|
package/dist/refusal.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { AdapterFailure, DiscoverResult, ProviderRefusal, ScopedRefusal } from '@agentshouse/mdruntime';
|
|
1
|
+
import type { AdapterFailure, DiscoverResult, ProviderRefusal, ScopedRefusal, TransportUncertainty } from '@agentshouse/mdruntime';
|
|
2
2
|
export declare function doorRefusal(body: unknown): ProviderRefusal | null;
|
|
3
|
+
export declare function answeredFailure(status: number, body: unknown): TransportUncertainty;
|
|
3
4
|
export declare function resetOf(refusal: ProviderRefusal | null): string | undefined;
|
|
4
5
|
export declare function scopedRefusal(locator: string, scope: ScopedRefusal['scope'], refusal: ProviderRefusal): ScopedRefusal;
|
|
5
6
|
export declare function classifyDoor(status: number, body: unknown, locator: string): AdapterFailure | null;
|
package/dist/refusal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACb,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAGhC,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAOjE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,oBAAoB,CAInF;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAG3E;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,EAC7B,OAAO,EAAE,eAAe,GACvB,aAAa,CAEf;AAoBD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,GACd,cAAc,GAAG,IAAI,CAMvB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAQrF"}
|
package/dist/refusal.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refusedFor, UNANSWERED, unusable } from './uncertain.js';
|
|
1
2
|
export function doorRefusal(body) {
|
|
2
3
|
if (typeof body !== 'object' || body === null)
|
|
3
4
|
return null;
|
|
@@ -9,6 +10,12 @@ export function doorRefusal(body) {
|
|
|
9
10
|
const { code, retryable, ...fields } = error;
|
|
10
11
|
return { code, fields, retryable: retryable === true };
|
|
11
12
|
}
|
|
13
|
+
export function answeredFailure(status, body) {
|
|
14
|
+
const refusal = doorRefusal(body);
|
|
15
|
+
if (refusal !== null)
|
|
16
|
+
return refusedFor(refusal);
|
|
17
|
+
return status === 0 || (status >= 500 && body === null) ? UNANSWERED : unusable();
|
|
18
|
+
}
|
|
12
19
|
export function resetOf(refusal) {
|
|
13
20
|
const reset = refusal?.fields.retry_at;
|
|
14
21
|
return refusal?.retryable === true && typeof reset === 'string' ? reset : undefined;
|
|
@@ -18,19 +25,18 @@ export function scopedRefusal(locator, scope, refusal) {
|
|
|
18
25
|
}
|
|
19
26
|
function doorFailure(status, body) {
|
|
20
27
|
if (status === 0)
|
|
21
|
-
return
|
|
28
|
+
return UNANSWERED;
|
|
22
29
|
if (status === 401)
|
|
23
30
|
return { kind: 'revoked-authorization' };
|
|
24
31
|
const refusal = doorRefusal(body);
|
|
25
|
-
if (refusal?.retryable === true || refusal?.code === 'update_required')
|
|
26
|
-
return
|
|
27
|
-
}
|
|
32
|
+
if (refusal?.retryable === true || refusal?.code === 'update_required')
|
|
33
|
+
return refusedFor(refusal);
|
|
28
34
|
if (status === 404 || refusal?.code === 'room_not_found')
|
|
29
35
|
return { kind: 'room-not-readable' };
|
|
30
36
|
if (status < 400)
|
|
31
37
|
return null;
|
|
32
38
|
if (refusal === null)
|
|
33
|
-
return
|
|
39
|
+
return answeredFailure(status, body);
|
|
34
40
|
return { kind: 'refused', scope: status === 403 ? 'operation' : 'undisclosed', refusal };
|
|
35
41
|
}
|
|
36
42
|
export function classifyDoor(status, body, locator) {
|
|
@@ -52,5 +58,5 @@ export function discoveryFailure(status, body) {
|
|
|
52
58
|
if (failure.kind === 'refused') {
|
|
53
59
|
return { kind: 'contract-unavailable', ...failure.refusal };
|
|
54
60
|
}
|
|
55
|
-
return
|
|
61
|
+
return failure.kind === 'transport-uncertainty' ? failure : answeredFailure(status, body);
|
|
56
62
|
}
|
package/dist/search.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAa,MAAM,wBAAwB,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAa,MAAM,wBAAwB,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAoBrE,wBAAsB,WAAW,CAC/B,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,EACvC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,OAAO,EAAE,SAAS,GACjB,OAAO,CAAC,YAAY,CAAC,CAsBvB"}
|
package/dist/search.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { doorRefusal } from './refusal.js';
|
|
1
|
+
import { answeredFailure, doorRefusal } from './refusal.js';
|
|
2
2
|
import { houseDoorRoute } from './transport.js';
|
|
3
3
|
const ROOMS = '/rooms/';
|
|
4
|
-
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
5
4
|
function hitOf(file, locators) {
|
|
6
5
|
if (typeof file !== 'object' || file === null)
|
|
7
6
|
return null;
|
|
@@ -37,8 +36,9 @@ export async function houseSearch(transport, tracked, request) {
|
|
|
37
36
|
if (refusal !== null)
|
|
38
37
|
return { kind: 'rejected', ...refusal };
|
|
39
38
|
const files = answer.body?.files;
|
|
40
|
-
if (answer.status !== 200 || !Array.isArray(files))
|
|
41
|
-
return
|
|
39
|
+
if (answer.status !== 200 || !Array.isArray(files)) {
|
|
40
|
+
return answeredFailure(answer.status, answer.body);
|
|
41
|
+
}
|
|
42
42
|
const locators = new Map(tracked.map((entry) => [entry.handle, entry.locator]));
|
|
43
43
|
return {
|
|
44
44
|
kind: 'found',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { DIFF_CHARACTERS, FIRST_PART_CHARACTERS, firstPart, keptDiff, lastLines, OUTPUT_CHARACTERS, OUTPUT_LINES, } from './bounds.js';
|
|
2
2
|
export { isOwn, isPart } from './parts.js';
|
|
3
|
-
export type { Call, FileChange, Part, Status } from './parts.js';
|
|
3
|
+
export type { Call, FileChange, Part, PartOf, Status } from './parts.js';
|
|
4
4
|
export { isState, standingState } from './state.js';
|
|
5
5
|
export type { SessionState, Tokens } from './state.js';
|
|
6
6
|
export { applied, isOperation, isTurn } from './turn.js';
|
|
@@ -66,7 +66,7 @@ declare const PART: Check<import("./check.js").Shaped<{
|
|
|
66
66
|
}> | import("./check.js").Shaped<{
|
|
67
67
|
readonly type: Check<"message">;
|
|
68
68
|
readonly parent: Check<number | null>;
|
|
69
|
-
readonly command: Check<
|
|
69
|
+
readonly command: Check<"agent-functions/cancel" | "agent-functions/mail/send" | "agent-functions/send">;
|
|
70
70
|
readonly target: Check<string | null>;
|
|
71
71
|
}> | import("./check.js").Shaped<{
|
|
72
72
|
readonly type: Check<"image">;
|
|
@@ -94,9 +94,10 @@ declare const PART: Check<import("./check.js").Shaped<{
|
|
|
94
94
|
readonly status: Check<"done" | "failed" | "running" | "stopped">;
|
|
95
95
|
}>>;
|
|
96
96
|
export type Part = Checked<typeof PART>;
|
|
97
|
-
export type
|
|
98
|
-
readonly type:
|
|
97
|
+
export type PartOf<T extends Part['type']> = Extract<Part, {
|
|
98
|
+
readonly type: T;
|
|
99
99
|
}>;
|
|
100
|
+
export type Call = PartOf<'call'>;
|
|
100
101
|
export declare const isPart: Check<Part>;
|
|
101
102
|
export declare function isOwn(part: Part): boolean;
|
|
102
103
|
export {};
|
|
@@ -60,7 +60,7 @@ declare const OPERATION: Check<import("./check.js").Shaped<{
|
|
|
60
60
|
}> | import("./check.js").Shaped<{
|
|
61
61
|
readonly type: Check<"message">;
|
|
62
62
|
readonly parent: Check<number | null>;
|
|
63
|
-
readonly command: Check<
|
|
63
|
+
readonly command: Check<"agent-functions/cancel" | "agent-functions/mail/send" | "agent-functions/send">;
|
|
64
64
|
readonly target: Check<string | null>;
|
|
65
65
|
}> | import("./check.js").Shaped<{
|
|
66
66
|
readonly type: Check<"image">;
|
|
@@ -151,7 +151,7 @@ declare const OPERATION: Check<import("./check.js").Shaped<{
|
|
|
151
151
|
}> | import("./check.js").Shaped<{
|
|
152
152
|
readonly type: Check<"message">;
|
|
153
153
|
readonly parent: Check<number | null>;
|
|
154
|
-
readonly command: Check<
|
|
154
|
+
readonly command: Check<"agent-functions/cancel" | "agent-functions/mail/send" | "agent-functions/send">;
|
|
155
155
|
readonly target: Check<string | null>;
|
|
156
156
|
}> | import("./check.js").Shaped<{
|
|
157
157
|
readonly type: Check<"image">;
|
|
@@ -239,7 +239,7 @@ declare const TURN: Check<import("./check.js").Shaped<{
|
|
|
239
239
|
}> | import("./check.js").Shaped<{
|
|
240
240
|
readonly type: Check<"message">;
|
|
241
241
|
readonly parent: Check<number | null>;
|
|
242
|
-
readonly command: Check<
|
|
242
|
+
readonly command: Check<"agent-functions/cancel" | "agent-functions/mail/send" | "agent-functions/send">;
|
|
243
243
|
readonly target: Check<string | null>;
|
|
244
244
|
}> | import("./check.js").Shaped<{
|
|
245
245
|
readonly type: Check<"image">;
|
package/dist/site.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OAAO,EAQR,MAAM,wBAAwB,CAAC;AAahC,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAwBxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,UAAQ,GAAG,OAAO,CA2J1F"}
|
package/dist/site.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
+
import { HOUSE_ROOM_TYPES, HOUSE_TYPED_PATHS } from '@agentshouse/mdmodel';
|
|
1
2
|
import { actionOutcome } from './actions.js';
|
|
2
3
|
import { chunkedHead, chunkPart, siteChunkList } from './chunks.js';
|
|
3
4
|
import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteTracked, } from './discovery.js';
|
|
4
|
-
import {
|
|
5
|
-
import { discoveryFailure } from './refusal.js';
|
|
5
|
+
import { answeredFailure, discoveryFailure } from './refusal.js';
|
|
6
6
|
import { admittedPath } from './authored-path.js';
|
|
7
|
-
import { HOUSE_TYPED_PATHS } from './house-model.js';
|
|
8
|
-
import { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES } from './room-types.js';
|
|
9
7
|
import { houseNotifications } from './stream.js';
|
|
10
8
|
import { houseSiteRoute, SITE_DOOR_SUBMIT, SITE_FILES, SITES_SUBMISSIONS_CREATE, } from './transport.js';
|
|
9
|
+
import { UNANSWERED, unusable } from './uncertain.js';
|
|
11
10
|
import { followsVersion, reachedVersion, roomVersion } from './version.js';
|
|
12
|
-
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
13
11
|
function unfound() {
|
|
14
12
|
return { kind: 'rejected', code: 'not_found', fields: {}, retryable: false };
|
|
15
13
|
}
|
|
@@ -27,14 +25,13 @@ function siteRoom(tracked) {
|
|
|
27
25
|
};
|
|
28
26
|
}
|
|
29
27
|
export function createSiteAdapter(transport, snapshot = false) {
|
|
30
|
-
const spaces = spaceSchemas();
|
|
31
28
|
const notifications = houseNotifications(transport, 'site', {
|
|
32
29
|
opened: async () => {
|
|
33
30
|
const found = await discovered();
|
|
34
31
|
return found.kind === 'discovery' ? found : null;
|
|
35
32
|
},
|
|
36
33
|
changed: () => null,
|
|
37
|
-
}
|
|
34
|
+
});
|
|
38
35
|
const tracked = new Map();
|
|
39
36
|
const chunked = new Map();
|
|
40
37
|
function fileRoute(request) {
|
|
@@ -48,7 +45,7 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
48
45
|
const listed = siteChunkList(await transport.read(`${houseSiteRoute('chunks')}/${entry.authority}${past === undefined ? '' : `?expired=${past}`}`), entry.locator);
|
|
49
46
|
if ('kind' in listed)
|
|
50
47
|
return listed;
|
|
51
|
-
const head = await chunkedHead(listed, entry
|
|
48
|
+
const head = await chunkedHead(listed, entry);
|
|
52
49
|
if (head.kind === 'bootstrap')
|
|
53
50
|
chunked.set(entry.locator, listed);
|
|
54
51
|
return head;
|
|
@@ -57,10 +54,10 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
57
54
|
const room = chunked.get(entry.locator);
|
|
58
55
|
const address = room?.chunks.get(id);
|
|
59
56
|
if (room === undefined || address === undefined)
|
|
60
|
-
return
|
|
57
|
+
return UNANSWERED;
|
|
61
58
|
const read = await transport.download(address.url);
|
|
62
59
|
if (read.status !== 200)
|
|
63
|
-
return
|
|
60
|
+
return answeredFailure(read.status, null);
|
|
64
61
|
return chunkPart(read.body, room, id, arriving);
|
|
65
62
|
}
|
|
66
63
|
async function discovered() {
|
|
@@ -70,7 +67,7 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
70
67
|
return failed;
|
|
71
68
|
const document = parseSiteDiscovery(answer.body);
|
|
72
69
|
if (document === null)
|
|
73
|
-
return
|
|
70
|
+
return unusable();
|
|
74
71
|
const entries = siteTracked(document);
|
|
75
72
|
tracked.clear();
|
|
76
73
|
for (const entry of entries)
|
|
@@ -81,7 +78,6 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
81
78
|
return {
|
|
82
79
|
localSaves: true,
|
|
83
80
|
roomTypes: HOUSE_ROOM_TYPES,
|
|
84
|
-
nameableRoomTypes: HOUSE_NAMEABLE_ROOM_TYPES,
|
|
85
81
|
typedPaths: HOUSE_TYPED_PATHS,
|
|
86
82
|
pathRule: admittedPath,
|
|
87
83
|
async authorize() {
|
|
@@ -103,7 +99,7 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
103
99
|
if (entry === undefined)
|
|
104
100
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
105
101
|
if (request.pageToken !== undefined)
|
|
106
|
-
return
|
|
102
|
+
return UNANSWERED;
|
|
107
103
|
return request.fromRoomVersion === roomVersion(entry)
|
|
108
104
|
? { kind: 'still-current' }
|
|
109
105
|
: { kind: 'beyond-horizon' };
|
|
@@ -126,9 +122,11 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
126
122
|
const read = await transport.download(route);
|
|
127
123
|
if (read.status === 404)
|
|
128
124
|
return unfound();
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
125
|
+
if (read.status !== 200)
|
|
126
|
+
return answeredFailure(read.status, null);
|
|
127
|
+
if (read.body === null)
|
|
128
|
+
return unusable();
|
|
129
|
+
return { kind: 'binary', body: read.body, mediaType: read.mediaType };
|
|
132
130
|
},
|
|
133
131
|
async link(_authorization, request) {
|
|
134
132
|
const route = fileRoute(request);
|
|
@@ -156,7 +154,7 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
156
154
|
};
|
|
157
155
|
}
|
|
158
156
|
if (!transport.online())
|
|
159
|
-
return
|
|
157
|
+
return UNANSWERED;
|
|
160
158
|
return actionOutcome(await transport.door(SITE_DOOR_SUBMIT, request.input), SITES_SUBMISSIONS_CREATE, request.input);
|
|
161
159
|
},
|
|
162
160
|
roomStream: snapshot
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space-schema.d.ts","sourceRoot":"","sources":["../src/space-schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"space-schema.d.ts","sourceRoot":"","sources":["../src/space-schema.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC1D,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3D,CAAC;AAEF,wBAAgB,YAAY,IAAI,YAAY,CAO3C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
package/dist/space-schema.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
const HELD_TEXTS = 16;
|
|
2
1
|
export function spaceSchemas() {
|
|
3
2
|
const texts = new Map();
|
|
4
3
|
const key = (space, revision) => `${space} ${revision}`;
|
|
5
4
|
return {
|
|
6
5
|
held: (space, revision) => texts.get(key(space, revision)),
|
|
7
|
-
keep(space, revision, text)
|
|
8
|
-
const named = key(space, revision);
|
|
9
|
-
texts.delete(named);
|
|
10
|
-
texts.set(named, text);
|
|
11
|
-
if (texts.size > HELD_TEXTS)
|
|
12
|
-
texts.delete(texts.keys().next().value);
|
|
13
|
-
},
|
|
6
|
+
keep: (space, revision, text) => void texts.set(key(space, revision), text),
|
|
14
7
|
};
|
|
15
8
|
}
|
|
16
9
|
export function spaceIdentity(space) {
|
package/dist/stream.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type AuthorityChange, type Discovery, type ConversationStream, type HeldRoom, type RoomStreamEvent, type ServiceModeSignal } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
|
-
import type { SpaceSchemas } from './space-schema.js';
|
|
4
3
|
import { type HouseDoor, type HouseMode, type HouseStreamFrame } from './transport.js';
|
|
5
4
|
export type HouseOpeningFrame = Extract<HouseStreamFrame, {
|
|
6
5
|
type: 'opening';
|
|
@@ -11,7 +10,7 @@ export type HouseAuthorityChangedFrame = Extract<HouseStreamFrame, {
|
|
|
11
10
|
export type HouseDiscovering = {
|
|
12
11
|
opened(frame: HouseOpeningFrame | null): Promise<Discovery | null>;
|
|
13
12
|
changed(frame: HouseAuthorityChangedFrame): AuthorityChange | null;
|
|
14
|
-
expired?(
|
|
13
|
+
expired?(entries: readonly TrackedAuthority[]): void;
|
|
15
14
|
};
|
|
16
15
|
export type HouseNotifications = {
|
|
17
16
|
runtime: string;
|
|
@@ -21,4 +20,4 @@ export type HouseNotifications = {
|
|
|
21
20
|
conversations: ConversationStream;
|
|
22
21
|
serviceMode: ServiceModeSignal;
|
|
23
22
|
};
|
|
24
|
-
export declare function houseNotifications(transport: HouseDoor, mode: HouseMode, discovering: HouseDiscovering
|
|
23
|
+
export declare function houseNotifications(transport: HouseDoor, mode: HouseMode, discovering: HouseDiscovering): HouseNotifications;
|
package/dist/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EAEpB,KAAK,SAAS,EACd,KAAK,kBAAkB,EAEvB,KAAK,QAAQ,EAGb,KAAK,eAAe,EAEpB,KAAK,iBAAiB,EAEvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EAEpB,KAAK,SAAS,EACd,KAAK,kBAAkB,EAEvB,KAAK,QAAQ,EAGb,KAAK,eAAe,EAEpB,KAAK,iBAAiB,EAEvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAYvD,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,SAAS,EAGd,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAaxB,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAE/E,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,gBAAgB,EAAE;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAC,CAAC;AAElG,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IACnE,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,eAAe,GAAG,IAAI,CAAC;IACnE,OAAO,CAAC,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC9D,IAAI,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,IAAI,CAAC;IACvC,KAAK,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtD,aAAa,EAAE,kBAAkB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAyFF,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,SAAS,EACf,WAAW,EAAE,gBAAgB,GAC5B,kBAAkB,CAoYpB"}
|