@agentshouse/mdruntime-adapter 0.1.0-ce7ce34e4ced0 → 0.1.0-ce861e3fb788a

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/read.js CHANGED
@@ -12,7 +12,7 @@ export function answering() {
12
12
  fileIds: new Map(),
13
13
  created: new Map(),
14
14
  changes: new Map(),
15
- binaryFiles: new Map(),
15
+ attachments: new Map(),
16
16
  removals: new Set(),
17
17
  folders: new Set(),
18
18
  folderRemovals: new Set(),
@@ -31,7 +31,7 @@ export function forgotten(answer, path) {
31
31
  answer.fileIds.delete(path);
32
32
  answer.created.delete(path);
33
33
  answer.changes.delete(path);
34
- answer.binaryFiles.delete(path);
34
+ answer.attachments.delete(path);
35
35
  answer.removals.delete(path);
36
36
  }
37
37
  export function folded(answer, path, removed) {
@@ -61,7 +61,7 @@ export function* answered(answer) {
61
61
  ...(answer.fileIds.size === 0 ? {} : { fileIds: yield* patching({}, answer.fileIds) }),
62
62
  ...(answer.created.size === 0 ? {} : { created: yield* patching({}, answer.created) }),
63
63
  changes: yield* patching({}, answer.changes),
64
- binaryFiles: yield* patching({}, answer.binaryFiles),
64
+ attachments: yield* patching({}, answer.attachments),
65
65
  removals,
66
66
  ...(answer.folders.size === 0 ? {} : { folders: yield* pathsOf(answer.folders) }),
67
67
  ...(answer.folderRemovals.size === 0
@@ -165,7 +165,7 @@ function imageSize(width, height) {
165
165
  return { width: null, height: null };
166
166
  return side(width) && side(height) ? { width, height } : null;
167
167
  }
168
- export function binaryFileOf(held) {
168
+ export function attachmentOf(held) {
169
169
  if (held.media_type === undefined)
170
170
  return undefined;
171
171
  const { bytes, media_type: mediaType, sha256 } = held;
@@ -176,7 +176,7 @@ export function binaryFileOf(held) {
176
176
  return null;
177
177
  return { byteLength: bytes, mediaType, sha256, ...size };
178
178
  }
179
- function binaried(binary) {
179
+ function withAttachment(binary) {
180
180
  return binary === undefined ? {} : { binary };
181
181
  }
182
182
  function carriedFacts(held) {
@@ -195,7 +195,7 @@ export function documentEntry(value, mode) {
195
195
  return null;
196
196
  const head = headChange(file);
197
197
  const created = createdOf(file);
198
- const binary = binaryFileOf(file);
198
+ const binary = attachmentOf(file);
199
199
  if (head === null || created === null || binary === null)
200
200
  return null;
201
201
  const content = file.content === undefined ? {} : { content: file.content };
@@ -207,7 +207,7 @@ export function documentEntry(value, mode) {
207
207
  revision: binary?.sha256,
208
208
  version: file.sha256,
209
209
  ...headed(head),
210
- ...binaried(binary),
210
+ ...withAttachment(binary),
211
211
  ...carriedFacts(file),
212
212
  ...content,
213
213
  };
@@ -220,7 +220,7 @@ export function documentEntry(value, mode) {
220
220
  version: file.revision,
221
221
  ...headed(head),
222
222
  ...createdHeld(created),
223
- ...binaried(binary),
223
+ ...withAttachment(binary),
224
224
  ...carriedFacts(file),
225
225
  ...carriedSpace(file),
226
226
  ...content,
@@ -232,7 +232,7 @@ export function kept(answer, file) {
232
232
  if (file.created !== undefined)
233
233
  answer.created.set(file.path, file.created);
234
234
  if (file.binary !== undefined)
235
- answer.binaryFiles.set(file.path, file.binary);
235
+ answer.attachments.set(file.path, file.binary);
236
236
  else if (file.content !== undefined)
237
237
  answer.documents.set(file.path, file.content);
238
238
  if (file.binary === undefined && file.facts !== undefined)
@@ -0,0 +1,10 @@
1
+ export interface Renamed {
2
+ readonly from: string;
3
+ readonly to: string;
4
+ }
5
+ export declare function renamedHandle(answer: {
6
+ readonly kind: string;
7
+ readonly code?: string;
8
+ readonly fields?: Readonly<Record<string, unknown>>;
9
+ }): Renamed | null;
10
+ export declare function movedPaths(value: unknown, roomPaths: readonly string[], renamed: Renamed): unknown;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renamed.d.ts","sourceRoot":"","sources":["../src/renamed.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAMD,wBAAgB,aAAa,CAAC,MAAM,EAAE;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACrD,GAAG,OAAO,GAAG,IAAI,CAKjB;AAOD,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,OAAO,EAAE,OAAO,GACf,OAAO,CAKT"}
@@ -0,0 +1,20 @@
1
+ import { selectorRewritten } from '@agentshouse/mdruntime';
2
+ const ROOM_ROOT = /^\/rooms\/([^/]+)(?=\/|$)/u;
3
+ function roomOfPath(path) {
4
+ return typeof path === 'string' ? (ROOM_ROOT.exec(path)?.[1] ?? null) : null;
5
+ }
6
+ export function renamedHandle(answer) {
7
+ if (answer.kind !== 'rejected' || answer.code !== 'handle_changed')
8
+ return null;
9
+ const from = roomOfPath(answer.fields?.path);
10
+ const to = roomOfPath(answer.fields?.current_path);
11
+ return from === null || to === null || from === to ? null : { from, to };
12
+ }
13
+ function movedPath(value, renamed) {
14
+ if (typeof value !== 'string' || roomOfPath(value) !== renamed.from)
15
+ return value;
16
+ return `/rooms/${renamed.to}${value.slice(`/rooms/${renamed.from}`.length)}`;
17
+ }
18
+ export function movedPaths(value, roomPaths, renamed) {
19
+ return roomPaths.reduce((moved, selector) => selectorRewritten(moved, selector, (one) => movedPath(one, renamed)), value);
20
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"room-query.d.ts","sourceRoot":"","sources":["../src/room-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EAId,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AASxB,wBAAsB,UAAU,CAC9B,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,EACvC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,gBAAgB,CAAC,CAO3B;AAED,wBAAsB,SAAS,CAC7B,SAAS,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,EAC3C,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,gBAAgB,CAAC,CAI3B"}
1
+ {"version":3,"file":"room-query.d.ts","sourceRoot":"","sources":["../src/room-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EAId,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAwBxB,wBAAsB,UAAU,CAC9B,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,EACvC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,gBAAgB,CAAC,CAK3B;AAED,wBAAsB,SAAS,CAC7B,SAAS,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,EAC3C,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,gBAAgB,CAAC,CAQ3B"}
@@ -6,26 +6,41 @@ const TOO_LONG_FOR_AN_ADDRESS = {
6
6
  fields: {},
7
7
  retryable: false,
8
8
  };
9
+ function infoAsked(request) {
10
+ const root = `/rooms/${request.room}`;
11
+ const follows = request.follows === undefined ? {} : { follows: request.follows };
12
+ if (!('query' in request)) {
13
+ const { path, after } = request;
14
+ return {
15
+ path: `${root}/${path}`,
16
+ ...(after === undefined ? {} : { cursor: after }),
17
+ ...follows,
18
+ };
19
+ }
20
+ const { after, ...query } = request.query;
21
+ return { path: root, query, ...(after === undefined ? {} : { cursor: after }), ...follows };
22
+ }
9
23
  export async function houseQuery(transport, request) {
10
- return queriedPage(await transport.door(houseDoorRoute('rooms/query'), {
11
- room_ref: request.room,
12
- query: request.query,
13
- }));
24
+ return queriedPage(await transport.door(houseDoorRoute('info'), infoAsked(request)), 'next_cursor');
14
25
  }
15
26
  export async function siteQuery(transport, request) {
16
- const route = siteQueryRoute(request.room, request.query);
27
+ const asked = 'query' in request
28
+ ? request.query
29
+ : { path: request.path, ...(request.after === undefined ? {} : { after: request.after }) };
30
+ const route = siteQueryRoute(request.room, asked, request.fresh);
17
31
  if (route.length > SITE_QUERY_ROUTE_CHARACTERS)
18
32
  return TOO_LONG_FOR_AN_ADDRESS;
19
- return queriedPage(await transport.read(route));
33
+ return queriedPage(await transport.read(route), 'next');
20
34
  }
21
- function queriedPage(answer) {
35
+ function queriedPage(answer, named) {
22
36
  if (answer.status === 401)
23
37
  return { kind: 'revoked-authorization' };
24
38
  const refusal = doorRefusal(answer.body);
25
39
  if (refusal !== null)
26
40
  return { kind: 'rejected', ...refusal };
27
- const { documents, groups, next, total, totalCapped, capped } = (answer.body ??
28
- {});
41
+ const body = (answer.body ?? {});
42
+ const { documents, groups, total, totalCapped, capped } = body;
43
+ const next = body[named];
29
44
  if (answer.status !== 200 || !(Array.isArray(documents) || Array.isArray(groups))) {
30
45
  return answeredFailure(answer.status, answer.body);
31
46
  }
@@ -12,6 +12,9 @@ export declare function oneOf<const V extends readonly string[]>(...values: V):
12
12
  export declare function where<T>(check: Check<T>, holds: (value: T) => boolean): Check<T>;
13
13
  export declare function nullable<T>(check: Check<T>): Check<T | null>;
14
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>>;
15
+ export type Optional<O extends Shape> = {
16
+ readonly [K in keyof O]?: Checked<O[K]>;
17
+ };
18
+ export declare function exact<const S extends Shape, const O extends Shape = Record<never, never>>(shape: S, optional?: O): Check<Shaped<S> & Optional<O>>;
16
19
  export declare function anyOf<const C extends readonly Check<unknown>[]>(...checks: C): Check<Checked<C[number]>>;
17
20
  export {};
@@ -3,4 +3,4 @@ export type { Counts, Part, PartOf } from './parts.js';
3
3
  export { isState, standingState } from './state.js';
4
4
  export type { SessionState, Tokens } from './state.js';
5
5
  export { applied, isOperation, isTurn } from './turn.js';
6
- export type { Operation, Turn } from './turn.js';
6
+ export type { ModelTokens, Operation, Turn } from './turn.js';
@@ -1,8 +1,8 @@
1
1
  import { type Check, type Checked } from './check.js';
2
- declare const PART: Check<import("./check.js").Shaped<{
2
+ declare const PART: Check<(import("./check.js").Shaped<{
3
3
  readonly type: Check<"text">;
4
4
  readonly text: Check<string>;
5
- }> | import("./check.js").Shaped<{
5
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
6
6
  readonly commands: Check<number>;
7
7
  readonly edited: Check<number>;
8
8
  readonly other: Check<number>;
@@ -10,16 +10,16 @@ declare const PART: Check<import("./check.js").Shaped<{
10
10
  readonly removed: Check<number>;
11
11
  readonly failed: Check<number>;
12
12
  readonly type: Check<"counts">;
13
- }> | import("./check.js").Shaped<{
13
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
14
14
  readonly type: Check<"image">;
15
15
  readonly file: Check<string>;
16
16
  readonly name: Check<string>;
17
17
  readonly media_type: Check<string>;
18
- }> | import("./check.js").Shaped<{
18
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
19
19
  readonly type: Check<"notice">;
20
20
  readonly kind: Check<"compaction" | "error" | "info" | "mode" | "model" | "retry" | "warning">;
21
21
  readonly text: Check<string>;
22
- }>>;
22
+ }> & import("./check.js").Optional<Record<never, never>>)>;
23
23
  export type Part = Checked<typeof PART>;
24
24
  export type PartOf<T extends Part['type']> = Extract<Part, {
25
25
  readonly type: T;
@@ -1,58 +1,58 @@
1
1
  import { type Check, type Checked } from './check.js';
2
- export declare const TOKENS: Check<import("./check.js").Shaped<{
2
+ declare const TOKENS: Check<import("./check.js").Shaped<{
3
3
  readonly input: Check<number>;
4
4
  readonly output: Check<number>;
5
5
  readonly cache_read: Check<number>;
6
6
  readonly cache_write: Check<number>;
7
- }>>;
7
+ }> & import("./check.js").Optional<Record<never, never>>>;
8
8
  export type Tokens = Checked<typeof TOKENS>;
9
9
  declare const STATE: Check<import("./check.js").Shaped<{
10
10
  readonly title: Check<string | null>;
11
- readonly context: Check<import("./check.js").Shaped<{
11
+ readonly context: Check<(import("./check.js").Shaped<{
12
12
  readonly used: Check<number>;
13
13
  readonly window: Check<number>;
14
- readonly breakdown: Check<readonly import("./check.js").Shaped<{
14
+ readonly breakdown: Check<readonly (import("./check.js").Shaped<{
15
15
  readonly name: Check<string>;
16
16
  readonly tokens: Check<number>;
17
- }>[]>;
18
- }> | null>;
19
- readonly limits: Check<readonly import("./check.js").Shaped<{
17
+ }> & import("./check.js").Optional<Record<never, never>>)[]>;
18
+ }> & import("./check.js").Optional<Record<never, never>>) | null>;
19
+ readonly limits: Check<readonly (import("./check.js").Shaped<{
20
20
  readonly name: Check<string | null>;
21
21
  readonly minutes: Check<number>;
22
22
  readonly percent: Check<number>;
23
23
  readonly resets: Check<string | null>;
24
- }>[]>;
25
- readonly cost: Check<import("./check.js").Shaped<{
24
+ }> & import("./check.js").Optional<Record<never, never>>)[]>;
25
+ readonly cost: Check<(import("./check.js").Shaped<{
26
26
  readonly amount: Check<number>;
27
27
  readonly currency: Check<string>;
28
- }> | null>;
29
- readonly tokens: Check<import("./check.js").Shaped<{
28
+ }> & import("./check.js").Optional<Record<never, never>>) | null>;
29
+ readonly tokens: Check<(import("./check.js").Shaped<{
30
30
  readonly input: Check<number>;
31
31
  readonly output: Check<number>;
32
32
  readonly cache_read: Check<number>;
33
33
  readonly cache_write: Check<number>;
34
- }> | null>;
34
+ }> & import("./check.js").Optional<Record<never, never>>) | null>;
35
35
  readonly duration: Check<number | null>;
36
36
  readonly files: Check<import("./check.js").Shaped<{
37
37
  readonly count: Check<number>;
38
38
  readonly added: Check<number>;
39
39
  readonly removed: Check<number>;
40
- }>>;
40
+ }> & import("./check.js").Optional<Record<never, never>>>;
41
41
  readonly branch: Check<string | null>;
42
42
  readonly worktree: Check<string | null>;
43
- readonly pull: Check<import("./check.js").Shaped<{
43
+ readonly pull: Check<(import("./check.js").Shaped<{
44
44
  readonly number: Check<number>;
45
45
  readonly url: Check<string>;
46
- }> | null>;
46
+ }> & import("./check.js").Optional<Record<never, never>>) | null>;
47
47
  readonly model: Check<string | null>;
48
48
  readonly effort: Check<string | null>;
49
49
  readonly mode: Check<string | null>;
50
50
  readonly suggestion: Check<string | null>;
51
- readonly running: Check<readonly import("./check.js").Shaped<{
51
+ readonly running: Check<readonly (import("./check.js").Shaped<{
52
52
  readonly kind: Check<"monitor" | "schedule" | "shell" | "subagent" | "task">;
53
53
  readonly count: Check<number>;
54
- }>[]>;
55
- }>>;
54
+ }> & import("./check.js").Optional<Record<never, never>>)[]>;
55
+ }> & import("./check.js").Optional<Record<never, never>>>;
56
56
  export type SessionState = Checked<typeof STATE>;
57
57
  export declare const isState: Check<SessionState>;
58
58
  export declare function standingState(state: SessionState, saved: string, ended: string | null): SessionState;
@@ -1,12 +1,12 @@
1
1
  import { type Check, type Checked } from './check.js';
2
2
  import { type Part } from './parts.js';
3
- declare const OPERATION: Check<import("./check.js").Shaped<{
3
+ declare const OPERATION: Check<(import("./check.js").Shaped<{
4
4
  readonly op: Check<"start">;
5
5
  readonly index: Check<number>;
6
- readonly part: Check<import("./check.js").Shaped<{
6
+ readonly part: Check<(import("./check.js").Shaped<{
7
7
  readonly type: Check<"text">;
8
8
  readonly text: Check<string>;
9
- }> | import("./check.js").Shaped<{
9
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
10
10
  readonly commands: Check<number>;
11
11
  readonly edited: Check<number>;
12
12
  readonly other: Check<number>;
@@ -14,27 +14,27 @@ declare const OPERATION: Check<import("./check.js").Shaped<{
14
14
  readonly removed: Check<number>;
15
15
  readonly failed: Check<number>;
16
16
  readonly type: Check<"counts">;
17
- }> | import("./check.js").Shaped<{
17
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
18
18
  readonly type: Check<"image">;
19
19
  readonly file: Check<string>;
20
20
  readonly name: Check<string>;
21
21
  readonly media_type: Check<string>;
22
- }> | import("./check.js").Shaped<{
22
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
23
23
  readonly type: Check<"notice">;
24
24
  readonly kind: Check<"compaction" | "error" | "info" | "mode" | "model" | "retry" | "warning">;
25
25
  readonly text: Check<string>;
26
- }>>;
27
- }> | import("./check.js").Shaped<{
26
+ }> & import("./check.js").Optional<Record<never, never>>)>;
27
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
28
28
  readonly op: Check<"append">;
29
29
  readonly index: Check<number>;
30
30
  readonly text: Check<string>;
31
- }> | import("./check.js").Shaped<{
31
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
32
32
  readonly op: Check<"set">;
33
33
  readonly index: Check<number>;
34
- readonly part: Check<import("./check.js").Shaped<{
34
+ readonly part: Check<(import("./check.js").Shaped<{
35
35
  readonly type: Check<"text">;
36
36
  readonly text: Check<string>;
37
- }> | import("./check.js").Shaped<{
37
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
38
38
  readonly commands: Check<number>;
39
39
  readonly edited: Check<number>;
40
40
  readonly other: Check<number>;
@@ -42,24 +42,35 @@ declare const OPERATION: Check<import("./check.js").Shaped<{
42
42
  readonly removed: Check<number>;
43
43
  readonly failed: Check<number>;
44
44
  readonly type: Check<"counts">;
45
- }> | import("./check.js").Shaped<{
45
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
46
46
  readonly type: Check<"image">;
47
47
  readonly file: Check<string>;
48
48
  readonly name: Check<string>;
49
49
  readonly media_type: Check<string>;
50
- }> | import("./check.js").Shaped<{
50
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
51
51
  readonly type: Check<"notice">;
52
52
  readonly kind: Check<"compaction" | "error" | "info" | "mode" | "model" | "retry" | "warning">;
53
53
  readonly text: Check<string>;
54
- }>>;
55
- }>>;
54
+ }> & import("./check.js").Optional<Record<never, never>>)>;
55
+ }> & import("./check.js").Optional<Record<never, never>>)>;
56
56
  export type Operation = Checked<typeof OPERATION>;
57
57
  export declare const isOperation: Check<Operation>;
58
+ declare const MODEL_TOKENS: Check<import("./check.js").Shaped<{
59
+ readonly model: Check<string | null>;
60
+ }> & import("./check.js").Optional<{
61
+ readonly input: Check<number>;
62
+ readonly cache_write: Check<number>;
63
+ readonly cache_write_5m: Check<number>;
64
+ readonly cache_write_1h: Check<number>;
65
+ readonly cache_read: Check<number>;
66
+ readonly output: Check<number>;
67
+ }>>;
68
+ export type ModelTokens = Checked<typeof MODEL_TOKENS>;
58
69
  declare const TURN: Check<import("./check.js").Shaped<{
59
- readonly parts: Check<readonly (import("./check.js").Shaped<{
70
+ readonly parts: Check<readonly ((import("./check.js").Shaped<{
60
71
  readonly type: Check<"text">;
61
72
  readonly text: Check<string>;
62
- }> | import("./check.js").Shaped<{
73
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
63
74
  readonly commands: Check<number>;
64
75
  readonly edited: Check<number>;
65
76
  readonly other: Check<number>;
@@ -67,70 +78,74 @@ declare const TURN: Check<import("./check.js").Shaped<{
67
78
  readonly removed: Check<number>;
68
79
  readonly failed: Check<number>;
69
80
  readonly type: Check<"counts">;
70
- }> | import("./check.js").Shaped<{
81
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
71
82
  readonly type: Check<"image">;
72
83
  readonly file: Check<string>;
73
84
  readonly name: Check<string>;
74
85
  readonly media_type: Check<string>;
75
- }> | import("./check.js").Shaped<{
86
+ }> & import("./check.js").Optional<Record<never, never>>) | (import("./check.js").Shaped<{
76
87
  readonly type: Check<"notice">;
77
88
  readonly kind: Check<"compaction" | "error" | "info" | "mode" | "model" | "retry" | "warning">;
78
89
  readonly text: Check<string>;
79
- }>)[]>;
80
- readonly tokens: Check<import("./check.js").Shaped<{
90
+ }> & import("./check.js").Optional<Record<never, never>>))[]>;
91
+ readonly tokens: Check<readonly (import("./check.js").Shaped<{
92
+ readonly model: Check<string | null>;
93
+ }> & import("./check.js").Optional<{
81
94
  readonly input: Check<number>;
82
- readonly output: Check<number>;
83
- readonly cache_read: Check<number>;
84
95
  readonly cache_write: Check<number>;
85
- }> | null>;
96
+ readonly cache_write_5m: Check<number>;
97
+ readonly cache_write_1h: Check<number>;
98
+ readonly cache_read: Check<number>;
99
+ readonly output: Check<number>;
100
+ }>)[]>;
86
101
  readonly state: Check<import("./check.js").Shaped<{
87
102
  readonly title: Check<string | null>;
88
- readonly context: Check<import("./check.js").Shaped<{
103
+ readonly context: Check<(import("./check.js").Shaped<{
89
104
  readonly used: Check<number>;
90
105
  readonly window: Check<number>;
91
- readonly breakdown: Check<readonly import("./check.js").Shaped<{
106
+ readonly breakdown: Check<readonly (import("./check.js").Shaped<{
92
107
  readonly name: Check<string>;
93
108
  readonly tokens: Check<number>;
94
- }>[]>;
95
- }> | null>;
96
- readonly limits: Check<readonly import("./check.js").Shaped<{
109
+ }> & import("./check.js").Optional<Record<never, never>>)[]>;
110
+ }> & import("./check.js").Optional<Record<never, never>>) | null>;
111
+ readonly limits: Check<readonly (import("./check.js").Shaped<{
97
112
  readonly name: Check<string | null>;
98
113
  readonly minutes: Check<number>;
99
114
  readonly percent: Check<number>;
100
115
  readonly resets: Check<string | null>;
101
- }>[]>;
102
- readonly cost: Check<import("./check.js").Shaped<{
116
+ }> & import("./check.js").Optional<Record<never, never>>)[]>;
117
+ readonly cost: Check<(import("./check.js").Shaped<{
103
118
  readonly amount: Check<number>;
104
119
  readonly currency: Check<string>;
105
- }> | null>;
106
- readonly tokens: Check<import("./check.js").Shaped<{
120
+ }> & import("./check.js").Optional<Record<never, never>>) | null>;
121
+ readonly tokens: Check<(import("./check.js").Shaped<{
107
122
  readonly input: Check<number>;
108
123
  readonly output: Check<number>;
109
124
  readonly cache_read: Check<number>;
110
125
  readonly cache_write: Check<number>;
111
- }> | null>;
126
+ }> & import("./check.js").Optional<Record<never, never>>) | null>;
112
127
  readonly duration: Check<number | null>;
113
128
  readonly files: Check<import("./check.js").Shaped<{
114
129
  readonly count: Check<number>;
115
130
  readonly added: Check<number>;
116
131
  readonly removed: Check<number>;
117
- }>>;
132
+ }> & import("./check.js").Optional<Record<never, never>>>;
118
133
  readonly branch: Check<string | null>;
119
134
  readonly worktree: Check<string | null>;
120
- readonly pull: Check<import("./check.js").Shaped<{
135
+ readonly pull: Check<(import("./check.js").Shaped<{
121
136
  readonly number: Check<number>;
122
137
  readonly url: Check<string>;
123
- }> | null>;
138
+ }> & import("./check.js").Optional<Record<never, never>>) | null>;
124
139
  readonly model: Check<string | null>;
125
140
  readonly effort: Check<string | null>;
126
141
  readonly mode: Check<string | null>;
127
142
  readonly suggestion: Check<string | null>;
128
- readonly running: Check<readonly import("./check.js").Shaped<{
143
+ readonly running: Check<readonly (import("./check.js").Shaped<{
129
144
  readonly kind: Check<"monitor" | "schedule" | "shell" | "subagent" | "task">;
130
145
  readonly count: Check<number>;
131
- }>[]>;
132
- }>>;
133
- }>>;
146
+ }> & import("./check.js").Optional<Record<never, never>>)[]>;
147
+ }> & import("./check.js").Optional<Record<never, never>>>;
148
+ }> & import("./check.js").Optional<Record<never, never>>>;
134
149
  export type Turn = Checked<typeof TURN>;
135
150
  export declare const isTurn: Check<Turn>;
136
151
  export declare function applied(parts: readonly Part[], operation: Operation): readonly Part[] | null;
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,OAAO,EASR,MAAM,wBAAwB,CAAC;AAchC,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAuCxB,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,QAAQ,UAAQ,GAAG,OAAO,CA2K1F"}
package/dist/site.js CHANGED
@@ -6,9 +6,16 @@ import { answeredFailure, discoveryFailure } from './refusal.js';
6
6
  import { admittedPath } from './authored-path.js';
7
7
  import { siteQuery } from './room-query.js';
8
8
  import { houseNotifications } from './stream.js';
9
- import { houseSiteRoute, SITE_DOOR_ACTS, SITE_FILES, } from './transport.js';
9
+ import { houseSiteRoute, SITE_DOOR_ACTS, SITE_DOOR_TOOL, SITE_FILES, } from './transport.js';
10
10
  import { UNANSWERED, unusable } from './uncertain.js';
11
11
  import { followsVersion, reachedVersion, roomVersion } from './version.js';
12
+ function siteDoorRequest(request) {
13
+ const { op, ...input } = (request.input ?? {});
14
+ if (request.name !== SITE_DOOR_TOOL || typeof op !== 'string')
15
+ return request;
16
+ const named = Object.entries(SITE_DOOR_ACTS).find(([, act]) => act.op === op);
17
+ return named === undefined ? request : { ...request, name: named[0], input };
18
+ }
12
19
  function unfound() {
13
20
  return { kind: 'rejected', code: 'not_found', fields: {}, retryable: false };
14
21
  }
@@ -131,7 +138,7 @@ export function createSiteAdapter(transport, snapshot = false) {
131
138
  async history() {
132
139
  return { kind: 'no-history' };
133
140
  },
134
- queryHouse: snapshot ? undefined : (_authorization, request) => siteQuery(transport, request),
141
+ queryHouse: (_authorization, request) => siteQuery(transport, request),
135
142
  async binary(_authorization, request) {
136
143
  const route = fileRoute(request);
137
144
  if (typeof route !== 'string')
@@ -169,9 +176,10 @@ export function createSiteAdapter(transport, snapshot = false) {
169
176
  follows(_locator, version, next) {
170
177
  return followsVersion(version, next);
171
178
  },
172
- async action(_authorization, request) {
179
+ async action(_authorization, asked) {
180
+ const request = siteDoorRequest(asked);
173
181
  const route = Object.hasOwn(SITE_DOOR_ACTS, request.name)
174
- ? SITE_DOOR_ACTS[request.name]
182
+ ? SITE_DOOR_ACTS[request.name].route
175
183
  : null;
176
184
  if (route === null) {
177
185
  return {
package/dist/stream.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type AuthorityChange, type Discovery, type ConversationStream, type HeldRoom, type RoomStreamEvent, type ServiceModeSignal } from '@agentshouse/mdruntime';
1
+ import { type AuthorityChange, type Discovery, type ConversationStream, type HeldRoom, type RoomStreamEvent, type RunStream, type ServiceModeSignal } from '@agentshouse/mdruntime';
2
2
  import type { TrackedAuthority } from './discovery.js';
3
3
  import { type HouseDoor, type HouseMode, type HouseStreamFrame } from './transport.js';
4
4
  export type HouseOpeningFrame = Extract<HouseStreamFrame, {
@@ -18,6 +18,7 @@ export type HouseNotifications = {
18
18
  send(rooms: readonly HeldRoom[]): void;
19
19
  track(authorities: readonly TrackedAuthority[]): void;
20
20
  conversations: ConversationStream;
21
+ runs: RunStream;
21
22
  serviceMode: ServiceModeSignal;
22
23
  };
23
24
  export declare function houseNotifications(transport: HouseDoor, mode: HouseMode, discovering: HouseDiscovering): HouseNotifications;
@@ -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;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;C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