@ahpd/server 0.1.0 → 0.3.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/README.md +88 -81
- package/dist/config.d.ts +72 -0
- package/dist/config.js +75 -0
- package/dist/daemon.d.ts +31 -0
- package/dist/daemon.js +162 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +335 -0
- package/dist/pty.d.ts +12 -0
- package/dist/pty.js +56 -0
- package/package.json +15 -25
- package/dist/automations.d.ts +0 -4
- package/dist/automations.d.ts.map +0 -1
- package/dist/automations.js +0 -191
- package/dist/automations.js.map +0 -1
- package/dist/catalog.d.ts +0 -48
- package/dist/catalog.d.ts.map +0 -1
- package/dist/catalog.js +0 -51
- package/dist/catalog.js.map +0 -1
- package/dist/changes.d.ts +0 -4
- package/dist/changes.d.ts.map +0 -1
- package/dist/changes.js +0 -601
- package/dist/changes.js.map +0 -1
- package/dist/cron.d.ts +0 -43
- package/dist/cron.d.ts.map +0 -1
- package/dist/cron.js +0 -211
- package/dist/cron.js.map +0 -1
- package/dist/git.d.ts +0 -16
- package/dist/git.d.ts.map +0 -1
- package/dist/git.js +0 -126
- package/dist/git.js.map +0 -1
- package/dist/host.d.ts +0 -24
- package/dist/host.d.ts.map +0 -1
- package/dist/host.js +0 -5850
- package/dist/host.js.map +0 -1
- package/dist/index.d.ts +0 -36
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -34
- package/dist/index.js.map +0 -1
- package/dist/listen.d.ts +0 -3
- package/dist/listen.d.ts.map +0 -1
- package/dist/listen.js +0 -183
- package/dist/listen.js.map +0 -1
- package/dist/paging.d.ts +0 -38
- package/dist/paging.d.ts.map +0 -1
- package/dist/paging.js +0 -53
- package/dist/paging.js.map +0 -1
- package/dist/paths.d.ts +0 -15
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js +0 -19
- package/dist/paths.js.map +0 -1
- package/dist/resources.d.ts +0 -122
- package/dist/resources.d.ts.map +0 -1
- package/dist/resources.js +0 -494
- package/dist/resources.js.map +0 -1
- package/dist/rpc.d.ts +0 -63
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js +0 -208
- package/dist/rpc.js.map +0 -1
- package/dist/scheduled.d.ts +0 -48
- package/dist/scheduled.d.ts.map +0 -1
- package/dist/scheduled.js +0 -325
- package/dist/scheduled.js.map +0 -1
- package/dist/terminals.d.ts +0 -29
- package/dist/terminals.d.ts.map +0 -1
- package/dist/terminals.js +0 -346
- package/dist/terminals.js.map +0 -1
- package/dist/tools.d.ts +0 -18
- package/dist/tools.d.ts.map +0 -1
- package/dist/tools.js +0 -65
- package/dist/tools.js.map +0 -1
- package/dist/types/agent.d.ts +0 -245
- package/dist/types/agent.d.ts.map +0 -1
- package/dist/types/agent.js +0 -3
- package/dist/types/agent.js.map +0 -1
- package/dist/types/automations.d.ts +0 -164
- package/dist/types/automations.d.ts.map +0 -1
- package/dist/types/automations.js +0 -3
- package/dist/types/automations.js.map +0 -1
- package/dist/types/catalog.d.ts +0 -30
- package/dist/types/catalog.d.ts.map +0 -1
- package/dist/types/catalog.js +0 -3
- package/dist/types/catalog.js.map +0 -1
- package/dist/types/changes.d.ts +0 -272
- package/dist/types/changes.d.ts.map +0 -1
- package/dist/types/changes.js +0 -3
- package/dist/types/changes.js.map +0 -1
- package/dist/types/common.d.ts +0 -9
- package/dist/types/common.d.ts.map +0 -1
- package/dist/types/common.js +0 -3
- package/dist/types/common.js.map +0 -1
- package/dist/types/host.d.ts +0 -372
- package/dist/types/host.d.ts.map +0 -1
- package/dist/types/host.js +0 -3
- package/dist/types/host.js.map +0 -1
- package/dist/types/index.d.ts +0 -20
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -8
- package/dist/types/index.js.map +0 -1
- package/dist/types/listen.d.ts +0 -48
- package/dist/types/listen.d.ts.map +0 -1
- package/dist/types/listen.js +0 -3
- package/dist/types/listen.js.map +0 -1
- package/dist/types/paging.d.ts +0 -10
- package/dist/types/paging.d.ts.map +0 -1
- package/dist/types/paging.js +0 -3
- package/dist/types/paging.js.map +0 -1
- package/dist/types/probe.d.ts +0 -46
- package/dist/types/probe.d.ts.map +0 -1
- package/dist/types/probe.js +0 -3
- package/dist/types/probe.js.map +0 -1
- package/dist/types/resources.d.ts +0 -83
- package/dist/types/resources.d.ts.map +0 -1
- package/dist/types/resources.js +0 -3
- package/dist/types/resources.js.map +0 -1
- package/dist/types/rpc.d.ts +0 -65
- package/dist/types/rpc.d.ts.map +0 -1
- package/dist/types/rpc.js +0 -3
- package/dist/types/rpc.js.map +0 -1
- package/dist/types/session.d.ts +0 -395
- package/dist/types/session.d.ts.map +0 -1
- package/dist/types/session.js +0 -3
- package/dist/types/session.js.map +0 -1
- package/dist/types/terminals.d.ts +0 -131
- package/dist/types/terminals.d.ts.map +0 -1
- package/dist/types/terminals.js +0 -3
- package/dist/types/terminals.js.map +0 -1
- package/dist/types/wire.d.ts +0 -62
- package/dist/types/wire.d.ts.map +0 -1
- package/dist/types/wire.js +0 -13
- package/dist/types/wire.js.map +0 -1
- package/dist/types/worktrees.d.ts +0 -86
- package/dist/types/worktrees.d.ts.map +0 -1
- package/dist/types/worktrees.js +0 -3
- package/dist/types/worktrees.js.map +0 -1
- package/dist/worktrees.d.ts +0 -27
- package/dist/worktrees.d.ts.map +0 -1
- package/dist/worktrees.js +0 -152
- package/dist/worktrees.js.map +0 -1
- package/src/automations.ts +0 -204
- package/src/catalog.ts +0 -53
- package/src/changes.ts +0 -629
- package/src/cron.ts +0 -251
- package/src/git.ts +0 -132
- package/src/host.ts +0 -5947
- package/src/index.ts +0 -40
- package/src/listen.ts +0 -240
- package/src/paging.ts +0 -56
- package/src/paths.ts +0 -19
- package/src/resources.ts +0 -513
- package/src/rpc.ts +0 -222
- package/src/scheduled.ts +0 -369
- package/src/terminals.ts +0 -353
- package/src/tools.ts +0 -64
- package/src/types/agent.ts +0 -255
- package/src/types/automations.ts +0 -164
- package/src/types/catalog.ts +0 -26
- package/src/types/changes.ts +0 -266
- package/src/types/common.ts +0 -9
- package/src/types/host.ts +0 -386
- package/src/types/index.ts +0 -27
- package/src/types/listen.ts +0 -53
- package/src/types/paging.ts +0 -11
- package/src/types/probe.ts +0 -42
- package/src/types/resources.ts +0 -107
- package/src/types/rpc.ts +0 -68
- package/src/types/session.ts +0 -415
- package/src/types/terminals.ts +0 -133
- package/src/types/wire.ts +0 -69
- package/src/types/worktrees.ts +0 -91
- package/src/worktrees.ts +0 -162
package/dist/listen.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { createPeer, receive } from './rpc.js';
|
|
2
|
-
/**
|
|
3
|
-
* Accepts WebSocket connections on Node, Bun or Deno.
|
|
4
|
-
*
|
|
5
|
-
* The runtime is detected at startup and the matching server is used: `ws` on
|
|
6
|
-
* Node, which has no WebSocket server of its own, and the built-in servers on
|
|
7
|
-
* Bun and Deno. `ws` is an optional dependency and is imported only on Node.
|
|
8
|
-
*
|
|
9
|
-
* This is the only module that knows which runtime it is on. Supporting
|
|
10
|
-
* another one is a case added here.
|
|
11
|
-
*/
|
|
12
|
-
const runtimeOf = () => {
|
|
13
|
-
const g = globalThis;
|
|
14
|
-
if (g.Bun !== undefined)
|
|
15
|
-
return 'bun';
|
|
16
|
-
if (g.Deno !== undefined)
|
|
17
|
-
return 'deno';
|
|
18
|
-
return 'node';
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* The token a connection presented, if it presented one.
|
|
22
|
-
*
|
|
23
|
-
* Two places, because only one of them always works: a browser cannot set
|
|
24
|
-
* headers on a WebSocket handshake, so the query string is the portable form
|
|
25
|
-
* and the header is for clients that can.
|
|
26
|
-
*/
|
|
27
|
-
const presented = (url, authorization) => {
|
|
28
|
-
const query = /[?&]tkn=([^&]*)/.exec(url ?? '');
|
|
29
|
-
if (query)
|
|
30
|
-
return decodeURIComponent(query[1] ?? '');
|
|
31
|
-
const bearer = /^Bearer\s+(.+)$/i.exec(authorization ?? '');
|
|
32
|
-
return bearer?.[1];
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Compares two secrets without returning early on the first difference.
|
|
36
|
-
*
|
|
37
|
-
* The lengths still differ observably, which is why a token is generated
|
|
38
|
-
* rather than chosen: they are all the same length.
|
|
39
|
-
*/
|
|
40
|
-
const same = (a, b) => {
|
|
41
|
-
if (a.length !== b.length)
|
|
42
|
-
return false;
|
|
43
|
-
let differing = 0;
|
|
44
|
-
for (let i = 0; i < a.length; i++)
|
|
45
|
-
differing |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
46
|
-
return differing === 0;
|
|
47
|
-
};
|
|
48
|
-
export async function listen(options, onConnect) {
|
|
49
|
-
const runtime = runtimeOf();
|
|
50
|
-
const host = options.host ?? '127.0.0.1';
|
|
51
|
-
const token = options.token;
|
|
52
|
-
/** Whether this handshake may proceed. No token configured accepts any. */
|
|
53
|
-
const allowed = (url, authorization) => token === undefined || same(token, presented(url, authorization) ?? '');
|
|
54
|
-
if (runtime === 'bun') {
|
|
55
|
-
const Bun = globalThis.Bun;
|
|
56
|
-
// Per socket, because Bun's handler table is one set of callbacks for
|
|
57
|
-
// every connection - `ws` is the only thing distinguishing them.
|
|
58
|
-
const bound = new Map();
|
|
59
|
-
const server = Bun.serve({
|
|
60
|
-
port: options.port,
|
|
61
|
-
hostname: host,
|
|
62
|
-
fetch(request, server_) {
|
|
63
|
-
// Refused before the upgrade, so an unauthorised client is told in
|
|
64
|
-
// HTTP rather than handed a socket that closes on its first message.
|
|
65
|
-
if (!allowed(request.url, request.headers.get('authorization'))) {
|
|
66
|
-
return new Response('A connection token is required', { status: 401 });
|
|
67
|
-
}
|
|
68
|
-
if (server_.upgrade(request))
|
|
69
|
-
return undefined;
|
|
70
|
-
return new Response('ahpd speaks the Agent Host Protocol over WebSocket', { status: 426 });
|
|
71
|
-
},
|
|
72
|
-
websocket: {
|
|
73
|
-
open(ws) {
|
|
74
|
-
const peer = createPeer({
|
|
75
|
-
send: (text) => { ws.send(text); },
|
|
76
|
-
close: () => ws.close(),
|
|
77
|
-
isOpen: () => ws.readyState === 1,
|
|
78
|
-
});
|
|
79
|
-
bound.set(ws, { peer, connected: onConnect(peer) });
|
|
80
|
-
},
|
|
81
|
-
message(ws, raw) {
|
|
82
|
-
const held = bound.get(ws);
|
|
83
|
-
if (!held)
|
|
84
|
-
return;
|
|
85
|
-
const text = typeof raw === 'string' ? raw : new TextDecoder().decode(raw);
|
|
86
|
-
receive(text, held.peer, (request) => held.connected.handle(request));
|
|
87
|
-
},
|
|
88
|
-
close(ws) {
|
|
89
|
-
const held = bound.get(ws);
|
|
90
|
-
// The peer first: a question this host asked is still pending, and
|
|
91
|
-
// the socket that would have answered it is gone.
|
|
92
|
-
held?.peer.close();
|
|
93
|
-
held?.connected.close();
|
|
94
|
-
bound.delete(ws);
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
return { runtime, host, port: server.port, guarded: token !== undefined, close: () => server.stop(true) };
|
|
99
|
-
}
|
|
100
|
-
if (runtime === 'deno') {
|
|
101
|
-
const Deno = globalThis.Deno;
|
|
102
|
-
const server = Deno.serve({ port: options.port, hostname: host }, (request) => {
|
|
103
|
-
if (!allowed(request.url, request.headers.get('authorization'))) {
|
|
104
|
-
return new Response('A connection token is required', { status: 401 });
|
|
105
|
-
}
|
|
106
|
-
if ((request.headers.get('upgrade') ?? '').toLowerCase() !== 'websocket') {
|
|
107
|
-
return new Response('ahpd speaks the Agent Host Protocol over WebSocket', { status: 426 });
|
|
108
|
-
}
|
|
109
|
-
const { socket, response } = Deno.upgradeWebSocket(request);
|
|
110
|
-
let held;
|
|
111
|
-
socket.onopen = () => {
|
|
112
|
-
const peer = createPeer({
|
|
113
|
-
send: (text) => { socket.send(text); },
|
|
114
|
-
close: () => socket.close(),
|
|
115
|
-
isOpen: () => socket.readyState === 1,
|
|
116
|
-
});
|
|
117
|
-
held = { peer, connected: onConnect(peer) };
|
|
118
|
-
};
|
|
119
|
-
socket.onmessage = (event) => {
|
|
120
|
-
const open = held;
|
|
121
|
-
if (!open)
|
|
122
|
-
return;
|
|
123
|
-
receive(String(event.data), open.peer, (request_) => open.connected.handle(request_));
|
|
124
|
-
};
|
|
125
|
-
socket.onclose = () => { held?.peer.close(); held?.connected.close(); held = undefined; };
|
|
126
|
-
return response;
|
|
127
|
-
});
|
|
128
|
-
return {
|
|
129
|
-
runtime,
|
|
130
|
-
host,
|
|
131
|
-
port: server.addr.port,
|
|
132
|
-
guarded: token !== undefined,
|
|
133
|
-
close: () => server.shutdown(),
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
let WebSocketServer;
|
|
137
|
-
try {
|
|
138
|
-
({ WebSocketServer } = await import('ws'));
|
|
139
|
-
}
|
|
140
|
-
catch {
|
|
141
|
-
throw new Error('Running on Node needs the `ws` package, which has no server in the standard library.\n'
|
|
142
|
-
+ ' npm install ws\n'
|
|
143
|
-
+ 'Bun and Deno have one built in and need nothing.');
|
|
144
|
-
}
|
|
145
|
-
const server = new WebSocketServer({
|
|
146
|
-
port: options.port,
|
|
147
|
-
host,
|
|
148
|
-
// `ws` answers a rejected handshake with the status this passes back, so
|
|
149
|
-
// an unauthorised client reads 401 rather than a socket that opened and
|
|
150
|
-
// then closed for no stated reason.
|
|
151
|
-
verifyClient: (info, accept) => {
|
|
152
|
-
if (allowed(info.req.url, info.req.headers.authorization ?? null))
|
|
153
|
-
accept(true);
|
|
154
|
-
else
|
|
155
|
-
accept(false, 401, 'A connection token is required');
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
server.on('connection', (socket) => {
|
|
159
|
-
const peer = createPeer({
|
|
160
|
-
send: (text) => { socket.send(text); },
|
|
161
|
-
close: () => socket.close(),
|
|
162
|
-
isOpen: () => socket.readyState === 1,
|
|
163
|
-
});
|
|
164
|
-
const connected = onConnect(peer);
|
|
165
|
-
socket.on('message', (raw) => {
|
|
166
|
-
receive(typeof raw === 'string' ? raw : raw.toString('utf8'), peer, (request) => connected.handle(request));
|
|
167
|
-
});
|
|
168
|
-
socket.on('close', () => { peer.close(); connected.close(); });
|
|
169
|
-
});
|
|
170
|
-
await new Promise((resolve, reject) => {
|
|
171
|
-
server.once('listening', () => resolve());
|
|
172
|
-
server.once('error', (error) => reject(error instanceof Error ? error : new Error(String(error))));
|
|
173
|
-
});
|
|
174
|
-
return {
|
|
175
|
-
runtime,
|
|
176
|
-
host,
|
|
177
|
-
// What was bound, not what was asked for: port 0 means the OS chooses.
|
|
178
|
-
port: server.address()?.port ?? options.port,
|
|
179
|
-
guarded: token !== undefined,
|
|
180
|
-
close: () => { server.close(); },
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
//# sourceMappingURL=listen.js.map
|
package/dist/listen.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listen.js","sourceRoot":"","sources":["../src/listen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAG/C;;;;;;;;;GASG;AAEH,MAAM,SAAS,GAAG,GAAY,EAAE;IAC9B,MAAM,CAAC,GAAG,UAA+C,CAAC;IAC1D,IAAI,CAAC,CAAC,GAAG,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACxC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAQF;;;;;;GAMG;AACH,MAAM,SAAS,GAAG,CAAC,GAAuB,EAAE,aAA4B,EAAsB,EAAE;IAC9F,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;IAChD,IAAI,KAAK;QAAE,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IAC5D,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
import type { Page } from './types/paging.js';
|
|
3
|
-
/**
|
|
4
|
-
* A long list of turns, served a page at a time.
|
|
5
|
-
*
|
|
6
|
-
* Nothing here knows what a turn is beyond it being one of many, which is why
|
|
7
|
-
* it is not in `transcript.ts`: reading a transcript is the backend's, because
|
|
8
|
-
* only the thing that ran the session knows the shape its frames are in.
|
|
9
|
-
* Paging is the host's, and it is the same paging whichever backend produced
|
|
10
|
-
* them.
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* How many turns a snapshot carries.
|
|
14
|
-
*
|
|
15
|
-
* A session in this directory has eight hundred and fifty turns. Sending them
|
|
16
|
-
* all works and will not keep working: a snapshot is what a client waits for
|
|
17
|
-
* before it can draw anything, and the oldest turns are the ones nobody is
|
|
18
|
-
* looking at.
|
|
19
|
-
*/
|
|
20
|
-
export declare const PAGE = 50;
|
|
21
|
-
/**
|
|
22
|
-
* The newest page, and where the rest begins.
|
|
23
|
-
*
|
|
24
|
-
* The cursor is the index of the oldest turn served - opaque to a client, and
|
|
25
|
-
* deliberately so, but it has to mean something here or `fetchTurns` cannot
|
|
26
|
-
* answer twice in a row.
|
|
27
|
-
*/
|
|
28
|
-
export declare function tail(turns: Bag[], size?: number): Page;
|
|
29
|
-
/**
|
|
30
|
-
* The page before a cursor, or nothing when the cursor is not one of ours.
|
|
31
|
-
*
|
|
32
|
-
* The protocol requires an unrecognised cursor to be rejected rather than
|
|
33
|
-
* guessed at: a host that quietly returned its newest page for a cursor it
|
|
34
|
-
* did not issue would answer a question about old turns with new ones, and
|
|
35
|
-
* the client would page forever without noticing.
|
|
36
|
-
*/
|
|
37
|
-
export declare function older(turns: Bag[], cursor: string, size?: number): Page | undefined;
|
|
38
|
-
//# sourceMappingURL=paging.d.ts.map
|
package/dist/paging.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paging.d.ts","sourceRoot":"","sources":["../src/paging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,KAAK,CAAC;AAEvB;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,SAAO,GAAG,IAAI,CAMpD;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,SAAO,GAAG,IAAI,GAAG,SAAS,CASjF"}
|
package/dist/paging.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A long list of turns, served a page at a time.
|
|
3
|
-
*
|
|
4
|
-
* Nothing here knows what a turn is beyond it being one of many, which is why
|
|
5
|
-
* it is not in `transcript.ts`: reading a transcript is the backend's, because
|
|
6
|
-
* only the thing that ran the session knows the shape its frames are in.
|
|
7
|
-
* Paging is the host's, and it is the same paging whichever backend produced
|
|
8
|
-
* them.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* How many turns a snapshot carries.
|
|
12
|
-
*
|
|
13
|
-
* A session in this directory has eight hundred and fifty turns. Sending them
|
|
14
|
-
* all works and will not keep working: a snapshot is what a client waits for
|
|
15
|
-
* before it can draw anything, and the oldest turns are the ones nobody is
|
|
16
|
-
* looking at.
|
|
17
|
-
*/
|
|
18
|
-
export const PAGE = 50;
|
|
19
|
-
/**
|
|
20
|
-
* The newest page, and where the rest begins.
|
|
21
|
-
*
|
|
22
|
-
* The cursor is the index of the oldest turn served - opaque to a client, and
|
|
23
|
-
* deliberately so, but it has to mean something here or `fetchTurns` cannot
|
|
24
|
-
* answer twice in a row.
|
|
25
|
-
*/
|
|
26
|
-
export function tail(turns, size = PAGE) {
|
|
27
|
-
const start = Math.max(0, turns.length - size);
|
|
28
|
-
return {
|
|
29
|
-
turns: turns.slice(start),
|
|
30
|
-
...(start > 0 ? { turnsNextCursor: String(start) } : {}),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* The page before a cursor, or nothing when the cursor is not one of ours.
|
|
35
|
-
*
|
|
36
|
-
* The protocol requires an unrecognised cursor to be rejected rather than
|
|
37
|
-
* guessed at: a host that quietly returned its newest page for a cursor it
|
|
38
|
-
* did not issue would answer a question about old turns with new ones, and
|
|
39
|
-
* the client would page forever without noticing.
|
|
40
|
-
*/
|
|
41
|
-
export function older(turns, cursor, size = PAGE) {
|
|
42
|
-
if (!/^\d+$/.test(cursor))
|
|
43
|
-
return undefined;
|
|
44
|
-
const at = Number(cursor);
|
|
45
|
-
if (at <= 0 || at > turns.length)
|
|
46
|
-
return undefined;
|
|
47
|
-
const start = Math.max(0, at - size);
|
|
48
|
-
return {
|
|
49
|
-
turns: turns.slice(start, at),
|
|
50
|
-
...(start > 0 ? { turnsNextCursor: String(start) } : {}),
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=paging.js.map
|
package/dist/paging.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paging.js","sourceRoot":"","sources":["../src/paging.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;AAEvB;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,KAAY,EAAE,IAAI,GAAG,IAAI;IAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC/C,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;QACzB,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzD,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,KAAK,CAAC,KAAY,EAAE,MAAc,EAAE,IAAI,GAAG,IAAI;IAC7D,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5C,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1B,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IACnD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACrC,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;QAC7B,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzD,CAAC;AACJ,CAAC"}
|
package/dist/paths.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Whether a path is a served root or under one.
|
|
3
|
-
*
|
|
4
|
-
* By `relative` rather than by string: `startsWith(root + '/')` is wrong for
|
|
5
|
-
* `/` - it asks whether the path begins `//` and refuses the whole filesystem -
|
|
6
|
-
* and `root === path` alone is wrong for everything else. Three places check
|
|
7
|
-
* this and they used to do it three ways, of which one was exact equality: a
|
|
8
|
-
* host told to serve `/home/you` served that directory and refused every
|
|
9
|
-
* project inside it, which is the only kind of directory anybody opens.
|
|
10
|
-
*
|
|
11
|
-
* Textual, so callers that can resolve symlinks resolve first and pass the
|
|
12
|
-
* real path - `served/link` pointing at `/etc` passes any textual test.
|
|
13
|
-
*/
|
|
14
|
-
export declare const within: (root: string, path: string) => boolean;
|
|
15
|
-
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,OAGnD,CAAC"}
|
package/dist/paths.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { isAbsolute, relative } from 'node:path';
|
|
2
|
-
/**
|
|
3
|
-
* Whether a path is a served root or under one.
|
|
4
|
-
*
|
|
5
|
-
* By `relative` rather than by string: `startsWith(root + '/')` is wrong for
|
|
6
|
-
* `/` - it asks whether the path begins `//` and refuses the whole filesystem -
|
|
7
|
-
* and `root === path` alone is wrong for everything else. Three places check
|
|
8
|
-
* this and they used to do it three ways, of which one was exact equality: a
|
|
9
|
-
* host told to serve `/home/you` served that directory and refused every
|
|
10
|
-
* project inside it, which is the only kind of directory anybody opens.
|
|
11
|
-
*
|
|
12
|
-
* Textual, so callers that can resolve symlinks resolve first and pass the
|
|
13
|
-
* real path - `served/link` pointing at `/etc` passes any textual test.
|
|
14
|
-
*/
|
|
15
|
-
export const within = (root, path) => {
|
|
16
|
-
const step = relative(root, path);
|
|
17
|
-
return step === '' || (!step.startsWith('..') && !isAbsolute(step));
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=paths.js.map
|
package/dist/paths.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEjD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,IAAY,EAAW,EAAE;IAC5D,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,OAAO,IAAI,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;AACtE,CAAC,CAAC"}
|
package/dist/resources.d.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import type { Entry, Metadata, Read, ResourceChange, WatchOptions, Watcher, Write } from './types/resources.js';
|
|
2
|
-
import type { ResourceStore } from './types/host.js';
|
|
3
|
-
/** `file:///a/b` and `/a/b` both mean the same path here. */
|
|
4
|
-
export declare const pathOf: (uri: string) => string;
|
|
5
|
-
/** A path, back as the URI a client sends and receives. */
|
|
6
|
-
export declare const uriOf: (path: string) => string;
|
|
7
|
-
/**
|
|
8
|
-
* The real path, if the client may see it.
|
|
9
|
-
*
|
|
10
|
-
* Resolved *before* the check, not after: `served/link` pointing at `/etc`
|
|
11
|
-
* passes a textual test and opens something else entirely. A path that does
|
|
12
|
-
* not exist yet is checked as written, since there is nothing to resolve.
|
|
13
|
-
*/
|
|
14
|
-
export declare function allowed(uri: string, roots: string[]): Promise<string>;
|
|
15
|
-
/**
|
|
16
|
-
* The path to write, if the client may write it.
|
|
17
|
-
*
|
|
18
|
-
* Not `allowed`, and the difference is the whole security of the write half.
|
|
19
|
-
* `allowed` resolves the path itself and falls back to the written text when
|
|
20
|
-
* there is nothing there yet - which is right for reading, where a file that
|
|
21
|
-
* does not exist has nothing to hand back either way. For a write it is a
|
|
22
|
-
* hole: `served/link` pointing at `/etc` resolves to nothing for
|
|
23
|
-
* `served/link/passwd`, so the textual test passes and the file is created
|
|
24
|
-
* in `/etc`.
|
|
25
|
-
*
|
|
26
|
-
* So the *parent* is resolved, and the check is on that. A directory that is
|
|
27
|
-
* not there yet is walked up until one is, because `mkdir -p` may be creating
|
|
28
|
-
* several at once and none of them can escape a real ancestor.
|
|
29
|
-
*/
|
|
30
|
-
export declare function writable(uri: string, roots: string[]): Promise<string>;
|
|
31
|
-
/** One directory's entries, names only. */
|
|
32
|
-
export declare function list(uri: string, roots: string[]): Promise<Entry[]>;
|
|
33
|
-
/**
|
|
34
|
-
* What a path is, without opening it.
|
|
35
|
-
*
|
|
36
|
-
* `followSymlinks` decides which of the two questions is being asked - what
|
|
37
|
-
* the link points at, or what the link is - and they have different answers
|
|
38
|
-
* for size and type.
|
|
39
|
-
*/
|
|
40
|
-
export declare function resolve(uri: string, roots: string[], followSymlinks?: boolean): Promise<Metadata>;
|
|
41
|
-
/**
|
|
42
|
-
* One file's bytes, as text where that is meaningful.
|
|
43
|
-
*
|
|
44
|
-
* The encoding is *reported* rather than assumed by the caller: a client that
|
|
45
|
-
* asked for utf-8 and got a PNG would render the replacement character four
|
|
46
|
-
* hundred thousand times, so anything not recognisably textual comes back
|
|
47
|
-
* base64 whatever was asked for - which the protocol allows for exactly this.
|
|
48
|
-
*/
|
|
49
|
-
export declare function read(uri: string, roots: string[], wanted?: string): Promise<Read>;
|
|
50
|
-
/**
|
|
51
|
-
* Paths under `base` that start with what was typed.
|
|
52
|
-
*
|
|
53
|
-
* The typed text is a path fragment, so its last segment is the prefix and
|
|
54
|
-
* everything before it is the directory to look in - which is what makes
|
|
55
|
-
* `@src/ho` complete to `@src/host.ts` rather than looking for a file called
|
|
56
|
-
* `src/ho`.
|
|
57
|
-
*/
|
|
58
|
-
export declare function complete(typed: string, base: string, roots: string[], limit?: number): Promise<string[]>;
|
|
59
|
-
/**
|
|
60
|
-
* Write, create or splice one file.
|
|
61
|
-
*
|
|
62
|
-
* The three modes differ in where `position` is rooted, which the protocol is
|
|
63
|
-
* explicit about and which is easy to get subtly wrong: `truncate` and
|
|
64
|
-
* `insert` count from the start of the file and `append` counts *backwards
|
|
65
|
-
* from EOF*, so `append` with `position: 0` is a POSIX append and with
|
|
66
|
-
* `position: 5` splices five bytes before the end.
|
|
67
|
-
*
|
|
68
|
-
* Everything is done on a buffer and written once. A file is not a stream
|
|
69
|
-
* here - the protocol has no chunked write - so reading it, splicing, and
|
|
70
|
-
* putting it back is both the simplest form and the only one that can honour
|
|
71
|
-
* `insert` at all.
|
|
72
|
-
*/
|
|
73
|
-
export declare function write(uri: string, roots: string[], content: Write): Promise<void>;
|
|
74
|
-
/**
|
|
75
|
-
* Remove one.
|
|
76
|
-
*
|
|
77
|
-
* A directory needs `recursive`, and a directory without it is refused rather
|
|
78
|
-
* than emptied: the protocol has the flag so that deleting a tree is
|
|
79
|
-
* something a client asked for in as many words.
|
|
80
|
-
*/
|
|
81
|
-
export declare function remove(uri: string, roots: string[], recursive?: boolean): Promise<void>;
|
|
82
|
-
/** Make a directory, and the parents it needs. */
|
|
83
|
-
export declare function mkdir(uri: string, roots: string[]): Promise<void>;
|
|
84
|
-
/** Rename, within the served directories on both ends. */
|
|
85
|
-
export declare function move(source: string, destination: string, roots: string[], failIfExists?: boolean): Promise<void>;
|
|
86
|
-
/** Copy, within the served directories on both ends. */
|
|
87
|
-
export declare function copy(source: string, destination: string, roots: string[], failIfExists?: boolean): Promise<void>;
|
|
88
|
-
/**
|
|
89
|
-
* Tell me when that changes.
|
|
90
|
-
*
|
|
91
|
-
* `node:fs.watch`, and the two things about it worth stating. It reports one
|
|
92
|
-
* event per file, so a save that rewrites four files is four events and a
|
|
93
|
-
* `git checkout` is hundreds - hence the window: events are gathered and sent
|
|
94
|
-
* as one batch, which is what the protocol asks a server to do and what keeps
|
|
95
|
-
* a client from redrawing per file.
|
|
96
|
-
*
|
|
97
|
-
* And its event names are not the protocol's, nor even the same across
|
|
98
|
-
* runtimes: creating a file is `rename` on Node and `change` on Deno, which is
|
|
99
|
-
* the sort of thing only running it on both ever tells you. So the name is
|
|
100
|
-
* ignored and the file is *looked at*. Gone is `deleted`. There and created
|
|
101
|
-
* since this watch started is `added`. Anything else is `updated`.
|
|
102
|
-
*
|
|
103
|
-
* `birthtime` rather than an inventory of the tree, because the tree may be a
|
|
104
|
-
* hundred thousand files and the question is only ever asked about the handful
|
|
105
|
-
* that moved. A path already reported as `added` is `updated` from then on, so
|
|
106
|
-
* a file created and then written twice is one appearance and two edits rather
|
|
107
|
-
* than three appearances.
|
|
108
|
-
*/
|
|
109
|
-
export declare function watch(uri: string, roots: string[], options: WatchOptions, onChange: (changes: ResourceChange[]) => void): Promise<Watcher>;
|
|
110
|
-
/**
|
|
111
|
-
* The filesystem this process is on, as a host's `ResourceStore`.
|
|
112
|
-
*
|
|
113
|
-
* Kept out of `createHost` so the protocol imports no runtime: this file is
|
|
114
|
-
* the one that touches `node:fs`, and a host that never opens a file never
|
|
115
|
-
* loads it.
|
|
116
|
-
*
|
|
117
|
-
* ```ts
|
|
118
|
-
* createHost({ path, agents, resources: fileResources() });
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
export declare const fileResources: () => ResourceStore;
|
|
122
|
-
//# sourceMappingURL=resources.d.ts.map
|
package/dist/resources.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAChH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAuBrD,6DAA6D;AAC7D,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,KAAG,MAGpC,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,KAAG,MAA0B,CAAC;AAsBhE;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAe3E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EA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