@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/search.d.ts
CHANGED
|
@@ -2,4 +2,3 @@ import type { SearchAnswer, SearchAsk } from '@agentshouse/mdruntime';
|
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
3
|
import { type HouseTransport } from './transport.js';
|
|
4
4
|
export declare function houseSearch(transport: Pick<HouseTransport, 'door'>, tracked: readonly TrackedAuthority[], request: SearchAsk): Promise<SearchAnswer>;
|
|
5
|
-
//# sourceMappingURL=search.d.ts.map
|
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;
|
|
@@ -27,7 +26,7 @@ export async function houseSearch(transport, tracked, request) {
|
|
|
27
26
|
: tracked.filter((entry) => request.rooms.includes(entry.locator));
|
|
28
27
|
if (named !== null && named.length === 0)
|
|
29
28
|
return { kind: 'found', documents: [] };
|
|
30
|
-
const answer = await transport.door(houseDoorRoute('search'), {
|
|
29
|
+
const answer = await transport.door(houseDoorRoute('rooms/search'), {
|
|
31
30
|
query: request.text,
|
|
32
31
|
...(named === null ? {} : { paths: named.map((entry) => `${ROOMS}${entry.handle}`) }),
|
|
33
32
|
});
|
|
@@ -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',
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type Check<T> = (value: unknown) => value is T;
|
|
2
|
+
export type Checked<C> = C extends Check<infer T> ? T : never;
|
|
3
|
+
type Shape = Readonly<Record<string, Check<unknown>>>;
|
|
4
|
+
export type Shaped<S extends Shape> = {
|
|
5
|
+
readonly [K in keyof S]: Checked<S[K]>;
|
|
6
|
+
};
|
|
7
|
+
export declare const text: Check<string>;
|
|
8
|
+
export declare const count: Check<number>;
|
|
9
|
+
export declare const figure: Check<number>;
|
|
10
|
+
export declare const instant: Check<string>;
|
|
11
|
+
export declare function oneOf<const V extends readonly string[]>(...values: V): Check<V[number]>;
|
|
12
|
+
export declare function where<T>(check: Check<T>, holds: (value: T) => boolean): Check<T>;
|
|
13
|
+
export declare function nullable<T>(check: Check<T>): Check<T | null>;
|
|
14
|
+
export declare function list<T>(check: Check<T>): Check<readonly T[]>;
|
|
15
|
+
export declare function exact<const S extends Shape>(shape: S): Check<Shaped<S>>;
|
|
16
|
+
export declare function anyOf<const C extends readonly Check<unknown>[]>(...checks: C): Check<Checked<C[number]>>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { isPart, turnCounts } from './parts.js';
|
|
2
|
+
export type { Counts, Part, PartOf } from './parts.js';
|
|
3
|
+
export { isState, standingState } from './state.js';
|
|
4
|
+
export type { SessionState, Tokens } from './state.js';
|
|
5
|
+
export { applied, isOperation, isTurn } from './turn.js';
|
|
6
|
+
export type { Operation, Turn } from './turn.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Check, type Checked } from './check.js';
|
|
2
|
+
declare const PART: Check<import("./check.js").Shaped<{
|
|
3
|
+
readonly type: Check<"text">;
|
|
4
|
+
readonly text: Check<string>;
|
|
5
|
+
}> | import("./check.js").Shaped<{
|
|
6
|
+
readonly commands: Check<number>;
|
|
7
|
+
readonly edited: Check<number>;
|
|
8
|
+
readonly other: Check<number>;
|
|
9
|
+
readonly added: Check<number>;
|
|
10
|
+
readonly removed: Check<number>;
|
|
11
|
+
readonly failed: Check<number>;
|
|
12
|
+
readonly type: Check<"counts">;
|
|
13
|
+
}> | import("./check.js").Shaped<{
|
|
14
|
+
readonly type: Check<"image">;
|
|
15
|
+
readonly file: Check<string>;
|
|
16
|
+
readonly name: Check<string>;
|
|
17
|
+
readonly media_type: Check<string>;
|
|
18
|
+
}> | import("./check.js").Shaped<{
|
|
19
|
+
readonly type: Check<"notice">;
|
|
20
|
+
readonly kind: Check<"compaction" | "error" | "info" | "mode" | "model" | "retry" | "warning">;
|
|
21
|
+
readonly text: Check<string>;
|
|
22
|
+
}>>;
|
|
23
|
+
export type Part = Checked<typeof PART>;
|
|
24
|
+
export type PartOf<T extends Part['type']> = Extract<Part, {
|
|
25
|
+
readonly type: T;
|
|
26
|
+
}>;
|
|
27
|
+
export type Counts = Omit<PartOf<'counts'>, 'type'>;
|
|
28
|
+
export declare const isPart: Check<Part>;
|
|
29
|
+
export declare function turnCounts(parts: readonly Part[]): Counts;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type Check, type Checked } from './check.js';
|
|
2
|
+
export declare const TOKENS: Check<import("./check.js").Shaped<{
|
|
3
|
+
readonly input: Check<number>;
|
|
4
|
+
readonly output: Check<number>;
|
|
5
|
+
readonly cache_read: Check<number>;
|
|
6
|
+
readonly cache_write: Check<number>;
|
|
7
|
+
}>>;
|
|
8
|
+
export type Tokens = Checked<typeof TOKENS>;
|
|
9
|
+
declare const STATE: Check<import("./check.js").Shaped<{
|
|
10
|
+
readonly title: Check<string | null>;
|
|
11
|
+
readonly context: Check<import("./check.js").Shaped<{
|
|
12
|
+
readonly used: Check<number>;
|
|
13
|
+
readonly window: Check<number>;
|
|
14
|
+
readonly breakdown: Check<readonly import("./check.js").Shaped<{
|
|
15
|
+
readonly name: Check<string>;
|
|
16
|
+
readonly tokens: Check<number>;
|
|
17
|
+
}>[]>;
|
|
18
|
+
}> | null>;
|
|
19
|
+
readonly limits: Check<readonly import("./check.js").Shaped<{
|
|
20
|
+
readonly name: Check<string | null>;
|
|
21
|
+
readonly minutes: Check<number>;
|
|
22
|
+
readonly percent: Check<number>;
|
|
23
|
+
readonly resets: Check<string | null>;
|
|
24
|
+
}>[]>;
|
|
25
|
+
readonly cost: Check<import("./check.js").Shaped<{
|
|
26
|
+
readonly amount: Check<number>;
|
|
27
|
+
readonly currency: Check<string>;
|
|
28
|
+
}> | null>;
|
|
29
|
+
readonly tokens: Check<import("./check.js").Shaped<{
|
|
30
|
+
readonly input: Check<number>;
|
|
31
|
+
readonly output: Check<number>;
|
|
32
|
+
readonly cache_read: Check<number>;
|
|
33
|
+
readonly cache_write: Check<number>;
|
|
34
|
+
}> | null>;
|
|
35
|
+
readonly duration: Check<number | null>;
|
|
36
|
+
readonly files: Check<import("./check.js").Shaped<{
|
|
37
|
+
readonly count: Check<number>;
|
|
38
|
+
readonly added: Check<number>;
|
|
39
|
+
readonly removed: Check<number>;
|
|
40
|
+
}>>;
|
|
41
|
+
readonly branch: Check<string | null>;
|
|
42
|
+
readonly worktree: Check<string | null>;
|
|
43
|
+
readonly pull: Check<import("./check.js").Shaped<{
|
|
44
|
+
readonly number: Check<number>;
|
|
45
|
+
readonly url: Check<string>;
|
|
46
|
+
}> | null>;
|
|
47
|
+
readonly model: Check<string | null>;
|
|
48
|
+
readonly effort: Check<string | null>;
|
|
49
|
+
readonly mode: Check<string | null>;
|
|
50
|
+
readonly suggestion: Check<string | null>;
|
|
51
|
+
readonly running: Check<readonly import("./check.js").Shaped<{
|
|
52
|
+
readonly kind: Check<"monitor" | "schedule" | "shell" | "subagent" | "task">;
|
|
53
|
+
readonly count: Check<number>;
|
|
54
|
+
}>[]>;
|
|
55
|
+
}>>;
|
|
56
|
+
export type SessionState = Checked<typeof STATE>;
|
|
57
|
+
export declare const isState: Check<SessionState>;
|
|
58
|
+
export declare function standingState(state: SessionState, saved: string, ended: string | null): SessionState;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { type Check, type Checked } from './check.js';
|
|
2
|
+
import { type Part } from './parts.js';
|
|
3
|
+
declare const OPERATION: Check<import("./check.js").Shaped<{
|
|
4
|
+
readonly op: Check<"start">;
|
|
5
|
+
readonly index: Check<number>;
|
|
6
|
+
readonly part: Check<import("./check.js").Shaped<{
|
|
7
|
+
readonly type: Check<"text">;
|
|
8
|
+
readonly text: Check<string>;
|
|
9
|
+
}> | import("./check.js").Shaped<{
|
|
10
|
+
readonly commands: Check<number>;
|
|
11
|
+
readonly edited: Check<number>;
|
|
12
|
+
readonly other: Check<number>;
|
|
13
|
+
readonly added: Check<number>;
|
|
14
|
+
readonly removed: Check<number>;
|
|
15
|
+
readonly failed: Check<number>;
|
|
16
|
+
readonly type: Check<"counts">;
|
|
17
|
+
}> | import("./check.js").Shaped<{
|
|
18
|
+
readonly type: Check<"image">;
|
|
19
|
+
readonly file: Check<string>;
|
|
20
|
+
readonly name: Check<string>;
|
|
21
|
+
readonly media_type: Check<string>;
|
|
22
|
+
}> | import("./check.js").Shaped<{
|
|
23
|
+
readonly type: Check<"notice">;
|
|
24
|
+
readonly kind: Check<"compaction" | "error" | "info" | "mode" | "model" | "retry" | "warning">;
|
|
25
|
+
readonly text: Check<string>;
|
|
26
|
+
}>>;
|
|
27
|
+
}> | import("./check.js").Shaped<{
|
|
28
|
+
readonly op: Check<"append">;
|
|
29
|
+
readonly index: Check<number>;
|
|
30
|
+
readonly text: Check<string>;
|
|
31
|
+
}> | import("./check.js").Shaped<{
|
|
32
|
+
readonly op: Check<"set">;
|
|
33
|
+
readonly index: Check<number>;
|
|
34
|
+
readonly part: Check<import("./check.js").Shaped<{
|
|
35
|
+
readonly type: Check<"text">;
|
|
36
|
+
readonly text: Check<string>;
|
|
37
|
+
}> | import("./check.js").Shaped<{
|
|
38
|
+
readonly commands: Check<number>;
|
|
39
|
+
readonly edited: Check<number>;
|
|
40
|
+
readonly other: Check<number>;
|
|
41
|
+
readonly added: Check<number>;
|
|
42
|
+
readonly removed: Check<number>;
|
|
43
|
+
readonly failed: Check<number>;
|
|
44
|
+
readonly type: Check<"counts">;
|
|
45
|
+
}> | import("./check.js").Shaped<{
|
|
46
|
+
readonly type: Check<"image">;
|
|
47
|
+
readonly file: Check<string>;
|
|
48
|
+
readonly name: Check<string>;
|
|
49
|
+
readonly media_type: Check<string>;
|
|
50
|
+
}> | import("./check.js").Shaped<{
|
|
51
|
+
readonly type: Check<"notice">;
|
|
52
|
+
readonly kind: Check<"compaction" | "error" | "info" | "mode" | "model" | "retry" | "warning">;
|
|
53
|
+
readonly text: Check<string>;
|
|
54
|
+
}>>;
|
|
55
|
+
}>>;
|
|
56
|
+
export type Operation = Checked<typeof OPERATION>;
|
|
57
|
+
export declare const isOperation: Check<Operation>;
|
|
58
|
+
declare const TURN: Check<import("./check.js").Shaped<{
|
|
59
|
+
readonly parts: Check<readonly (import("./check.js").Shaped<{
|
|
60
|
+
readonly type: Check<"text">;
|
|
61
|
+
readonly text: Check<string>;
|
|
62
|
+
}> | import("./check.js").Shaped<{
|
|
63
|
+
readonly commands: Check<number>;
|
|
64
|
+
readonly edited: Check<number>;
|
|
65
|
+
readonly other: Check<number>;
|
|
66
|
+
readonly added: Check<number>;
|
|
67
|
+
readonly removed: Check<number>;
|
|
68
|
+
readonly failed: Check<number>;
|
|
69
|
+
readonly type: Check<"counts">;
|
|
70
|
+
}> | import("./check.js").Shaped<{
|
|
71
|
+
readonly type: Check<"image">;
|
|
72
|
+
readonly file: Check<string>;
|
|
73
|
+
readonly name: Check<string>;
|
|
74
|
+
readonly media_type: Check<string>;
|
|
75
|
+
}> | import("./check.js").Shaped<{
|
|
76
|
+
readonly type: Check<"notice">;
|
|
77
|
+
readonly kind: Check<"compaction" | "error" | "info" | "mode" | "model" | "retry" | "warning">;
|
|
78
|
+
readonly text: Check<string>;
|
|
79
|
+
}>)[]>;
|
|
80
|
+
readonly tokens: Check<import("./check.js").Shaped<{
|
|
81
|
+
readonly input: Check<number>;
|
|
82
|
+
readonly output: Check<number>;
|
|
83
|
+
readonly cache_read: Check<number>;
|
|
84
|
+
readonly cache_write: Check<number>;
|
|
85
|
+
}> | null>;
|
|
86
|
+
readonly state: Check<import("./check.js").Shaped<{
|
|
87
|
+
readonly title: Check<string | null>;
|
|
88
|
+
readonly context: Check<import("./check.js").Shaped<{
|
|
89
|
+
readonly used: Check<number>;
|
|
90
|
+
readonly window: Check<number>;
|
|
91
|
+
readonly breakdown: Check<readonly import("./check.js").Shaped<{
|
|
92
|
+
readonly name: Check<string>;
|
|
93
|
+
readonly tokens: Check<number>;
|
|
94
|
+
}>[]>;
|
|
95
|
+
}> | null>;
|
|
96
|
+
readonly limits: Check<readonly import("./check.js").Shaped<{
|
|
97
|
+
readonly name: Check<string | null>;
|
|
98
|
+
readonly minutes: Check<number>;
|
|
99
|
+
readonly percent: Check<number>;
|
|
100
|
+
readonly resets: Check<string | null>;
|
|
101
|
+
}>[]>;
|
|
102
|
+
readonly cost: Check<import("./check.js").Shaped<{
|
|
103
|
+
readonly amount: Check<number>;
|
|
104
|
+
readonly currency: Check<string>;
|
|
105
|
+
}> | null>;
|
|
106
|
+
readonly tokens: Check<import("./check.js").Shaped<{
|
|
107
|
+
readonly input: Check<number>;
|
|
108
|
+
readonly output: Check<number>;
|
|
109
|
+
readonly cache_read: Check<number>;
|
|
110
|
+
readonly cache_write: Check<number>;
|
|
111
|
+
}> | null>;
|
|
112
|
+
readonly duration: Check<number | null>;
|
|
113
|
+
readonly files: Check<import("./check.js").Shaped<{
|
|
114
|
+
readonly count: Check<number>;
|
|
115
|
+
readonly added: Check<number>;
|
|
116
|
+
readonly removed: Check<number>;
|
|
117
|
+
}>>;
|
|
118
|
+
readonly branch: Check<string | null>;
|
|
119
|
+
readonly worktree: Check<string | null>;
|
|
120
|
+
readonly pull: Check<import("./check.js").Shaped<{
|
|
121
|
+
readonly number: Check<number>;
|
|
122
|
+
readonly url: Check<string>;
|
|
123
|
+
}> | null>;
|
|
124
|
+
readonly model: Check<string | null>;
|
|
125
|
+
readonly effort: Check<string | null>;
|
|
126
|
+
readonly mode: Check<string | null>;
|
|
127
|
+
readonly suggestion: Check<string | null>;
|
|
128
|
+
readonly running: Check<readonly import("./check.js").Shaped<{
|
|
129
|
+
readonly kind: Check<"monitor" | "schedule" | "shell" | "subagent" | "task">;
|
|
130
|
+
readonly count: Check<number>;
|
|
131
|
+
}>[]>;
|
|
132
|
+
}>>;
|
|
133
|
+
}>>;
|
|
134
|
+
export type Turn = Checked<typeof TURN>;
|
|
135
|
+
export declare const isTurn: Check<Turn>;
|
|
136
|
+
export declare function applied(parts: readonly Part[], operation: Operation): readonly Part[] | null;
|
|
137
|
+
export {};
|
package/dist/site.d.ts
CHANGED
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,EASR,MAAM,wBAAwB,CAAC;AAchC,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAgCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,UAAQ,GAAG,OAAO,CA0K1F"}
|
package/dist/site.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HOUSE_ROOM_TYPES, HOUSE_TYPED_PATHS } from '@agentshouse/mdmodel';
|
|
2
2
|
import { actionOutcome } from './actions.js';
|
|
3
|
+
import { chunkedHead, chunkPart, siteChunkList } from './chunks.js';
|
|
3
4
|
import { mapDiscovery, parseSiteDiscovery, siteCapabilities, siteTracked, } from './discovery.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { classifyDoor, discoveryFailure } from './refusal.js';
|
|
8
|
-
import { HOUSE_TYPED_PATHS } from './house-model.js';
|
|
9
|
-
import { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES } from './room-types.js';
|
|
5
|
+
import { answeredFailure, discoveryFailure } from './refusal.js';
|
|
6
|
+
import { admittedPath } from './authored-path.js';
|
|
7
|
+
import { siteQuery } from './room-query.js';
|
|
10
8
|
import { houseNotifications } from './stream.js';
|
|
11
|
-
import { houseSiteRoute,
|
|
12
|
-
import {
|
|
13
|
-
|
|
9
|
+
import { houseSiteRoute, SITE_DOOR_ACTS, SITE_FILES, } from './transport.js';
|
|
10
|
+
import { UNANSWERED, unusable } from './uncertain.js';
|
|
11
|
+
import { followsVersion, reachedVersion, roomVersion } from './version.js';
|
|
14
12
|
function unfound() {
|
|
15
|
-
return { kind: 'rejected', code: '
|
|
13
|
+
return { kind: 'rejected', code: 'not_found', fields: {}, retryable: false };
|
|
14
|
+
}
|
|
15
|
+
function siteCopies(copies) {
|
|
16
|
+
if (copies === null || copies === undefined)
|
|
17
|
+
return [];
|
|
18
|
+
return copies.split(', ').map((offered) => {
|
|
19
|
+
const [url = '', width = ''] = offered.split(' ');
|
|
20
|
+
return { url, width: Number.parseInt(width, 10) };
|
|
21
|
+
});
|
|
16
22
|
}
|
|
17
23
|
function siteRoom(tracked) {
|
|
18
24
|
return {
|
|
@@ -20,51 +26,48 @@ function siteRoom(tracked) {
|
|
|
20
26
|
locator: tracked.locator,
|
|
21
27
|
handle: tracked.handle,
|
|
22
28
|
roomVersion: roomVersion(tracked),
|
|
23
|
-
operations: { write: [],
|
|
29
|
+
operations: { write: [], erase: [] },
|
|
24
30
|
replica: { selection: tracked.locator, admission: 'admitted', offline: 'open' },
|
|
31
|
+
typedSelection: null,
|
|
25
32
|
providerOwnedPaths: [],
|
|
33
|
+
authoredPaths: ['**'],
|
|
26
34
|
};
|
|
27
35
|
}
|
|
28
36
|
export function createSiteAdapter(transport, snapshot = false) {
|
|
29
|
-
const spaces = spaceSchemas();
|
|
30
37
|
const notifications = houseNotifications(transport, 'site', {
|
|
31
38
|
opened: async () => {
|
|
32
39
|
const found = await discovered();
|
|
33
40
|
return found.kind === 'discovery' ? found : null;
|
|
34
41
|
},
|
|
35
42
|
changed: () => null,
|
|
36
|
-
}
|
|
43
|
+
});
|
|
37
44
|
const tracked = new Map();
|
|
38
|
-
const
|
|
39
|
-
const rooms = roomStreams('site', spaces);
|
|
45
|
+
const chunked = new Map();
|
|
40
46
|
function fileRoute(request) {
|
|
41
47
|
const entry = tracked.get(request.locator);
|
|
42
48
|
if (entry === undefined)
|
|
43
49
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
44
50
|
return `${SITE_FILES}${entry.authority}/${encodeURIComponent(request.revision)}/${encodeURIComponent(request.path)}`;
|
|
45
51
|
}
|
|
46
|
-
async function
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
return
|
|
51
|
-
const head = await
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
read.set(entry.locator, at.position);
|
|
52
|
+
async function listedRoom(entry) {
|
|
53
|
+
const past = chunked.get(entry.locator)?.position;
|
|
54
|
+
const listed = siteChunkList(await transport.read(`${houseSiteRoute('chunks')}/${entry.authority}${past === undefined ? '' : `?expired=${past}`}`), entry.locator);
|
|
55
|
+
if ('kind' in listed)
|
|
56
|
+
return listed;
|
|
57
|
+
const head = await chunkedHead(listed, entry);
|
|
58
|
+
if (head.kind === 'bootstrap')
|
|
59
|
+
chunked.set(entry.locator, listed);
|
|
55
60
|
return head;
|
|
56
61
|
}
|
|
57
|
-
async function
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
bytes: part.bytes,
|
|
67
|
-
};
|
|
62
|
+
async function chunkPage(entry, id, arriving) {
|
|
63
|
+
const room = chunked.get(entry.locator);
|
|
64
|
+
const address = room?.chunks.get(id);
|
|
65
|
+
if (room === undefined || address === undefined)
|
|
66
|
+
return UNANSWERED;
|
|
67
|
+
const read = await transport.download(address.url);
|
|
68
|
+
if (read.status !== 200)
|
|
69
|
+
return answeredFailure(read.status, null);
|
|
70
|
+
return chunkPart(read.body, room, id, arriving);
|
|
68
71
|
}
|
|
69
72
|
async function discovered() {
|
|
70
73
|
const answer = await transport.read(houseSiteRoute('discover'));
|
|
@@ -73,19 +76,26 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
73
76
|
return failed;
|
|
74
77
|
const document = parseSiteDiscovery(answer.body);
|
|
75
78
|
if (document === null)
|
|
76
|
-
return
|
|
79
|
+
return unusable();
|
|
77
80
|
const entries = siteTracked(document);
|
|
78
81
|
tracked.clear();
|
|
79
82
|
for (const entry of entries)
|
|
80
83
|
tracked.set(entry.locator, entry);
|
|
81
84
|
notifications.track(entries);
|
|
82
|
-
return
|
|
85
|
+
return {
|
|
86
|
+
...mapDiscovery(document, entries.map(siteRoom), siteCapabilities()),
|
|
87
|
+
queriesOnly: document.queriesOnly.map(({ roomRef, roomHandle }) => ({
|
|
88
|
+
locator: roomRef,
|
|
89
|
+
handle: roomHandle,
|
|
90
|
+
name: roomHandle,
|
|
91
|
+
})),
|
|
92
|
+
};
|
|
83
93
|
}
|
|
84
94
|
return {
|
|
85
95
|
localSaves: true,
|
|
86
96
|
roomTypes: HOUSE_ROOM_TYPES,
|
|
87
|
-
nameableRoomTypes: HOUSE_NAMEABLE_ROOM_TYPES,
|
|
88
97
|
typedPaths: HOUSE_TYPED_PATHS,
|
|
98
|
+
pathRule: admittedPath,
|
|
89
99
|
async authorize() {
|
|
90
100
|
return {};
|
|
91
101
|
},
|
|
@@ -94,8 +104,8 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
94
104
|
if (entry === undefined)
|
|
95
105
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
96
106
|
return request.pageToken === undefined
|
|
97
|
-
?
|
|
98
|
-
:
|
|
107
|
+
? listedRoom(entry)
|
|
108
|
+
: chunkPage(entry, request.pageToken, request.arriving);
|
|
99
109
|
},
|
|
100
110
|
...(snapshot
|
|
101
111
|
? {
|
|
@@ -105,7 +115,7 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
105
115
|
if (entry === undefined)
|
|
106
116
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
107
117
|
if (request.pageToken !== undefined)
|
|
108
|
-
return
|
|
118
|
+
return UNANSWERED;
|
|
109
119
|
return request.fromRoomVersion === roomVersion(entry)
|
|
110
120
|
? { kind: 'still-current' }
|
|
111
121
|
: { kind: 'beyond-horizon' };
|
|
@@ -121,6 +131,7 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
121
131
|
async history() {
|
|
122
132
|
return { kind: 'no-history' };
|
|
123
133
|
},
|
|
134
|
+
queryHouse: (_authorization, request) => siteQuery(transport, request),
|
|
124
135
|
async binary(_authorization, request) {
|
|
125
136
|
const route = fileRoute(request);
|
|
126
137
|
if (typeof route !== 'string')
|
|
@@ -128,11 +139,21 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
128
139
|
const read = await transport.download(route);
|
|
129
140
|
if (read.status === 404)
|
|
130
141
|
return unfound();
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
142
|
+
if (read.status !== 200)
|
|
143
|
+
return answeredFailure(read.status, null);
|
|
144
|
+
if (read.body === null)
|
|
145
|
+
return unusable();
|
|
146
|
+
return {
|
|
147
|
+
kind: 'binary',
|
|
148
|
+
body: read.body,
|
|
149
|
+
mediaType: read.mediaType,
|
|
150
|
+
url: route,
|
|
151
|
+
copies: siteCopies(read.copies),
|
|
152
|
+
};
|
|
134
153
|
},
|
|
135
154
|
async link(_authorization, request) {
|
|
155
|
+
if (request.kind === 'key')
|
|
156
|
+
return unfound();
|
|
136
157
|
const route = fileRoute(request);
|
|
137
158
|
if (typeof route !== 'string')
|
|
138
159
|
return route;
|
|
@@ -149,7 +170,10 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
149
170
|
return followsVersion(version, next);
|
|
150
171
|
},
|
|
151
172
|
async action(_authorization, request) {
|
|
152
|
-
|
|
173
|
+
const route = Object.hasOwn(SITE_DOOR_ACTS, request.name)
|
|
174
|
+
? SITE_DOOR_ACTS[request.name]
|
|
175
|
+
: null;
|
|
176
|
+
if (route === null) {
|
|
153
177
|
return {
|
|
154
178
|
kind: 'rejected',
|
|
155
179
|
code: 'action-unimplemented',
|
|
@@ -158,19 +182,13 @@ export function createSiteAdapter(transport, snapshot = false) {
|
|
|
158
182
|
};
|
|
159
183
|
}
|
|
160
184
|
if (!transport.online())
|
|
161
|
-
return
|
|
162
|
-
return actionOutcome(await transport.door(
|
|
185
|
+
return UNANSWERED;
|
|
186
|
+
return actionOutcome(await transport.door(route, request.input), request.name, request.input);
|
|
163
187
|
},
|
|
164
188
|
roomStream: snapshot
|
|
165
189
|
? undefined
|
|
166
190
|
: {
|
|
167
|
-
hold
|
|
168
|
-
notifications.send(rooms.flatMap((room) => {
|
|
169
|
-
const entry = tracked.get(room.locator);
|
|
170
|
-
const at = logPosition(room.roomVersion);
|
|
171
|
-
return entry === undefined || at === null ? [] : [presented(entry.authority, at)];
|
|
172
|
-
}));
|
|
173
|
-
},
|
|
191
|
+
hold: notifications.send,
|
|
174
192
|
observe: notifications.observe,
|
|
175
193
|
},
|
|
176
194
|
serviceMode: notifications.serviceMode,
|
package/dist/space-schema.d.ts
CHANGED
|
@@ -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,7 +1,6 @@
|
|
|
1
|
-
import { type AuthorityChange, type Discovery, type ConversationStream, type RoomStreamEvent, type ServiceModeSignal } from '@agentshouse/mdruntime';
|
|
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
|
|
4
|
-
import { type HouseDoor, type HouseHeldRoom, type HouseMode, type HouseStreamFrame } from './transport.js';
|
|
3
|
+
import { type HouseDoor, type HouseMode, type HouseStreamFrame } from './transport.js';
|
|
5
4
|
export type HouseOpeningFrame = Extract<HouseStreamFrame, {
|
|
6
5
|
type: 'opening';
|
|
7
6
|
}>;
|
|
@@ -11,14 +10,14 @@ 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;
|
|
13
|
+
expired?(entries: readonly TrackedAuthority[]): void;
|
|
14
14
|
};
|
|
15
15
|
export type HouseNotifications = {
|
|
16
16
|
runtime: string;
|
|
17
17
|
observe(notify: (event: RoomStreamEvent) => void): () => void;
|
|
18
|
-
send(rooms: readonly
|
|
18
|
+
send(rooms: readonly HeldRoom[]): void;
|
|
19
19
|
track(authorities: readonly TrackedAuthority[]): void;
|
|
20
20
|
conversations: ConversationStream;
|
|
21
21
|
serviceMode: ServiceModeSignal;
|
|
22
22
|
};
|
|
23
|
-
export declare function houseNotifications(transport: HouseDoor, mode: HouseMode, discovering: HouseDiscovering
|
|
24
|
-
//# sourceMappingURL=stream.d.ts.map
|
|
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,
|
|
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;AAwFF,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,SAAS,EACf,WAAW,EAAE,gBAAgB,GAC5B,kBAAkB,CA6XpB"}
|