@chopin-ai/harness-pi 0.0.0-stage → 0.2.0
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/LICENSE +202 -0
- package/dist/acp.d.ts +42 -0
- package/dist/acp.js +122 -0
- package/dist/acp.js.map +1 -0
- package/dist/auth.d.ts +25 -0
- package/dist/auth.js +56 -0
- package/dist/auth.js.map +1 -0
- package/dist/backoff.d.ts +5 -0
- package/dist/backoff.js +13 -0
- package/dist/backoff.js.map +1 -0
- package/dist/bridge.d.ts +11 -0
- package/dist/bridge.js +259 -0
- package/dist/bridge.js.map +1 -0
- package/dist/http.d.ts +7 -0
- package/dist/http.js +73 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/layer.d.ts +8 -0
- package/dist/layer.js +84 -0
- package/dist/layer.js.map +1 -0
- package/dist/mcp.d.ts +24 -0
- package/dist/mcp.js +126 -0
- package/dist/mcp.js.map +1 -0
- package/dist/mode.d.ts +11 -0
- package/dist/mode.js +33 -0
- package/dist/mode.js.map +1 -0
- package/dist/pages.d.ts +8 -0
- package/dist/pages.js +12 -0
- package/dist/pages.js.map +1 -0
- package/dist/project-context.d.ts +18 -0
- package/dist/project-context.js +77 -0
- package/dist/project-context.js.map +1 -0
- package/dist/protocol.d.ts +247 -0
- package/dist/protocol.js +327 -0
- package/dist/protocol.js.map +1 -0
- package/dist/server.d.ts +25 -0
- package/dist/server.js +349 -0
- package/dist/server.js.map +1 -0
- package/dist/service.d.ts +96 -0
- package/dist/service.js +493 -0
- package/dist/service.js.map +1 -0
- package/dist/shell.d.ts +31 -0
- package/dist/shell.js +57 -0
- package/dist/shell.js.map +1 -0
- package/dist/submissions.d.ts +22 -0
- package/dist/submissions.js +33 -0
- package/dist/submissions.js.map +1 -0
- package/package.json +48 -3
- package/README.md +0 -3
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { createHost, hostNamed, isChordError, method, remote, webSocketLink } from "@earendil-works/chord";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
import { unansweredText } from "./acp.js";
|
|
4
|
+
import { backoff } from "./backoff.js";
|
|
5
|
+
export const HOST = "chopin";
|
|
6
|
+
/** What a conversation may do: `read` admits only tools that change nothing; `full` admits every tool. */
|
|
7
|
+
export const ModeSchema = Type.Union([Type.Literal("read"), Type.Literal("full")]);
|
|
8
|
+
export const MODES = ModeSchema.anyOf.map((literal) => literal.const);
|
|
9
|
+
/** How a submission made through this object ended, or that it has not yet. */
|
|
10
|
+
export const SubmissionSchema = Type.Union([
|
|
11
|
+
Type.Object({ status: Type.Literal("pending") }),
|
|
12
|
+
Type.Object({ status: Type.Literal("done") }),
|
|
13
|
+
Type.Object({ status: Type.Literal("unanswered"), reason: Type.String(), detail: Type.Optional(Type.String()) }),
|
|
14
|
+
]);
|
|
15
|
+
/**
|
|
16
|
+
* Why the latest submission got no answer, unless it was stopped on purpose; `undefined` while it runs or once it
|
|
17
|
+
* was answered.
|
|
18
|
+
*/
|
|
19
|
+
export function lastFailure(submissions) {
|
|
20
|
+
const latest = Object.keys(submissions).map(Number).sort((a, b) => b - a)[0];
|
|
21
|
+
const outcome = latest === undefined ? undefined : submissions[String(latest)];
|
|
22
|
+
return outcome?.status === "unanswered" && outcome.reason !== "aborted" ? unansweredText(outcome) : undefined;
|
|
23
|
+
}
|
|
24
|
+
const ForkArgs = Type.Object({ conversation: Type.Number(), at: Type.Number() });
|
|
25
|
+
/** `request`, chosen by the client, makes sending the same message again harmless: it is admitted once. */
|
|
26
|
+
const SubmitArgs = Type.Object({
|
|
27
|
+
text: Type.String({ minLength: 1 }),
|
|
28
|
+
steer: Type.Optional(Type.Boolean()),
|
|
29
|
+
request: Type.Optional(Type.String({ minLength: 1 })),
|
|
30
|
+
});
|
|
31
|
+
const ModeArgs = Type.Object({ mode: ModeSchema });
|
|
32
|
+
/** A model as the model library names it: its provider and its id there. */
|
|
33
|
+
const ModelArgs = Type.Object({ provider: Type.String({ minLength: 1 }), modelId: Type.String({ minLength: 1 }) });
|
|
34
|
+
const NoArgs = Type.Object({});
|
|
35
|
+
const NameArgs = Type.Object({ name: Type.String({ maxLength: 200 }) });
|
|
36
|
+
/** A thinking level as the model library names them; the service takes only those the conversation's model has. */
|
|
37
|
+
const ThinkingArgs = Type.Object({ level: Type.String({ minLength: 1 }) });
|
|
38
|
+
const CompactArgs = Type.Object({ instructions: Type.Optional(Type.String()) });
|
|
39
|
+
/** A command of the user's, run in the workspace; an excluded one the model never sees. */
|
|
40
|
+
const ShellArgs = Type.Object({ command: Type.String({ minLength: 1 }), excluded: Type.Optional(Type.Boolean()) });
|
|
41
|
+
const Texts = Type.Array(Type.String());
|
|
42
|
+
/** The command the user is running in a conversation and its output so far; null while none runs. */
|
|
43
|
+
export const RunningSchema = Type.Union([
|
|
44
|
+
Type.Null(),
|
|
45
|
+
Type.Object({ command: Type.String(), output: Type.String(), excluded: Type.Boolean() }),
|
|
46
|
+
]);
|
|
47
|
+
/**
|
|
48
|
+
* What an owner's agent loads besides its tools: whether the layer has instructions, the paths of the project's
|
|
49
|
+
* instruction files in the workspace, the skills, the MCP servers.
|
|
50
|
+
*/
|
|
51
|
+
export const LoadedSchema = Type.Object({
|
|
52
|
+
instructions: Type.Boolean(),
|
|
53
|
+
projectInstructions: Type.Array(Type.String()),
|
|
54
|
+
skills: Type.Array(Type.String()),
|
|
55
|
+
mcpServers: Type.Array(Type.String()),
|
|
56
|
+
});
|
|
57
|
+
/** A line about one conversation, for picking one to resume: times in milliseconds since the epoch. */
|
|
58
|
+
export const SummarySchema = Type.Object({
|
|
59
|
+
id: Type.Number(),
|
|
60
|
+
name: Type.String(),
|
|
61
|
+
first: Type.String(),
|
|
62
|
+
messages: Type.Number(),
|
|
63
|
+
created: Type.Number(),
|
|
64
|
+
modified: Type.Number(),
|
|
65
|
+
});
|
|
66
|
+
const Summaries = Type.Array(SummarySchema);
|
|
67
|
+
/** An owner's conversations. */
|
|
68
|
+
export const Conversations = remote("chopin.conversations", {
|
|
69
|
+
version: 1,
|
|
70
|
+
input: Type.Object({}),
|
|
71
|
+
host: hostNamed(HOST),
|
|
72
|
+
variants: {
|
|
73
|
+
owner: {
|
|
74
|
+
state: { ids: Type.Array(Type.Number()) },
|
|
75
|
+
methods: {
|
|
76
|
+
create: method(undefined, Type.Number()),
|
|
77
|
+
/** Asks the workspace, so it is not part of the list's state, which would start a workspace just to list. */
|
|
78
|
+
loaded: method(undefined, LoadedSchema),
|
|
79
|
+
fork: method(ForkArgs, Type.Number()),
|
|
80
|
+
summaries: method(undefined, Summaries),
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* One conversation: its durable view (transcript, live generation, inbox, usage), what it may do, and how the
|
|
87
|
+
* submissions made through it ended, keyed by the id `submit` returned.
|
|
88
|
+
*/
|
|
89
|
+
export const Conversation = remote("chopin.conversation", {
|
|
90
|
+
version: 1,
|
|
91
|
+
input: Type.Object({ conversation: Type.Number() }),
|
|
92
|
+
host: hostNamed(HOST),
|
|
93
|
+
variants: {
|
|
94
|
+
owner: {
|
|
95
|
+
state: {
|
|
96
|
+
view: Type.Unknown(),
|
|
97
|
+
mode: ModeSchema,
|
|
98
|
+
name: Type.String(),
|
|
99
|
+
submissions: Type.Record(Type.String(), SubmissionSchema),
|
|
100
|
+
running: RunningSchema,
|
|
101
|
+
},
|
|
102
|
+
methods: {
|
|
103
|
+
submit: method(SubmitArgs, Type.Number()),
|
|
104
|
+
/** Runs to the command's end, which may take long; `stopCommand` ends it sooner. */
|
|
105
|
+
shell: method(ShellArgs),
|
|
106
|
+
stopCommand: method(NoArgs),
|
|
107
|
+
/** The whole conversation as transcript lines, what compaction took from the view included. */
|
|
108
|
+
transcript: method(NoArgs, Type.Array(Type.Unknown())),
|
|
109
|
+
/** Takes back every message still queued, answering with their texts in the order they were sent. */
|
|
110
|
+
withdraw: method(NoArgs, Texts),
|
|
111
|
+
abort: method(NoArgs),
|
|
112
|
+
setMode: method(ModeArgs),
|
|
113
|
+
setModel: method(ModelArgs),
|
|
114
|
+
setName: method(NameArgs),
|
|
115
|
+
setThinking: method(ThinkingArgs),
|
|
116
|
+
compact: method(CompactArgs),
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
/**
|
|
122
|
+
* A client host connected to the agent service at `url`, which carries the client's credential. A link that drops
|
|
123
|
+
* is dialled again, waiting longer each time, until the host is closed; references come back live once the service
|
|
124
|
+
* answers. Only a link that held for a while resets the wait, so a refused one is not dialled ever faster.
|
|
125
|
+
*/
|
|
126
|
+
export function connect(url, options = {}) {
|
|
127
|
+
const host = createHost({ name: `client:${randomId()}`, self: { kind: "host" }, kind: "client" });
|
|
128
|
+
let open = true;
|
|
129
|
+
const waits = backoff(250, 10_000);
|
|
130
|
+
let redial;
|
|
131
|
+
const again = () => {
|
|
132
|
+
if (!open)
|
|
133
|
+
return;
|
|
134
|
+
redial = setTimeout(() => {
|
|
135
|
+
(options.find?.() ?? Promise.resolve({ url, token: options.token })).then(dial).catch(again);
|
|
136
|
+
}, waits.next());
|
|
137
|
+
};
|
|
138
|
+
const dial = ({ url: at, token }) => {
|
|
139
|
+
if (!open)
|
|
140
|
+
return;
|
|
141
|
+
// Node's WebSocket takes headers; a browser has its cookie instead.
|
|
142
|
+
const socket = token === undefined ? new WebSocket(at) : new WebSocket(at, { headers: { authorization: `Bearer ${token}` } });
|
|
143
|
+
let opened;
|
|
144
|
+
socket.addEventListener("open", () => void (opened = Date.now()));
|
|
145
|
+
const link = webSocketLink(socket);
|
|
146
|
+
link.onClose(() => {
|
|
147
|
+
if (opened !== undefined && Date.now() - opened >= HELD_MS)
|
|
148
|
+
waits.reset();
|
|
149
|
+
again();
|
|
150
|
+
});
|
|
151
|
+
host.connect(link, { principal: { kind: "host" } });
|
|
152
|
+
};
|
|
153
|
+
dial({ url, token: options.token });
|
|
154
|
+
const close = host.close.bind(host);
|
|
155
|
+
host.close = async () => {
|
|
156
|
+
open = false;
|
|
157
|
+
clearTimeout(redial);
|
|
158
|
+
await close();
|
|
159
|
+
};
|
|
160
|
+
return host;
|
|
161
|
+
}
|
|
162
|
+
/** How long a link must hold to count as a working one, which dials again without waiting long. */
|
|
163
|
+
const HELD_MS = 5_000;
|
|
164
|
+
/** How long a call waits for the service, through any reconnect, before it fails. */
|
|
165
|
+
export const CALL_TIMEOUT_MS = 30_000;
|
|
166
|
+
/** A call that waited longer than its bound for the service. */
|
|
167
|
+
export class CallTimeout extends Error {
|
|
168
|
+
constructor(options) {
|
|
169
|
+
super("the agent service did not answer in time", options);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/** Runs `work` against the service, failing with `CallTimeout` once it has waited too long for an answer. */
|
|
173
|
+
export function call(host, work, options = {}) {
|
|
174
|
+
return within(options, (signal) => host.root(work, { signal }));
|
|
175
|
+
}
|
|
176
|
+
/** One conversation of the service, held until released, waited for as long as a call. */
|
|
177
|
+
export function openConversation(host, conversation, options = {}) {
|
|
178
|
+
return within(options, (signal) => host.get(Conversation, { conversation }, { signal }));
|
|
179
|
+
}
|
|
180
|
+
export function heldList(host, options = {}) {
|
|
181
|
+
let held;
|
|
182
|
+
let opening;
|
|
183
|
+
let released = false;
|
|
184
|
+
return {
|
|
185
|
+
get: (signal) => {
|
|
186
|
+
if (released)
|
|
187
|
+
return Promise.reject(new Error("the list was released"));
|
|
188
|
+
if (held !== undefined && (held.status === "live" || held.status === "loading"))
|
|
189
|
+
return Promise.resolve(held);
|
|
190
|
+
held?.release();
|
|
191
|
+
held = undefined;
|
|
192
|
+
opening ??= openConversations(host, options).then((list) => {
|
|
193
|
+
opening = undefined;
|
|
194
|
+
if (released) {
|
|
195
|
+
list.release();
|
|
196
|
+
throw new Error("the list was released");
|
|
197
|
+
}
|
|
198
|
+
held = list;
|
|
199
|
+
return list;
|
|
200
|
+
}, (error) => {
|
|
201
|
+
opening = undefined;
|
|
202
|
+
throw error;
|
|
203
|
+
});
|
|
204
|
+
return signal === undefined ? opening : abandonable(opening, signal);
|
|
205
|
+
},
|
|
206
|
+
release: () => {
|
|
207
|
+
released = true;
|
|
208
|
+
held?.release();
|
|
209
|
+
held = undefined;
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/** What `promise` settles to, unless `signal` aborts first. */
|
|
214
|
+
function abandonable(promise, signal) {
|
|
215
|
+
if (signal.aborted)
|
|
216
|
+
return Promise.reject(signal.reason);
|
|
217
|
+
return new Promise((resolve, reject) => {
|
|
218
|
+
const abort = () => reject(signal.reason);
|
|
219
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
220
|
+
void promise.then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/** Starts a new conversation in the owner's list and opens it, waiting no longer than any one call. */
|
|
224
|
+
export async function startConversation(host, list, options = {}) {
|
|
225
|
+
// Two calls, so a link lost after the conversation was made opens it rather than making another; together they
|
|
226
|
+
// wait no longer than one.
|
|
227
|
+
const started = Date.now();
|
|
228
|
+
const id = await within(options, async (signal) => {
|
|
229
|
+
const conversations = await list(signal);
|
|
230
|
+
return host.root((ctx) => conversations.create(ctx), { signal });
|
|
231
|
+
});
|
|
232
|
+
const left = Math.max(0, (options.timeoutMs ?? CALL_TIMEOUT_MS) - (Date.now() - started));
|
|
233
|
+
return { id, conversation: await openConversation(host, id, { ...options, timeoutMs: left }) };
|
|
234
|
+
}
|
|
235
|
+
/** The owner's list of conversations, held until released, waited for as long as a call. */
|
|
236
|
+
export function openConversations(host, options = {}) {
|
|
237
|
+
return within(options, (signal) => host.get(Conversations, {}, { signal }));
|
|
238
|
+
}
|
|
239
|
+
/** An error's text as every client shows it. */
|
|
240
|
+
export function errorText(error) {
|
|
241
|
+
return error instanceof Error ? error.message || error.name : String(error);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* An error's text followed by what lies beneath it, for a log or a command's last word: an aggregate's failures,
|
|
245
|
+
* then its cause, each told once however many ways lead to it.
|
|
246
|
+
*/
|
|
247
|
+
export function errorChain(error) {
|
|
248
|
+
const seen = new Set([error]);
|
|
249
|
+
const told = (current, below) => (below.length === 0 ? errorText(current) : `${errorText(current)}: ${below.join("; ")}`);
|
|
250
|
+
const beneath = (current) => {
|
|
251
|
+
const own = errorText(current);
|
|
252
|
+
const cause = current instanceof Error && current.cause != null ? current.cause : undefined;
|
|
253
|
+
// A cause the error already quotes at its end, as a wrapping error words it, adds only what lies beneath it.
|
|
254
|
+
const quoted = cause !== undefined && (own === errorText(cause) || own.endsWith(`: ${errorText(cause)}`));
|
|
255
|
+
const members = current instanceof AggregateError ? current.errors : [];
|
|
256
|
+
return [...members, ...(cause === undefined ? [] : [cause])].flatMap((next) => {
|
|
257
|
+
if (seen.has(next))
|
|
258
|
+
return [];
|
|
259
|
+
seen.add(next);
|
|
260
|
+
return next === cause && quoted ? beneath(next) : [told(next, beneath(next))];
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
return told(error, beneath(error));
|
|
264
|
+
}
|
|
265
|
+
/** Why a reference ended: its error, or else its status. */
|
|
266
|
+
export function endText(ref) {
|
|
267
|
+
return errorText(ref.error ?? ref.status);
|
|
268
|
+
}
|
|
269
|
+
/** A random id; a page served over plain HTTP has no `crypto.randomUUID`, but every page has random values. */
|
|
270
|
+
export function randomId() {
|
|
271
|
+
return Array.from(crypto.getRandomValues(new Uint8Array(16)), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Sends messages so that sending the same text straight after a failure is a resend under the same request, which
|
|
275
|
+
* the service admits once, whether or not the failed try reached it; any other message is a new one.
|
|
276
|
+
*/
|
|
277
|
+
export function resender() {
|
|
278
|
+
let failed;
|
|
279
|
+
return (text, submit) => {
|
|
280
|
+
const request = failed?.text === text ? failed.request : randomId();
|
|
281
|
+
failed = undefined;
|
|
282
|
+
return submit(request).catch((error) => {
|
|
283
|
+
failed = { text, request };
|
|
284
|
+
throw error;
|
|
285
|
+
});
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
/** Runs `work` with a signal that aborts once `options` say to stop waiting, failing then with `CallTimeout`. */
|
|
289
|
+
export async function within(options, work) {
|
|
290
|
+
const bound = options.timeoutMs ?? CALL_TIMEOUT_MS;
|
|
291
|
+
const timeout = Number.isFinite(bound) ? AbortSignal.timeout(bound) : undefined;
|
|
292
|
+
const signal = AbortSignal.any([timeout, options.signal].filter((each) => each !== undefined));
|
|
293
|
+
try {
|
|
294
|
+
for (;;) {
|
|
295
|
+
try {
|
|
296
|
+
return await work(signal);
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
// Between dials there is no link, so nothing was sent: the work waits for the next one rather than failing.
|
|
300
|
+
if (!(isChordError(error) && error.code === "unavailable" && error.message.includes("no route to")))
|
|
301
|
+
throw error;
|
|
302
|
+
await pause(UNROUTED_RETRY_MS, signal);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
throw timeout?.aborted === true ? new CallTimeout({ cause: error }) : error;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const UNROUTED_RETRY_MS = 100;
|
|
311
|
+
/** Resolves after `ms`, or rejects once `signal` aborts. */
|
|
312
|
+
function pause(ms, signal) {
|
|
313
|
+
return new Promise((resolve, reject) => {
|
|
314
|
+
const done = () => {
|
|
315
|
+
clearTimeout(timer);
|
|
316
|
+
reject(signal.reason);
|
|
317
|
+
};
|
|
318
|
+
const timer = setTimeout(() => {
|
|
319
|
+
signal.removeEventListener("abort", done);
|
|
320
|
+
resolve();
|
|
321
|
+
}, ms);
|
|
322
|
+
if (signal.aborted)
|
|
323
|
+
return done();
|
|
324
|
+
signal.addEventListener("abort", done, { once: true });
|
|
325
|
+
});
|
|
326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E,MAAM,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,GAAG,EAAE;YAChB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC,CAAC;QACF,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC1C,OAAO,EAAE,CAAC;QACZ,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,IAAI,MAAM,CAAC,OAAO;YAAE,OAAO,IAAI,EAAE,CAAC;QAClC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Host } from "@earendil-works/chord";
|
|
2
|
+
import { type Authenticate } from "./auth.js";
|
|
3
|
+
import { type Principal } from "./protocol.js";
|
|
4
|
+
import type { AgentService } from "./service.js";
|
|
5
|
+
/** Serves the client protocol for `service`; every object belongs to the owner that asked for it. */
|
|
6
|
+
export declare function createAgentHost(service: AgentService): Host<Principal>;
|
|
7
|
+
export interface ListenOptions {
|
|
8
|
+
authenticate: Authenticate;
|
|
9
|
+
/** 0, the default, picks a free port. */
|
|
10
|
+
port?: number;
|
|
11
|
+
/** Loopback by default; anything wider needs TLS in front. */
|
|
12
|
+
hostname?: string;
|
|
13
|
+
/** A built web app to serve on the same port. */
|
|
14
|
+
web?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface Listening {
|
|
17
|
+
readonly port: number;
|
|
18
|
+
/** Clients connected right now. */
|
|
19
|
+
readonly clients: number;
|
|
20
|
+
/** When an authenticated request or connection last arrived, in milliseconds since the epoch. */
|
|
21
|
+
readonly reachedAt: number;
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
/** Serves the client protocol over WebSocket, and the web app over HTTP, on one port. */
|
|
25
|
+
export declare function listen(service: AgentService, options: ListenOptions): Promise<Listening>;
|