@quo-systems/dock 0.1.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/NOTICE +6 -0
- package/README.md +27 -0
- package/beings/avatar.ts +84 -0
- package/beings/desk.ts +46 -0
- package/beings/index.ts +5 -0
- package/beings/quo-dock.md +698 -0
- package/beings/setup.ts +23 -0
- package/beings/side.ts +51 -0
- package/beings/user.ts +78 -0
- package/cli/client.ts +65 -0
- package/cli/daemon.ts +582 -0
- package/cli/quo.ts +126 -0
- package/dist/beings/avatar.d.ts +32 -0
- package/dist/beings/avatar.js +82 -0
- package/dist/beings/desk.d.ts +42 -0
- package/dist/beings/desk.js +43 -0
- package/dist/beings/index.d.ts +3 -0
- package/dist/beings/index.js +5 -0
- package/dist/beings/setup.d.ts +2 -0
- package/dist/beings/setup.js +16 -0
- package/dist/beings/side.d.ts +25 -0
- package/dist/beings/side.js +37 -0
- package/dist/beings/user.d.ts +108 -0
- package/dist/beings/user.js +74 -0
- package/dist/cli/client.d.ts +14 -0
- package/dist/cli/client.js +51 -0
- package/dist/cli/daemon.d.ts +57 -0
- package/dist/cli/daemon.js +581 -0
- package/dist/cli/quo.d.ts +2 -0
- package/dist/cli/quo.js +121 -0
- package/dist/harbor/browser.d.ts +13 -0
- package/dist/harbor/browser.js +50 -0
- package/dist/harbor/disk.d.ts +19 -0
- package/dist/harbor/disk.js +126 -0
- package/dist/harbor/edge/edge.d.ts +26 -0
- package/dist/harbor/edge/edge.js +123 -0
- package/dist/harbor/edge/exercise.d.ts +7 -0
- package/dist/harbor/edge/exercise.js +179 -0
- package/dist/harbor/edge/storage.d.ts +20 -0
- package/dist/harbor/edge/storage.js +81 -0
- package/dist/harbor/edge/worker.d.ts +14 -0
- package/dist/harbor/edge/worker.js +47 -0
- package/dist/harbor/files.d.ts +14 -0
- package/dist/harbor/files.js +83 -0
- package/dist/harbor/idb.d.ts +15 -0
- package/dist/harbor/idb.js +85 -0
- package/dist/human/dom.d.ts +2 -0
- package/dist/human/dom.js +15 -0
- package/dist/human/html.d.ts +32 -0
- package/dist/human/html.js +136 -0
- package/dist/human/screen.d.ts +11 -0
- package/dist/human/screen.js +66 -0
- package/dist/human/tab.d.ts +7 -0
- package/dist/human/tab.js +68 -0
- package/dist/mcp/agent.d.ts +10 -0
- package/dist/mcp/agent.js +78 -0
- package/dist/mcp/http.d.ts +27 -0
- package/dist/mcp/http.js +96 -0
- package/dist/mcp/oauth.d.ts +98 -0
- package/dist/mcp/oauth.js +241 -0
- package/dist/mcp/pilot.d.ts +6 -0
- package/dist/mcp/pilot.js +68 -0
- package/dist/mcp/runner.d.ts +45 -0
- package/dist/mcp/runner.js +94 -0
- package/dist/mcp/server.d.ts +9 -0
- package/dist/mcp/server.js +63 -0
- package/dist/mcp/web/exchange.d.ts +23 -0
- package/dist/mcp/web/exchange.js +136 -0
- package/harbor/browser.ts +63 -0
- package/harbor/disk.ts +120 -0
- package/harbor/edge/edge.ts +147 -0
- package/harbor/edge/exercise.ts +187 -0
- package/harbor/edge/platform.d.ts +28 -0
- package/harbor/edge/storage.ts +82 -0
- package/harbor/edge/worker.ts +47 -0
- package/harbor/edge/wrangler.toml +21 -0
- package/harbor/files.ts +89 -0
- package/harbor/idb.ts +90 -0
- package/harbor/quo-harbor.md +403 -0
- package/human/dom.ts +21 -0
- package/human/html.ts +164 -0
- package/human/quo-human.md +86 -0
- package/human/screen.ts +76 -0
- package/human/tab.ts +84 -0
- package/mcp/agent.ts +94 -0
- package/mcp/http.ts +96 -0
- package/mcp/oauth.ts +260 -0
- package/mcp/pilot.ts +73 -0
- package/mcp/quo-mcp.md +262 -0
- package/mcp/runner.ts +131 -0
- package/mcp/server.ts +67 -0
- package/mcp/web/exchange.ts +146 -0
- package/package.json +89 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// A client of the daemon's socket. One ask, one line, one reply. This is
|
|
3
|
+
// what every subcommand but init and serve is: connect, ask, print, exit.
|
|
4
|
+
import { connect } from 'node:net';
|
|
5
|
+
import { createInterface } from 'node:readline';
|
|
6
|
+
import { sockPath, sidePath } from './daemon.js';
|
|
7
|
+
// `via` names a standing the ward's user being holds at another ward: the
|
|
8
|
+
// ask is then an owner's ask at that ward's door, sealed, and the answer is
|
|
9
|
+
// the far ward's. Without it the ask is the root's, on the pointer.
|
|
10
|
+
export function ask(dir, method, args = {}, ward = 'main', via) {
|
|
11
|
+
return line(dir, via === undefined ? { ward, method, args } : { ward, method, args, via });
|
|
12
|
+
}
|
|
13
|
+
// `quo reach`: a hint for the harbor's directory, which is the harbor's and
|
|
14
|
+
// not a ward's, so it crosses the root socket as its own line.
|
|
15
|
+
export function reach(dir, pk, url) {
|
|
16
|
+
return line(dir, { reach: { pk, url } });
|
|
17
|
+
}
|
|
18
|
+
function line(dir, body) {
|
|
19
|
+
return new Promise((ok, no) => {
|
|
20
|
+
const c = connect(sockPath(dir));
|
|
21
|
+
const id = Math.random().toString(36).slice(2);
|
|
22
|
+
c.once('error', (e) => no(e.code === 'ENOENT' || e.code === 'ECONNREFUSED' ? new Error(`no daemon at ${dir}: run \`quo serve\``) : e));
|
|
23
|
+
c.once('connect', () => {
|
|
24
|
+
c.write(JSON.stringify({ id, ...body }) + '\n');
|
|
25
|
+
createInterface({ input: c }).once('line', (line) => {
|
|
26
|
+
c.end();
|
|
27
|
+
const r = JSON.parse(line);
|
|
28
|
+
ok(r.error !== undefined ? { error: r.error } : { result: r.result });
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function side(dir, as, ward = 'main', run) {
|
|
34
|
+
return new Promise((ok, no) => {
|
|
35
|
+
const c = connect(sidePath(dir));
|
|
36
|
+
c.once('error', (e) => no(e.code === 'ENOENT' || e.code === 'ECONNREFUSED' ? new Error(`no daemon at ${dir}: run \`quo serve\``) : e));
|
|
37
|
+
c.once('connect', () => {
|
|
38
|
+
c.write(JSON.stringify(run ? { as, ward, run } : { as, ward }) + '\n');
|
|
39
|
+
const lines = createInterface({ input: c });
|
|
40
|
+
lines.once('line', (hello) => {
|
|
41
|
+
const h = JSON.parse(hello);
|
|
42
|
+
if (h.error !== undefined)
|
|
43
|
+
return no(new Error(h.error));
|
|
44
|
+
lines.on('line', (line) => process.stdout.write(line + '\n'));
|
|
45
|
+
createInterface({ input: process.stdin }).on('line', (line) => c.write(line + '\n'));
|
|
46
|
+
process.stdin.once('end', () => c.end());
|
|
47
|
+
});
|
|
48
|
+
c.once('close', () => ok());
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type IncomingMessage, type ServerResponse } from 'node:http';
|
|
2
|
+
import { Socket as Held, type Dialer } from '@quo-systems/quo/harbor';
|
|
3
|
+
import { DiskHarbor, type Hosted } from '../harbor/disk.ts';
|
|
4
|
+
import { type Avatar } from '../beings/index.ts';
|
|
5
|
+
import { type Agent } from '../mcp/agent.ts';
|
|
6
|
+
import { OAuth } from '../mcp/oauth.ts';
|
|
7
|
+
import { Exchange } from '../mcp/web/exchange.ts';
|
|
8
|
+
import { McpHttp } from '../mcp/http.ts';
|
|
9
|
+
export type Handler = (req: IncomingMessage, res: ServerResponse, rest: string) => void | Promise<void>;
|
|
10
|
+
export type Http = {
|
|
11
|
+
port: number;
|
|
12
|
+
host: string;
|
|
13
|
+
mount(prefix: string, handler: Handler): void;
|
|
14
|
+
};
|
|
15
|
+
export type Quo = {
|
|
16
|
+
sockets: Set<Held>;
|
|
17
|
+
dialers: Dialer[];
|
|
18
|
+
};
|
|
19
|
+
export type Serving = {
|
|
20
|
+
harbor: DiskHarbor;
|
|
21
|
+
sock: string;
|
|
22
|
+
side: string;
|
|
23
|
+
http: Http | null;
|
|
24
|
+
oauth: OAuth | null;
|
|
25
|
+
exchange: Exchange | null;
|
|
26
|
+
mcp: McpHttp | null;
|
|
27
|
+
agents: Map<string, Agent>;
|
|
28
|
+
quo: Quo;
|
|
29
|
+
close(): Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
export type Routes = {
|
|
32
|
+
mcp: string;
|
|
33
|
+
web: string;
|
|
34
|
+
quo?: string;
|
|
35
|
+
};
|
|
36
|
+
export type Agents = Record<string, {
|
|
37
|
+
command: string;
|
|
38
|
+
args?: string[];
|
|
39
|
+
dir: string;
|
|
40
|
+
}>;
|
|
41
|
+
export type Options = {
|
|
42
|
+
http?: {
|
|
43
|
+
port: number;
|
|
44
|
+
host?: string;
|
|
45
|
+
};
|
|
46
|
+
routes?: Routes;
|
|
47
|
+
agents?: Agents;
|
|
48
|
+
dial?: string[];
|
|
49
|
+
password?: () => string | undefined;
|
|
50
|
+
};
|
|
51
|
+
export declare const sockPath: (dir: string) => string;
|
|
52
|
+
export declare const sidePath: (dir: string) => string;
|
|
53
|
+
export declare function admit(hosted: Hosted, identity: string, kind: 'local' | 'web', wake?: boolean): Promise<{
|
|
54
|
+
avatar?: Avatar;
|
|
55
|
+
error?: string;
|
|
56
|
+
}>;
|
|
57
|
+
export declare function serve(dir: string, options?: Options): Promise<Serving>;
|