@agentshouse/mdruntime-adapter 0.1.0-c2806486363ef → 0.1.0-c2880bd12f733
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 +112 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +1 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +23 -172
- package/dist/house-model.d.ts +2950 -1
- package/dist/house-model.d.ts.map +1 -1
- package/dist/house-model.js +1627 -488
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/model.d.ts +1 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -17
- package/dist/read.d.ts +1 -44
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +2 -173
- package/dist/refusal.d.ts +0 -3
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +0 -5
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +1 -0
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +20 -71
- package/dist/stream.d.ts +3 -13
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +79 -413
- package/dist/transport.d.ts +14 -32
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +48 -12
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +2 -2
- package/package.json +2 -2
- package/dist/gather.d.ts +0 -3
- package/dist/gather.d.ts.map +0 -1
- package/dist/gather.js +0 -35
package/dist/actions.d.ts
CHANGED
|
@@ -39,6 +39,118 @@ export type AppAnswerAdditions = {
|
|
|
39
39
|
readonly turn: string;
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
|
+
type AppAct<Input = unknown> = {
|
|
43
|
+
readonly door: string;
|
|
44
|
+
readonly batched?: readonly string[];
|
|
45
|
+
carry(transport: HouseActDoor, input: Input, name: string): Promise<ActionResult>;
|
|
46
|
+
};
|
|
47
|
+
declare const APP_ACTS: {
|
|
48
|
+
'access.read': AppAct<unknown> & {
|
|
49
|
+
readonly door: "rooms/access/read";
|
|
50
|
+
};
|
|
51
|
+
'conversation.answer': AppAct<Operated & {
|
|
52
|
+
readonly conversation: string;
|
|
53
|
+
} & {
|
|
54
|
+
readonly answer: {
|
|
55
|
+
readonly interaction_id: string;
|
|
56
|
+
readonly response: unknown;
|
|
57
|
+
};
|
|
58
|
+
}> & {
|
|
59
|
+
readonly door: "conversations/interaction/answer";
|
|
60
|
+
};
|
|
61
|
+
'conversation.create': AppAct<Operated & {
|
|
62
|
+
readonly agent_id: string;
|
|
63
|
+
readonly replaces?: string;
|
|
64
|
+
}> & {
|
|
65
|
+
readonly door: "conversations/create";
|
|
66
|
+
};
|
|
67
|
+
'conversation.delete': AppAct<ConversationControl> & {
|
|
68
|
+
readonly door: "conversations/delete";
|
|
69
|
+
};
|
|
70
|
+
'conversation.history': AppAct<ConversationHistoryRequest> & {
|
|
71
|
+
readonly door: "conversations/history";
|
|
72
|
+
};
|
|
73
|
+
'conversation.interrupt': AppAct<ConversationControl> & {
|
|
74
|
+
readonly door: "conversations/interrupt";
|
|
75
|
+
};
|
|
76
|
+
'conversation.kill': AppAct<ConversationControl> & {
|
|
77
|
+
readonly door: "conversations/kill";
|
|
78
|
+
};
|
|
79
|
+
'conversation.markDone': AppAct<unknown> & {
|
|
80
|
+
readonly door: "conversations/done";
|
|
81
|
+
};
|
|
82
|
+
'conversation.rename': AppAct<unknown> & {
|
|
83
|
+
readonly door: "conversations/rename";
|
|
84
|
+
};
|
|
85
|
+
'conversation.retry': AppAct<unknown> & {
|
|
86
|
+
readonly door: "conversations/retry";
|
|
87
|
+
};
|
|
88
|
+
'conversation.send': AppAct<Operated & {
|
|
89
|
+
readonly conversation: string;
|
|
90
|
+
} & {
|
|
91
|
+
readonly operation_id: string;
|
|
92
|
+
readonly text: string;
|
|
93
|
+
}> & {
|
|
94
|
+
readonly door: "conversations/send";
|
|
95
|
+
};
|
|
96
|
+
'conversation.setOption': AppAct<unknown> & {
|
|
97
|
+
readonly door: "conversations/option";
|
|
98
|
+
};
|
|
99
|
+
'feature.list': AppAct<unknown> & {
|
|
100
|
+
readonly door: "apps/features/read";
|
|
101
|
+
};
|
|
102
|
+
'holder.list': AppAct<unknown> & {
|
|
103
|
+
readonly door: "apps/holders";
|
|
104
|
+
};
|
|
105
|
+
'holder.ring': AppAct<unknown> & {
|
|
106
|
+
readonly door: "apps/ring";
|
|
107
|
+
};
|
|
108
|
+
'inboxChat.assign': AppAct<unknown> & {
|
|
109
|
+
readonly door: "chats/assign";
|
|
110
|
+
};
|
|
111
|
+
'inboxChat.return': AppAct<unknown> & {
|
|
112
|
+
readonly door: "chats/return";
|
|
113
|
+
};
|
|
114
|
+
'inboxChat.takeControl': AppAct<unknown> & {
|
|
115
|
+
readonly door: "chats/take-control";
|
|
116
|
+
};
|
|
117
|
+
'member.list': AppAct<unknown> & {
|
|
118
|
+
readonly door: "rooms/members";
|
|
119
|
+
};
|
|
120
|
+
'message.send': AppAct<unknown> & {
|
|
121
|
+
readonly door: "apps/messages/send";
|
|
122
|
+
};
|
|
123
|
+
'processing.read': AppAct<unknown> & {
|
|
124
|
+
readonly door: "rooms/settings/processing/read";
|
|
125
|
+
};
|
|
126
|
+
'record.list': AppAct<unknown> & {
|
|
127
|
+
readonly door: "records/read";
|
|
128
|
+
};
|
|
129
|
+
'relay.read': AppAct<unknown> & {
|
|
130
|
+
readonly door: "apps/relay";
|
|
131
|
+
};
|
|
132
|
+
'routine.list': AppAct<unknown> & {
|
|
133
|
+
readonly door: "routines/access";
|
|
134
|
+
};
|
|
135
|
+
'routineAccess.list': AppAct<unknown> & {
|
|
136
|
+
readonly door: "routines/granted";
|
|
137
|
+
};
|
|
138
|
+
'routineAllowance.list': AppAct<unknown> & {
|
|
139
|
+
readonly door: "routines/allowance";
|
|
140
|
+
};
|
|
141
|
+
'routineRequest.list': AppAct<unknown> & {
|
|
142
|
+
readonly door: "routines/requests";
|
|
143
|
+
};
|
|
144
|
+
'storage.read': AppAct<unknown> & {
|
|
145
|
+
readonly door: "storage/inventory";
|
|
146
|
+
};
|
|
147
|
+
'triggerEvent.list': AppAct<unknown> & {
|
|
148
|
+
readonly door: "triggers/fired";
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
export type HouseAppActs = {
|
|
152
|
+
readonly [Name in keyof typeof APP_ACTS]: (typeof APP_ACTS)[Name]['door'];
|
|
153
|
+
};
|
|
42
154
|
export declare const HOUSE_APP_ACTS: Readonly<Record<string, string>>;
|
|
43
155
|
export declare const SITE_SUBMIT = "submit";
|
|
44
156
|
export declare const HOUSE_SITE_ACTS: Readonly<Record<string, string>>;
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAE1B,KAAK,0BAA0B,EAChC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAExD,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC,KAAK,QAAQ,GAAG;IAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,KAAK,mBAAmB,GAAG,QAAQ,GAAG;IAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,qBAAqB,EAAE,mBAAmB,GAAG;QACpD,QAAQ,CAAC,MAAM,EAAE;YAAE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;Y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O,EAAE,MAAM,GAAG,kBAAkB,CAE3E;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAKvF;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,CAAC,CAYvB;AAkFD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAQjF;AA+BD,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AASjE,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE5D;AAUD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAUtE"}
|
package/dist/actions.js
CHANGED
|
@@ -45,7 +45,7 @@ const APP_ACTS = {
|
|
|
45
45
|
'routineAllowance.list': mapped('routines/allowance'),
|
|
46
46
|
'routineRequest.list': mapped('routines/requests'),
|
|
47
47
|
'storage.read': mapped('storage/inventory'),
|
|
48
|
-
'
|
|
48
|
+
'triggerEvent.list': mapped('triggers/fired'),
|
|
49
49
|
};
|
|
50
50
|
export const HOUSE_APP_ACTS = Object.fromEntries(Object.entries(APP_ACTS).map(([name, act]) => [name, act.door]));
|
|
51
51
|
export const SITE_SUBMIT = 'submit';
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EAGP,aAAa,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EAGP,aAAa,EAed,MAAM,wBAAwB,CAAC;AA2BhC,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAmBxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AA6DrD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CA6ZpF"}
|
package/dist/adapter.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { stepped } from '@agentshouse/mdruntime';
|
|
2
2
|
import { DISCOVER_PREFIXES, capabilities, discoveredRoom, mapDiscovery, parseDiscovery, trackedFrom, } from './discovery.js';
|
|
3
|
-
import { streamedModels, viewModels } from './model.js';
|
|
4
|
-
import { gathered, selections } from './gather.js';
|
|
5
3
|
import { createSiteAdapter } from './site.js';
|
|
6
|
-
import { authorityRoot, bootstrapping,
|
|
4
|
+
import { authorityRoot, bootstrapping, parseFileAddress, parseGrant, } from './read.js';
|
|
7
5
|
import { roomStreams } from './room-stream.js';
|
|
8
6
|
import { sha256Hex } from './digest.js';
|
|
9
7
|
import { finishedUpload, houseUpload } from './upload.js';
|
|
10
8
|
import { houseAction } from './actions.js';
|
|
11
|
-
import { classifyDoor,
|
|
9
|
+
import { classifyDoor, discoveryFailure, doorRefusal } from './refusal.js';
|
|
12
10
|
import { houseNotifications } from './stream.js';
|
|
13
|
-
import {
|
|
11
|
+
import { houseDoorRoute, } from './transport.js';
|
|
14
12
|
import { batchPaths, deltaBody, deltaBytes, deltaDigest, historyOutcome, houseChanges, houseMove, mutationOutcome, operationHead, rejectedMapping, revisionBody, uploadable, } from './write.js';
|
|
15
13
|
import { HOUSE_NAMEABLE_ROOM_TYPES, HOUSE_ROOM_TYPES } from './room-types.js';
|
|
16
|
-
import { followsVersion, logPosition, presented, reachedVersion, roomVersion
|
|
14
|
+
import { followsVersion, logPosition, presented, reachedVersion, roomVersion } from './version.js';
|
|
17
15
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
18
16
|
const UNCERTAIN_READ = { kind: 'transport-uncertainty' };
|
|
19
17
|
const OCTET_STREAM = 'application/octet-stream';
|
|
@@ -53,10 +51,8 @@ export function createAgentsHouseAdapter(options) {
|
|
|
53
51
|
const transport = options.transport;
|
|
54
52
|
const notifications = houseNotifications(transport, 'credential');
|
|
55
53
|
const tracked = new Map();
|
|
56
|
-
const handed = new Map();
|
|
57
54
|
const rooms = roomStreams('credential');
|
|
58
55
|
const unreused = new Set();
|
|
59
|
-
let heldRevisions;
|
|
60
56
|
let bounds;
|
|
61
57
|
function declared() {
|
|
62
58
|
if (bounds === undefined)
|
|
@@ -72,11 +68,6 @@ export function createAgentsHouseAdapter(options) {
|
|
|
72
68
|
unreused.add(entry.locator);
|
|
73
69
|
return UNCERTAIN_READ;
|
|
74
70
|
}
|
|
75
|
-
if (part.first && part.ended)
|
|
76
|
-
handed.set(entry.locator, roomVersion(scope));
|
|
77
|
-
else
|
|
78
|
-
handed.delete(entry.locator);
|
|
79
|
-
notifications.reach(entry.authority, scope);
|
|
80
71
|
return {
|
|
81
72
|
...(await stepped(bootstrapping(scope))),
|
|
82
73
|
...(part.models === undefined ? {} : { models: part.models }),
|
|
@@ -89,7 +80,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
89
80
|
const files = reusing === undefined
|
|
90
81
|
? null
|
|
91
82
|
: await heldFiles(entry.authority, reusing, declared().max_held_files);
|
|
92
|
-
const answered = await transport.streamed(
|
|
83
|
+
const answered = await transport.streamed(houseDoorRoute('bootstrap'), {
|
|
93
84
|
prefixes: [authorityRoot(entry.handle)],
|
|
94
85
|
...(files === null ? {} : { held: [files] }),
|
|
95
86
|
}, request.signal ?? new AbortController().signal);
|
|
@@ -97,84 +88,12 @@ export function createAgentsHouseAdapter(options) {
|
|
|
97
88
|
return classifyDoor(answered.status, answered.body, entry.locator) ?? UNCERTAIN_READ;
|
|
98
89
|
return rooms.head(entry, answered.room, request.arriving, request.signal);
|
|
99
90
|
}
|
|
100
|
-
async function enumeratedPage(ask, page) {
|
|
101
|
-
const answer = await transport.door(DOOR_ENUMERATE, {
|
|
102
|
-
prefixes: [authorityRoot(ask.entry.handle)],
|
|
103
|
-
positions: [
|
|
104
|
-
{
|
|
105
|
-
...presented(ask.entry.authority, { position: page.after, logEpoch: ask.from.logEpoch }),
|
|
106
|
-
page: { through: page.through, read: page.read },
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
});
|
|
110
|
-
const failure = classifyRead(answer.status, answer.body, ask.entry.locator);
|
|
111
|
-
if (failure !== null)
|
|
112
|
-
return failure;
|
|
113
|
-
const enumeration = parseEnumeration(answer.body, 'credential');
|
|
114
|
-
if (enumeration === null)
|
|
115
|
-
return UNCERTAIN_READ;
|
|
116
|
-
return (viewOf(enumeration, ask.entry) ?? { kind: 'room-not-readable', locator: ask.entry.locator });
|
|
117
|
-
}
|
|
118
|
-
async function enumeratedRoom(enumeration, ask) {
|
|
119
|
-
const first = viewOf(enumeration, ask.entry);
|
|
120
|
-
if (first === undefined)
|
|
121
|
-
return { kind: 'room-not-readable', locator: ask.entry.locator };
|
|
122
|
-
const view = await wholeView(first, (page) => enumeratedPage(ask, page));
|
|
123
|
-
if ('kind' in view)
|
|
124
|
-
return view;
|
|
125
|
-
notifications.reach(ask.entry.authority, view);
|
|
126
|
-
const answer = await refreshFrom(view, ask.fromRoomVersion);
|
|
127
|
-
if (answer.kind !== 'net-advancement')
|
|
128
|
-
return answer;
|
|
129
|
-
handed.set(ask.entry.locator, roomVersion(view));
|
|
130
|
-
const models = await viewModels(view, ask.entry);
|
|
131
|
-
return models === undefined ? answer : { ...answer, models };
|
|
132
|
-
}
|
|
133
|
-
async function streamed(entry, request, from) {
|
|
134
|
-
if (handed.get(entry.locator) !== request.fromRoomVersion)
|
|
135
|
-
return null;
|
|
136
|
-
const asked = notifications.edited(entry, from);
|
|
137
|
-
const kept = asked.length === 0 || heldRevisions === undefined
|
|
138
|
-
? new Map()
|
|
139
|
-
: await heldRevisions(entry.locator, asked);
|
|
140
|
-
const advanced = await stepped(notifications.advance(entry, from, (path, revision) => kept.get(path) === revision));
|
|
141
|
-
if (advanced === null)
|
|
142
|
-
return null;
|
|
143
|
-
handed.set(entry.locator, advanced.page.roomVersion);
|
|
144
|
-
const models = await streamedModels(advanced.schemas, entry, 'credential');
|
|
145
|
-
return models === undefined ? advanced.page : { ...advanced.page, models };
|
|
146
|
-
}
|
|
147
91
|
function held(rooms) {
|
|
148
|
-
|
|
92
|
+
notifications.send(rooms.flatMap((room) => {
|
|
149
93
|
const entry = tracked.get(room.locator);
|
|
150
94
|
const at = logPosition(room.roomVersion);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
handed.set(room.locator, room.roomVersion);
|
|
154
|
-
notifications.reach(entry.authority, at);
|
|
155
|
-
return [presented(entry.authority, at)];
|
|
156
|
-
});
|
|
157
|
-
notifications.send(kept);
|
|
158
|
-
}
|
|
159
|
-
async function adoptedMove(entry, into, outcome) {
|
|
160
|
-
if (outcome.kind === 'accepted' && outcome.destination !== undefined) {
|
|
161
|
-
await adopted(into, { kind: 'accepted', ...outcome.destination });
|
|
162
|
-
}
|
|
163
|
-
return adopted(entry, outcome);
|
|
164
|
-
}
|
|
165
|
-
async function adopted(entry, outcome) {
|
|
166
|
-
if (outcome.kind !== 'accepted')
|
|
167
|
-
return outcome;
|
|
168
|
-
const held = handed.get(entry.locator);
|
|
169
|
-
if (held === undefined)
|
|
170
|
-
return outcome;
|
|
171
|
-
const follows = followsVersion(held, outcome.roomVersion);
|
|
172
|
-
if (follows)
|
|
173
|
-
handed.set(entry.locator, outcome.roomVersion);
|
|
174
|
-
const at = logPosition(outcome.roomVersion);
|
|
175
|
-
if (follows && at !== null)
|
|
176
|
-
notifications.reach(entry.authority, at);
|
|
177
|
-
return outcome;
|
|
95
|
+
return entry === undefined || at === null ? [] : [presented(entry.authority, at)];
|
|
96
|
+
}));
|
|
178
97
|
}
|
|
179
98
|
function authorityFor(locator) {
|
|
180
99
|
return tracked.get(locator);
|
|
@@ -193,60 +112,18 @@ export function createAgentsHouseAdapter(options) {
|
|
|
193
112
|
return result;
|
|
194
113
|
return { ...result, at: { locator, roomVersion: roomVersion({ position, logEpoch }) } };
|
|
195
114
|
}
|
|
196
|
-
function layered(asks) {
|
|
197
|
-
const depths = new Map();
|
|
198
|
-
const layers = [];
|
|
199
|
-
for (const ask of asks) {
|
|
200
|
-
const depth = depths.get(ask.ask.entry.authority) ?? 0;
|
|
201
|
-
depths.set(ask.ask.entry.authority, depth + 1);
|
|
202
|
-
(layers[depth] ??= []).push(ask);
|
|
203
|
-
}
|
|
204
|
-
return layers;
|
|
205
|
-
}
|
|
206
|
-
async function enumerated(asks) {
|
|
207
|
-
const answers = [];
|
|
208
|
-
const parts = layered(asks.map((ask, index) => ({ ask, index }))).flatMap((layer) => selections(layer, declared().max_prefixes));
|
|
209
|
-
for (const part of parts) {
|
|
210
|
-
let open = [...part];
|
|
211
|
-
while (open.length > 0) {
|
|
212
|
-
const answer = await transport.door(DOOR_ENUMERATE, {
|
|
213
|
-
prefixes: open.map(({ ask }) => authorityRoot(ask.entry.handle)),
|
|
214
|
-
positions: open.map(({ ask }) => presented(ask.entry.authority, ask.from)),
|
|
215
|
-
});
|
|
216
|
-
const classified = open.map(({ ask }) => classifyRead(answer.status, answer.body, ask.entry.locator));
|
|
217
|
-
if (classified[0]?.kind === 'beyond-horizon') {
|
|
218
|
-
const named = doorRefusal(answer.body)?.fields.authority;
|
|
219
|
-
const expired = open.filter(({ ask }) => ask.entry.authority === named);
|
|
220
|
-
const answered = expired.length === 0 ? UNCERTAIN_READ : { kind: 'beyond-horizon' };
|
|
221
|
-
const gone = expired.length === 0 ? open : expired;
|
|
222
|
-
for (const ask of gone)
|
|
223
|
-
answers[ask.index] = answered;
|
|
224
|
-
open = open.filter((ask) => !gone.includes(ask));
|
|
225
|
-
continue;
|
|
226
|
-
}
|
|
227
|
-
const enumeration = classified[0] === null ? parseEnumeration(answer.body, 'credential') : null;
|
|
228
|
-
for (const [answerIndex, { ask, index }] of open.entries()) {
|
|
229
|
-
const failure = classified[answerIndex];
|
|
230
|
-
if (failure !== null && failure !== undefined) {
|
|
231
|
-
answers[index] = failure;
|
|
232
|
-
continue;
|
|
233
|
-
}
|
|
234
|
-
answers[index] =
|
|
235
|
-
enumeration === null ? UNCERTAIN_READ : await enumeratedRoom(enumeration, ask);
|
|
236
|
-
}
|
|
237
|
-
open = [];
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return answers;
|
|
241
|
-
}
|
|
242
|
-
const enumerateTogether = gathered(enumerated);
|
|
243
115
|
async function uploaded(head, changes, delta, bytes, entry, handed, keep) {
|
|
244
116
|
const paths = batchPaths(changes);
|
|
245
117
|
const sha256 = await deltaDigest(delta);
|
|
246
118
|
if (handed !== undefined && handed.sha256 === sha256) {
|
|
247
119
|
return { body: { ...head, paths, upload: handed, runtime: notifications.runtime } };
|
|
248
120
|
}
|
|
249
|
-
const minted = await transport.door(
|
|
121
|
+
const minted = await transport.door(houseDoorRoute('batch-upload'), {
|
|
122
|
+
...head,
|
|
123
|
+
paths,
|
|
124
|
+
bytes,
|
|
125
|
+
sha256,
|
|
126
|
+
});
|
|
250
127
|
if (minted.status !== 200) {
|
|
251
128
|
return {
|
|
252
129
|
outcome: await stepped(mutationOutcome(minted.status, minted.body, entry.locator, entry.handle)),
|
|
@@ -294,11 +171,11 @@ export function createAgentsHouseAdapter(options) {
|
|
|
294
171
|
: { body: inline };
|
|
295
172
|
if ('outcome' in prepared)
|
|
296
173
|
return prepared.outcome;
|
|
297
|
-
const answer = await transport.door(
|
|
174
|
+
const answer = await transport.door(houseDoorRoute('batch'), prepared.body);
|
|
298
175
|
const stagedFiles = await staged(answer, request);
|
|
299
176
|
if (stagedFiles === false)
|
|
300
177
|
return UNCERTAIN;
|
|
301
|
-
const settled = stagedFiles === null ? answer : await transport.door(
|
|
178
|
+
const settled = stagedFiles === null ? answer : await transport.door(houseDoorRoute('batch'), prepared.body);
|
|
302
179
|
if (stagedFiles === true && (await staged(settled, request)) !== null)
|
|
303
180
|
return UNCERTAIN;
|
|
304
181
|
return stepped(mutationOutcome(settled.status, settled.body, entry.locator, entry.handle, into === undefined
|
|
@@ -366,7 +243,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
366
243
|
const entry = authorityFor(request.locator);
|
|
367
244
|
if (entry === undefined)
|
|
368
245
|
return null;
|
|
369
|
-
return () => transport.door(
|
|
246
|
+
return () => transport.door(houseDoorRoute('files/get'), {
|
|
370
247
|
room_ref: entry.authority,
|
|
371
248
|
path: request.path,
|
|
372
249
|
revision: request.revision,
|
|
@@ -379,7 +256,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
379
256
|
return options.authorize();
|
|
380
257
|
},
|
|
381
258
|
async discover(_authorization, scope) {
|
|
382
|
-
const answer = await transport.door(
|
|
259
|
+
const answer = await transport.door(houseDoorRoute('discover'), {
|
|
383
260
|
prefixes: [...DISCOVER_PREFIXES],
|
|
384
261
|
...(scope === undefined ? {} : { rooms: scope.authorities }),
|
|
385
262
|
});
|
|
@@ -408,9 +285,6 @@ export function createAgentsHouseAdapter(options) {
|
|
|
408
285
|
tracked.delete(locator);
|
|
409
286
|
for (const entry of entries)
|
|
410
287
|
tracked.set(entry.locator, entry);
|
|
411
|
-
for (const locator of handed.keys())
|
|
412
|
-
if (!tracked.has(locator))
|
|
413
|
-
handed.delete(locator);
|
|
414
288
|
notifications.track([...tracked.values()]);
|
|
415
289
|
return {
|
|
416
290
|
...mapDiscovery(document, document.authorities.map((authority) => discoveredRoom(authority)), capabilities(document.actions, [...tracked.values()])),
|
|
@@ -426,20 +300,6 @@ export function createAgentsHouseAdapter(options) {
|
|
|
426
300
|
? openedRoom(entry, request)
|
|
427
301
|
: streamedPage(entry, request.pageToken, request.held);
|
|
428
302
|
},
|
|
429
|
-
async refresh(_authorization, request) {
|
|
430
|
-
const entry = authorityFor(request.locator);
|
|
431
|
-
if (entry === undefined)
|
|
432
|
-
return { kind: 'room-not-readable', locator: request.locator };
|
|
433
|
-
if (request.pageToken !== undefined)
|
|
434
|
-
return { kind: 'transport-uncertainty' };
|
|
435
|
-
const from = logPosition(request.fromRoomVersion);
|
|
436
|
-
if (from === null)
|
|
437
|
-
return { kind: 'beyond-horizon' };
|
|
438
|
-
const answered = await streamed(entry, request, from);
|
|
439
|
-
if (answered !== null)
|
|
440
|
-
return answered;
|
|
441
|
-
return enumerateTogether({ entry, from, fromRoomVersion: request.fromRoomVersion });
|
|
442
|
-
},
|
|
443
303
|
async mutate(_authorization, request, keep) {
|
|
444
304
|
const entry = authorityFor(request.locator);
|
|
445
305
|
if (entry === undefined)
|
|
@@ -460,17 +320,16 @@ export function createAgentsHouseAdapter(options) {
|
|
|
460
320
|
const bytes = deltaBytes(delta);
|
|
461
321
|
const handed = request.upload;
|
|
462
322
|
const answer = (upload) => submit(request, head, mapped.changes, delta, bytes, entry, upload, keep, into);
|
|
463
|
-
const settle = (outcome) => into === undefined ? adopted(entry, outcome) : adoptedMove(entry, into, outcome);
|
|
464
323
|
const outcome = await answer(handed);
|
|
465
324
|
if (handed === undefined || !lapsedGrant(outcome))
|
|
466
|
-
return
|
|
467
|
-
return
|
|
325
|
+
return outcome;
|
|
326
|
+
return answer(undefined);
|
|
468
327
|
},
|
|
469
328
|
async history(_authorization, request) {
|
|
470
329
|
const entry = authorityFor(request.locator);
|
|
471
330
|
if (entry === undefined)
|
|
472
331
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
473
|
-
const answer = await transport.door(
|
|
332
|
+
const answer = await transport.door(houseDoorRoute('revisions'), revisionBody({
|
|
474
333
|
path: request.path,
|
|
475
334
|
handle: entry.handle,
|
|
476
335
|
...(request.revision === undefined ? {} : { revision: request.revision }),
|
|
@@ -497,7 +356,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
497
356
|
const entry = authorityFor(request.locator);
|
|
498
357
|
if (entry === undefined)
|
|
499
358
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
500
|
-
const declared = await transport.door(
|
|
359
|
+
const declared = await transport.door(houseDoorRoute('files/attach'), {
|
|
501
360
|
room_ref: entry.authority,
|
|
502
361
|
name: request.name,
|
|
503
362
|
bytes: request.byteLength,
|
|
@@ -534,15 +393,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
534
393
|
roomStream: {
|
|
535
394
|
hold: held,
|
|
536
395
|
reopen: notifications.reopen,
|
|
537
|
-
observe
|
|
538
|
-
heldRevisions = revisions;
|
|
539
|
-
return notifications.observe(notify, receipts);
|
|
540
|
-
},
|
|
541
|
-
published(locator, roomVersion) {
|
|
542
|
-
const at = logPosition(roomVersion);
|
|
543
|
-
if (at !== null)
|
|
544
|
-
notifications.published(locator, at);
|
|
545
|
-
},
|
|
396
|
+
observe: notifications.observe,
|
|
546
397
|
},
|
|
547
398
|
conversations: notifications.conversations,
|
|
548
399
|
serviceMode: notifications.serviceMode,
|