@dsh-teamwork/dsh-teamwork 0.9.0 → 0.11.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 +5 -2
- package/README.zh-CN.md +1 -1
- package/cordis.patch.yml +2 -1
- package/docs/development.md +72 -2
- package/docs/en/guide.md +76 -3
- package/docs/zh-CN/guide.md +38 -3
- package/lib/audit-archive.js +174 -0
- package/lib/audit-archive.js.map +1 -0
- package/lib/audit-cli.js +91 -0
- package/lib/audit-cli.js.map +1 -0
- package/lib/bridge.js +32 -10
- package/lib/bridge.js.map +1 -1
- package/lib/client.js +37 -15
- package/lib/client.js.map +1 -1
- package/lib/config-sync.js +1 -1
- package/lib/config-sync.js.map +1 -1
- package/lib/control-socket.js +63 -0
- package/lib/control-socket.js.map +1 -0
- package/lib/index.js +338 -94
- package/lib/index.js.map +1 -1
- package/lib/locale.js +18 -0
- package/lib/locale.js.map +1 -0
- package/lib/login-callback.js +1 -1
- package/lib/login-callback.js.map +1 -1
- package/lib/messages.js +119 -0
- package/lib/messages.js.map +1 -0
- package/lib/panel.js +27 -20
- package/lib/panel.js.map +1 -1
- package/lib/phone-security.js +120 -2
- package/lib/phone-security.js.map +1 -1
- package/lib/pin-lock.js +89 -0
- package/lib/pin-lock.js.map +1 -0
- package/lib/platform-models.js +10 -7
- package/lib/platform-models.js.map +1 -1
- package/lib/plugin-status.js +4 -4
- package/lib/plugin-status.js.map +1 -1
- package/lib/preset-session.js +2 -1
- package/lib/preset-session.js.map +1 -1
- package/lib/relay.js +14 -9
- package/lib/relay.js.map +1 -1
- package/lib/share-cli.js +150 -0
- package/lib/share-cli.js.map +1 -0
- package/lib/shared-mode.js +151 -0
- package/lib/shared-mode.js.map +1 -0
- package/lib/shared-owner.js +122 -0
- package/lib/shared-owner.js.map +1 -0
- package/lib/shared-roster.js +112 -0
- package/lib/shared-roster.js.map +1 -0
- package/lib/task-session.js +21 -19
- package/lib/task-session.js.map +1 -1
- package/lib/teamwork-cli.js +277 -0
- package/lib/teamwork-cli.js.map +1 -0
- package/lib/types/audit-archive.d.ts +78 -0
- package/lib/types/audit-archive.d.ts.map +1 -0
- package/lib/types/audit-cli.d.ts +14 -0
- package/lib/types/audit-cli.d.ts.map +1 -0
- package/lib/types/bridge.d.ts +7 -3
- package/lib/types/bridge.d.ts.map +1 -1
- package/lib/types/client.d.ts +21 -4
- package/lib/types/client.d.ts.map +1 -1
- package/lib/types/control-socket.d.ts +5 -0
- package/lib/types/control-socket.d.ts.map +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/locale.d.ts +13 -0
- package/lib/types/locale.d.ts.map +1 -0
- package/lib/types/messages.d.ts +67 -0
- package/lib/types/messages.d.ts.map +1 -0
- package/lib/types/panel.d.ts +64 -8
- package/lib/types/panel.d.ts.map +1 -1
- package/lib/types/phone-security.d.ts +37 -0
- package/lib/types/phone-security.d.ts.map +1 -1
- package/lib/types/pin-lock.d.ts +36 -0
- package/lib/types/pin-lock.d.ts.map +1 -0
- package/lib/types/platform-models.d.ts.map +1 -1
- package/lib/types/preset-session.d.ts.map +1 -1
- package/lib/types/relay.d.ts +15 -1
- package/lib/types/relay.d.ts.map +1 -1
- package/lib/types/share-cli.d.ts +9 -0
- package/lib/types/share-cli.d.ts.map +1 -0
- package/lib/types/shared-mode.d.ts +50 -0
- package/lib/types/shared-mode.d.ts.map +1 -0
- package/lib/types/shared-owner.d.ts +42 -0
- package/lib/types/shared-owner.d.ts.map +1 -0
- package/lib/types/shared-roster.d.ts +49 -0
- package/lib/types/shared-roster.d.ts.map +1 -0
- package/lib/types/task-session.d.ts +2 -2
- package/lib/types/task-session.d.ts.map +1 -1
- package/lib/types/teamwork-cli.d.ts +11 -0
- package/lib/types/teamwork-cli.d.ts.map +1 -0
- package/lib/web/client.js +1086 -355
- package/package.json +10 -2
package/lib/task-session.js
CHANGED
|
@@ -6,7 +6,8 @@ export const taskProjection = {
|
|
|
6
6
|
apply: (state, event) => {
|
|
7
7
|
if (event.type === 'user/message' && event.data.source.kind === 'user') {
|
|
8
8
|
const text = event.data.content.filter(b => b.type === 'text').map(b => b.text).join('\n');
|
|
9
|
-
|
|
9
|
+
// Empty for a message with no text: the phone app titles such a session in its own language.
|
|
10
|
+
return { ...state, task: text.slice(0, 240) };
|
|
10
11
|
}
|
|
11
12
|
if (event.type === 'turn/start')
|
|
12
13
|
return { ...state, turn: event.data.turn, outcome: 'running', failureCode: null };
|
|
@@ -49,29 +50,29 @@ export const stepProjection = {
|
|
|
49
50
|
return state;
|
|
50
51
|
}, wire: { viewSchema: stepSchema, view: state => state }, stateVersion: 1,
|
|
51
52
|
};
|
|
52
|
-
export function outcomeText(outcome) { return { 'not-started': '
|
|
53
|
+
export function outcomeText(outcome) { return { 'not-started': 'not started', running: 'running', completed: 'completed', aborted: 'cancelled', blocked: 'blocked', error: 'failed', interrupted: 'interrupted before a restart', 'max-tokens': 'hit the output limit', forked: 'inherited from a fork' }[outcome] ?? 'unknown'; }
|
|
53
54
|
export function recoveryHint(code, outcome) {
|
|
54
55
|
if (['AUTH', 'AUTHENTICATION', 'UNAUTHORIZED', 'MISSING_CREDENTIAL'].includes(code ?? ''))
|
|
55
|
-
return '
|
|
56
|
+
return 'Sign-in or credentials are invalid: for a team model run /teamwork login; for a local model check its credentials.';
|
|
56
57
|
if (code === 'RATE_LIMIT')
|
|
57
|
-
return '
|
|
58
|
+
return 'The model is rate limited: continue explicitly later; the task is not repeated automatically.';
|
|
58
59
|
if (code === 'TOOL_ACTIVATION_FAILED')
|
|
59
|
-
return '
|
|
60
|
+
return 'A tool condition is not met: run /teamwork tools and /teamwork plugins to check.';
|
|
60
61
|
if (['TRANSPORT', 'TIMEOUT', 'SERVER'].includes(code ?? ''))
|
|
61
|
-
return '
|
|
62
|
+
return 'The model connection or service failed: check the connection, then continue explicitly; the task may already have done part of its work.';
|
|
62
63
|
if (outcome === 'aborted')
|
|
63
|
-
return '
|
|
64
|
+
return 'The task was cancelled; history and finished file changes stay. Check what is there before continuing.';
|
|
64
65
|
if (outcome === 'error' || outcome === 'blocked' || outcome === 'interrupted')
|
|
65
|
-
return '
|
|
66
|
+
return 'The task did not finish: read the DSH session error, check permissions, tools and existing changes, then continue.';
|
|
66
67
|
if (outcome === 'max-tokens')
|
|
67
|
-
return '
|
|
68
|
-
return '
|
|
68
|
+
return 'The output limit was reached: check the result, then run /teamwork continue <instruction>.';
|
|
69
|
+
return 'To continue, send a new follow-up; files are never rolled back and history is never cleared.';
|
|
69
70
|
}
|
|
70
71
|
export function assertIdle(agent) {
|
|
71
72
|
if (agent.status !== 'idle')
|
|
72
|
-
throw new Error('
|
|
73
|
+
throw new Error('A task is running. Wait for it to finish, or run /teamwork cancel first.');
|
|
73
74
|
if (agent.inbox.nextTurn.length || agent.inbox.nextStep.length)
|
|
74
|
-
throw new Error('
|
|
75
|
+
throw new Error('There is pending input. Check or handle it in DSH’s pending input first, so nothing is submitted twice.');
|
|
75
76
|
}
|
|
76
77
|
export class TaskActions {
|
|
77
78
|
inspect;
|
|
@@ -93,28 +94,28 @@ export class TaskActions {
|
|
|
93
94
|
review(agent, outcome) {
|
|
94
95
|
assertIdle(agent);
|
|
95
96
|
if (!['error', 'aborted', 'blocked', 'interrupted', 'max-tokens'].includes(outcome))
|
|
96
|
-
throw new Error('
|
|
97
|
+
throw new Error('There is no failed or interrupted task to retry. Use /teamwork continue <instruction>.');
|
|
97
98
|
this.tickets.set(agent, { fingerprint: this.fingerprint(agent), expires: this.now() + 120000 });
|
|
98
99
|
}
|
|
99
100
|
async submit(agent, text, retry = false) {
|
|
100
101
|
assertIdle(agent);
|
|
101
102
|
if (this.busy.has(agent))
|
|
102
|
-
throw new Error('
|
|
103
|
+
throw new Error('This session is being checked; do not submit again.');
|
|
103
104
|
if (!text.trim() || text.length > 16000)
|
|
104
|
-
throw new Error('
|
|
105
|
+
throw new Error('Enter a follow-up of 1 to 16000 characters.');
|
|
105
106
|
const cancellation = this.cancellations.get(agent) ?? 0;
|
|
106
107
|
const before = this.fingerprint(agent), ticket = this.tickets.get(agent);
|
|
107
108
|
this.tickets.delete(agent);
|
|
108
109
|
if (retry && (!ticket || ticket.expires < this.now() || ticket.fingerprint !== before))
|
|
109
|
-
throw new Error('
|
|
110
|
+
throw new Error('The retry confirmation expired, or the session configuration changed. Run /teamwork retry again.');
|
|
110
111
|
this.busy.add(agent);
|
|
111
112
|
try {
|
|
112
113
|
await this.inspect(agent);
|
|
113
114
|
assertIdle(agent);
|
|
114
115
|
if ((this.cancellations.get(agent) ?? 0) !== cancellation)
|
|
115
|
-
throw new Error('
|
|
116
|
+
throw new Error('The follow-up was cancelled.');
|
|
116
117
|
if (this.fingerprint(agent) !== before)
|
|
117
|
-
throw new Error('
|
|
118
|
+
throw new Error('The session or team configuration changed during the check. Run /teamwork session, then submit again.');
|
|
118
119
|
agent.followup(createUserMessage({ content: [{ type: 'text', text }], source: { kind: 'user' } }));
|
|
119
120
|
}
|
|
120
121
|
finally {
|
|
@@ -122,5 +123,6 @@ export class TaskActions {
|
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
|
-
|
|
126
|
+
// Sent to the model as the member's follow-up; it answers in the conversation's own language.
|
|
127
|
+
export const retryInstruction = 'Continue the unfinished task from what this session has already done. First check the actions already taken and the files already changed, so nothing is written, committed or run with side effects twice; ask me before any action you are unsure of.';
|
|
126
128
|
//# sourceMappingURL=task-session.js.map
|
package/lib/task-session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-session.js","sourceRoot":"","sources":["../src/task-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC,MAAM,EAAE,EAAC,OAAO,EAAC,CAAC,CAAC,MAAM,EAAE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,EAAC,CAAC,CAAC,CAAC;QACzF,CAAC;gBAAS,CAAC;YAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAAC,CAAC;IACxC,CAAC;CACF;AACD,8FAA8F;AAC9F,MAAM,CAAC,MAAM,gBAAgB,GAAC,yPAAyP,CAAC"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `dsh-teamwork`, run on the machine of a running DSH to do what its Teamwork panel does, without a browser — for a
|
|
4
|
+
* DSH on a server, a shared one above all:
|
|
5
|
+
*
|
|
6
|
+
* dsh-teamwork server [url] the Teamwork server it uses (a self-hosted team sets its own first);
|
|
7
|
+
* without a url, prints it
|
|
8
|
+
* dsh-teamwork login a sign-in link to open in any browser; the code it shows goes to authorize
|
|
9
|
+
* dsh-teamwork authorize <code> finish signing in
|
|
10
|
+
* dsh-teamwork status sign-in, teams, sync, the relay and paired phones
|
|
11
|
+
* dsh-teamwork sync sync the team configuration now
|
|
12
|
+
* dsh-teamwork logout sign out
|
|
13
|
+
* dsh-teamwork phone pair a pairing QR code (and link) for the DSH Teamwork phone app
|
|
14
|
+
* dsh-teamwork phone list paired and waiting phones, with a waiting phone's safety code
|
|
15
|
+
* dsh-teamwork phone accept <id> accept a waiting phone, once its safety code matches the one listed here
|
|
16
|
+
* dsh-teamwork phone reject <id> refuse a waiting phone
|
|
17
|
+
* dsh-teamwork phone revoke <id> remove a paired phone
|
|
18
|
+
* dsh-teamwork share enable <key> make this DSH its team's shared DSH with the console's team host key
|
|
19
|
+
* dsh-teamwork share audit-key <key> seal its archive to the key `dsh-teamwork-audit keygen` printed
|
|
20
|
+
* dsh-teamwork share status its name, team, audit key and any error
|
|
21
|
+
* dsh-teamwork share members who may reach it, their devices and locks
|
|
22
|
+
* dsh-teamwork share invite <email> a single-use pairing link for one listed member
|
|
23
|
+
* dsh-teamwork share unlock <email> clear a member's PIN and lock
|
|
24
|
+
* dsh-teamwork share disable end shared mode and delete the key
|
|
25
|
+
*
|
|
26
|
+
* It talks to that DSH over the plugin's socket (`src/control-socket.ts`) in the DSH home, `$DSH_HOME` or else ~/.dsh,
|
|
27
|
+
* the same rule DSH itself follows; the plugin keeps its files in that home's `dsh-teamwork/`.
|
|
28
|
+
*/
|
|
29
|
+
import { realpathSync } from 'node:fs';
|
|
30
|
+
import { request } from 'node:http';
|
|
31
|
+
import { homedir } from 'node:os';
|
|
32
|
+
import { join, resolve } from 'node:path';
|
|
33
|
+
import { fileURLToPath } from 'node:url';
|
|
34
|
+
import qrcode from 'qrcode-generator';
|
|
35
|
+
/** The DSH home as DSH resolves it: a non-blank `$DSH_HOME` (with `~` expanded), else ~/.dsh. */
|
|
36
|
+
export function dshHome(env = process.env) {
|
|
37
|
+
const configured = env.DSH_HOME?.trim() ? env.DSH_HOME : join(homedir(), '.dsh');
|
|
38
|
+
return resolve(configured === '~' ? homedir() : configured.replace(/^~[/\\]/, `${homedir()}/`));
|
|
39
|
+
}
|
|
40
|
+
export const socketIn = (home) => join(home, 'dsh-teamwork', 'cache.sock');
|
|
41
|
+
/** One panel route on the socket: its JSON answer, or its error as a thrown message. */
|
|
42
|
+
export function call(socketPath, route, body = {}) {
|
|
43
|
+
return new Promise((done, failed) => {
|
|
44
|
+
const req = request({ socketPath, path: `/api/teamwork/${route}`, method: 'POST', agent: false, headers: { 'content-type': 'application/json' } }, (res) => {
|
|
45
|
+
const chunks = [];
|
|
46
|
+
res.on('data', (chunk) => chunks.push(chunk));
|
|
47
|
+
res.on('end', () => {
|
|
48
|
+
let answer = null;
|
|
49
|
+
try {
|
|
50
|
+
answer = JSON.parse(Buffer.concat(chunks).toString('utf8') || 'null');
|
|
51
|
+
}
|
|
52
|
+
catch { /* not JSON: said below */ }
|
|
53
|
+
const error = answer?.error;
|
|
54
|
+
if ((res.statusCode ?? 500) >= 400)
|
|
55
|
+
failed(new Error(typeof error === 'string' ? error : `The DSH answered ${res.statusCode}.`));
|
|
56
|
+
else
|
|
57
|
+
done(answer);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
req.on('error', (error) => failed(error.code === 'ENOENT' || error.code === 'ECONNREFUSED'
|
|
61
|
+
? new Error(`No running DSH with the Teamwork plugin at ${socketPath}. Start it (dsh web) with the same DSH_HOME, and run this as the same user.`)
|
|
62
|
+
: error));
|
|
63
|
+
req.end(JSON.stringify(body));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const state = async (socketPath) => (await call(socketPath, 'state'));
|
|
67
|
+
const shared = async (socketPath) => (await state(socketPath)).shared;
|
|
68
|
+
/** The pairing link as a QR code a terminal shows: two rows per character line, so it stays square. */
|
|
69
|
+
export function terminalQr(link) {
|
|
70
|
+
const code = qrcode(0, 'M');
|
|
71
|
+
code.addData(link);
|
|
72
|
+
code.make();
|
|
73
|
+
return code.createASCII(1, 2);
|
|
74
|
+
}
|
|
75
|
+
const phoneLine = (p) => p.status === 'pending'
|
|
76
|
+
? `${p.id} ${p.deviceName} waiting: ${p.safetyCode && p.phoneConfirmed ? `safety code ${p.safetyCode}; if the phone shows the same, dsh-teamwork phone accept ${p.id}` : 'the phone has not finished its encrypted handshake yet'}`
|
|
77
|
+
: `${p.id} ${p.deviceName} paired${p.verified ? '' : ' (pair it again: its key is not verified)'}${p.lastUsedAt ? `, last used ${p.lastUsedAt}` : ''}`;
|
|
78
|
+
async function phone(action, id, socketPath, out, err) {
|
|
79
|
+
const phones = async () => (await state(socketPath)).phones;
|
|
80
|
+
const needsId = () => { if (!id) {
|
|
81
|
+
err(`${usage}\n(phone ${action} needs the phone's id, from dsh-teamwork phone list)`);
|
|
82
|
+
return false;
|
|
83
|
+
} return true; };
|
|
84
|
+
switch (action) {
|
|
85
|
+
case 'pair': {
|
|
86
|
+
const offer = (await call(socketPath, 'pair-phone'));
|
|
87
|
+
out(terminalQr(offer.link));
|
|
88
|
+
out(`Scan it in the DSH Teamwork app, or open: ${offer.link}`);
|
|
89
|
+
out(`Valid until ${offer.expiresAt}. Then run dsh-teamwork phone list to compare the safety code.`);
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
case 'list': {
|
|
93
|
+
const listed = await phones();
|
|
94
|
+
out(listed.length ? listed.map(phoneLine).join('\n') : 'No phone is paired. Run dsh-teamwork phone pair.');
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
case 'accept': {
|
|
98
|
+
if (!needsId())
|
|
99
|
+
return 2;
|
|
100
|
+
const waiting = (await phones()).find((p) => p.id === id && p.status === 'pending');
|
|
101
|
+
if (!waiting) {
|
|
102
|
+
err(`No phone waits as ${id}. Run dsh-teamwork phone list.`);
|
|
103
|
+
return 1;
|
|
104
|
+
}
|
|
105
|
+
// As in the panel: only a finished handshake has a safety code the person can have compared.
|
|
106
|
+
if (!waiting.safetyCode || !waiting.phoneConfirmed) {
|
|
107
|
+
err('The phone has not finished its encrypted handshake yet; wait, then run dsh-teamwork phone list.');
|
|
108
|
+
return 1;
|
|
109
|
+
}
|
|
110
|
+
await call(socketPath, 'decide-phone', { id, accept: true });
|
|
111
|
+
out(`Accepted ${waiting.deviceName}.`);
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
case 'reject':
|
|
115
|
+
if (!needsId())
|
|
116
|
+
return 2;
|
|
117
|
+
await call(socketPath, 'decide-phone', { id, accept: false });
|
|
118
|
+
out('Refused.');
|
|
119
|
+
return 0;
|
|
120
|
+
case 'revoke':
|
|
121
|
+
if (!needsId())
|
|
122
|
+
return 2;
|
|
123
|
+
await call(socketPath, 'revoke-phone', { id });
|
|
124
|
+
out('Removed.');
|
|
125
|
+
return 0;
|
|
126
|
+
default:
|
|
127
|
+
err(usage);
|
|
128
|
+
return 2;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function describeState(s) {
|
|
132
|
+
return [
|
|
133
|
+
`Teamwork server: ${s.server}`,
|
|
134
|
+
s.shared ? 'Signed in: as this shared DSH (dsh-teamwork share status)' : `Signed in: ${s.authenticated ? 'yes' : 'no — dsh-teamwork login'}`,
|
|
135
|
+
...(s.teams.length ? [`Teams: ${s.teams.map((t) => `${t.name} (${t.role})`).join(', ')}`] : []),
|
|
136
|
+
`Sync: ${s.sync.running ? 'running' : s.sync.lastSuccess ? `last ${s.sync.lastSuccess}` : 'not yet'}${s.sync.auto ? ', automatic' : ''}`,
|
|
137
|
+
...(s.sync.lastError ? [`Sync error: ${s.sync.lastError}`] : []),
|
|
138
|
+
`Relay: ${s.relay}`,
|
|
139
|
+
`Phones: ${s.phones.length ? s.phones.map((p) => `${p.deviceName} (${p.status === 'pending' ? 'waiting' : 'paired'})`).join(', ') : 'none'}`,
|
|
140
|
+
].join('\n');
|
|
141
|
+
}
|
|
142
|
+
const describe = (s) => [
|
|
143
|
+
`Shared DSH: ${s.name ?? 'not yet confirmed'}`,
|
|
144
|
+
`Team: ${s.teamName ?? 'unknown'}`,
|
|
145
|
+
`Audit key: ${s.auditKey ?? 'not set — no member is admitted until dsh-teamwork share audit-key <key>'}`,
|
|
146
|
+
...(s.error ? [`Error: ${s.error}`] : []),
|
|
147
|
+
].join('\n');
|
|
148
|
+
const usage = [
|
|
149
|
+
'usage: dsh-teamwork server [url] | login | authorize <code> | status | sync | logout',
|
|
150
|
+
' dsh-teamwork phone pair | list | accept <id> | reject <id> | revoke <id>',
|
|
151
|
+
' dsh-teamwork share enable <key> | audit-key <key> | status | members | invite <email> | unlock <email> | disable',
|
|
152
|
+
].join('\n');
|
|
153
|
+
/** Runs one command against the DSH on socketPath, writing to out and err; returns the exit code. */
|
|
154
|
+
export async function run(args, socketPath, out, err) {
|
|
155
|
+
const [group, action, value] = args;
|
|
156
|
+
const needs = (what) => { if (!value) {
|
|
157
|
+
err(`${usage}\n(${action} needs ${what})`);
|
|
158
|
+
return false;
|
|
159
|
+
} return true; };
|
|
160
|
+
if (group === 'server') {
|
|
161
|
+
if (action)
|
|
162
|
+
await call(socketPath, 'server', { server: action });
|
|
163
|
+
out(`Teamwork server: ${(await call(socketPath, 'state')).server}`);
|
|
164
|
+
return 0;
|
|
165
|
+
}
|
|
166
|
+
switch (group) {
|
|
167
|
+
case 'login': {
|
|
168
|
+
const { url, automatic } = (await call(socketPath, 'login'));
|
|
169
|
+
out(`Open this in a browser, sign in and confirm:\n${url}`);
|
|
170
|
+
out(automatic
|
|
171
|
+
? 'A browser on this machine finishes by itself. Anywhere else, copy the code the page shows and run: dsh-teamwork authorize <code>'
|
|
172
|
+
: 'Then copy the code the page shows and run: dsh-teamwork authorize <code>');
|
|
173
|
+
return 0;
|
|
174
|
+
}
|
|
175
|
+
case 'authorize':
|
|
176
|
+
if (!action) {
|
|
177
|
+
err(`${usage}\n(authorize needs the code the sign-in page shows)`);
|
|
178
|
+
return 2;
|
|
179
|
+
}
|
|
180
|
+
// The page shows a whole line, /teamwork authorize <code>; its last word is the code.
|
|
181
|
+
await call(socketPath, 'authorize', { code: args.at(-1) });
|
|
182
|
+
out('Signed in. The team configuration syncs now; dsh-teamwork status shows it.');
|
|
183
|
+
return 0;
|
|
184
|
+
case 'status':
|
|
185
|
+
out(describeState(await state(socketPath)));
|
|
186
|
+
return 0;
|
|
187
|
+
case 'sync': {
|
|
188
|
+
await call(socketPath, 'sync');
|
|
189
|
+
const now = await state(socketPath);
|
|
190
|
+
if (now.sync.lastError) {
|
|
191
|
+
err(`Sync failed: ${now.sync.lastError}`);
|
|
192
|
+
return 1;
|
|
193
|
+
}
|
|
194
|
+
out(`Synced ${now.teams.length} team${now.teams.length === 1 ? '' : 's'}.`);
|
|
195
|
+
return 0;
|
|
196
|
+
}
|
|
197
|
+
case 'logout':
|
|
198
|
+
await call(socketPath, 'logout');
|
|
199
|
+
out('Signed out; the team configuration is removed from this DSH.');
|
|
200
|
+
return 0;
|
|
201
|
+
case 'phone': return phone(action, value, socketPath, out, err);
|
|
202
|
+
}
|
|
203
|
+
if (group !== 'share') {
|
|
204
|
+
err(usage);
|
|
205
|
+
return 2;
|
|
206
|
+
}
|
|
207
|
+
switch (action) {
|
|
208
|
+
case 'enable': {
|
|
209
|
+
if (!needs('the key'))
|
|
210
|
+
return 2;
|
|
211
|
+
await call(socketPath, 'share-enable', { key: value });
|
|
212
|
+
const now = await shared(socketPath);
|
|
213
|
+
out(now ? describe(now) : 'Shared mode is on.');
|
|
214
|
+
out('Personal sign-in is off while it is shared. Next: dsh-teamwork share audit-key <key>.');
|
|
215
|
+
return 0;
|
|
216
|
+
}
|
|
217
|
+
case 'audit-key': {
|
|
218
|
+
if (!needs('the public key'))
|
|
219
|
+
return 2;
|
|
220
|
+
const { fingerprint } = (await call(socketPath, 'share-audit-key', { key: value }));
|
|
221
|
+
out(`Audit key set (fingerprint ${fingerprint}). Members can now join.`);
|
|
222
|
+
return 0;
|
|
223
|
+
}
|
|
224
|
+
case 'status': {
|
|
225
|
+
const now = await shared(socketPath);
|
|
226
|
+
out(now ? describe(now) : 'Shared mode is off. Run dsh-teamwork share enable <key> with the key from the team console.');
|
|
227
|
+
return 0;
|
|
228
|
+
}
|
|
229
|
+
case 'members': {
|
|
230
|
+
const now = await shared(socketPath);
|
|
231
|
+
if (!now) {
|
|
232
|
+
out('Shared mode is off.');
|
|
233
|
+
return 0;
|
|
234
|
+
}
|
|
235
|
+
if (!now.members.length) {
|
|
236
|
+
out('Nobody is listed yet: choose who may reach it in the team console, under Shared DSHs.');
|
|
237
|
+
return 0;
|
|
238
|
+
}
|
|
239
|
+
for (const m of now.members)
|
|
240
|
+
out(`${m.email ?? m.userId}${m.locked ? ' (locked)' : ''}: ${m.devices.join(', ') || 'no device yet'}`);
|
|
241
|
+
return 0;
|
|
242
|
+
}
|
|
243
|
+
case 'invite': {
|
|
244
|
+
if (!needs('the member\'s email'))
|
|
245
|
+
return 2;
|
|
246
|
+
const invite = (await call(socketPath, 'share-invite', { email: value }));
|
|
247
|
+
out(`Invite for ${value}, single use, valid until ${invite.expiresAt}:`);
|
|
248
|
+
out(invite.link);
|
|
249
|
+
out('Hand it over yourself, in person or through a channel your team trusts, never through the Teamwork server.');
|
|
250
|
+
return 0;
|
|
251
|
+
}
|
|
252
|
+
case 'unlock': {
|
|
253
|
+
if (!needs('the member\'s email'))
|
|
254
|
+
return 2;
|
|
255
|
+
await call(socketPath, 'share-unlock', { email: value });
|
|
256
|
+
out(`${value}'s PIN and lock are cleared; they set a new PIN on their next connection.`);
|
|
257
|
+
return 0;
|
|
258
|
+
}
|
|
259
|
+
case 'disable':
|
|
260
|
+
await call(socketPath, 'share-disable');
|
|
261
|
+
out('Shared mode is off and its key deleted.');
|
|
262
|
+
return 0;
|
|
263
|
+
default:
|
|
264
|
+
err(usage);
|
|
265
|
+
return 2;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// Run as a command (through npm's bin link too), not when imported by tests.
|
|
269
|
+
if (process.argv[1] && realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
270
|
+
if (process.platform === 'win32') {
|
|
271
|
+
console.error('dsh-teamwork runs on Linux and macOS; on Windows use the Teamwork panel in DSH.');
|
|
272
|
+
process.exit(1);
|
|
273
|
+
}
|
|
274
|
+
run(process.argv.slice(2), socketIn(dshHome()), console.log, console.error)
|
|
275
|
+
.then((code) => process.exit(code), (error) => { console.error(error.message); process.exit(1); });
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=teamwork-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teamwork-cli.js","sourceRoot":"","sources":["../src/teamwork-cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,O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C,GAAG,CAAC,yCAAyC,CAAC,CAAC;YAC/C,OAAO,CAAC,CAAC;QACX;YACE,GAAG,CAAC,KAAK,CAAC,CAAC;YACX,OAAO,CAAC,CAAC;IACb,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACxF,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAAC,OAAO,CAAC,KAAK,CAAC,iFAAiF,CAAC,CAAC;QAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAAC,CAAC;IACxJ,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC;SACxE,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClH,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { CipherSuite } from '@hpke/core';
|
|
2
|
+
import type { Identity } from './secure-channel.js';
|
|
3
|
+
export declare const suite: CipherSuite;
|
|
4
|
+
export declare const SEGMENT_BYTES: number;
|
|
5
|
+
export declare const SEGMENT_MS: number;
|
|
6
|
+
export interface Segment {
|
|
7
|
+
v: 1;
|
|
8
|
+
host: string;
|
|
9
|
+
seq: number;
|
|
10
|
+
prev: string;
|
|
11
|
+
key: string;
|
|
12
|
+
enc: string;
|
|
13
|
+
ct: string;
|
|
14
|
+
sig: string;
|
|
15
|
+
}
|
|
16
|
+
export interface AuditRecord {
|
|
17
|
+
at: string;
|
|
18
|
+
member: string;
|
|
19
|
+
device: string;
|
|
20
|
+
dir: 'in' | 'out';
|
|
21
|
+
frame: unknown;
|
|
22
|
+
}
|
|
23
|
+
/** A string's UTF-8 bytes as the ArrayBuffer HPKE takes. */
|
|
24
|
+
export declare const bytesOf: (text: string) => ArrayBuffer;
|
|
25
|
+
/** The clear header the AEAD binds: whoever opens a segment knows these were not moved between segments. */
|
|
26
|
+
export declare const segmentHeader: (s: Pick<Segment, "host" | "seq" | "prev" | "key">) => string;
|
|
27
|
+
/** What this DSH signs, and the server checks before it keeps a segment (its `server/relay/archive.go`). */
|
|
28
|
+
export declare const segmentSigned: (s: Omit<Segment, "v" | "sig">) => string;
|
|
29
|
+
export declare const keyFingerprint: (publicKey: string) => string;
|
|
30
|
+
/** A frame as the archive keeps it: large strings by their length and digest. */
|
|
31
|
+
export declare function recordable(value: unknown): unknown;
|
|
32
|
+
export interface AuditArchiveOptions {
|
|
33
|
+
/** Where the archive keeps its state (`<path>`) and its queue (`<path>.queue/`). */
|
|
34
|
+
path: string;
|
|
35
|
+
hostId(): string | undefined;
|
|
36
|
+
identity(): Promise<Identity>;
|
|
37
|
+
/** Uploads one segment's bytes; the server answers 201 or 200 when it holds it. */
|
|
38
|
+
upload(body: string): Promise<{
|
|
39
|
+
status: number;
|
|
40
|
+
}>;
|
|
41
|
+
log?(message: string): void;
|
|
42
|
+
now?(): number;
|
|
43
|
+
}
|
|
44
|
+
export declare const auditArchivePath: (cachePath: string) => string;
|
|
45
|
+
export declare class AuditArchive {
|
|
46
|
+
private readonly options;
|
|
47
|
+
private state?;
|
|
48
|
+
private records;
|
|
49
|
+
private bytes;
|
|
50
|
+
private timer?;
|
|
51
|
+
private sealing;
|
|
52
|
+
private draining?;
|
|
53
|
+
private publicKey?;
|
|
54
|
+
constructor(options: AuditArchiveOptions);
|
|
55
|
+
private get queue();
|
|
56
|
+
private load;
|
|
57
|
+
private save;
|
|
58
|
+
/** Whether an audit key is set: a shared DSH admits no member until it is. */
|
|
59
|
+
ready(): Promise<boolean>;
|
|
60
|
+
/** The audit key's fingerprint, or undefined before one is set. */
|
|
61
|
+
fingerprint(): Promise<string | undefined>;
|
|
62
|
+
/** The admin's audit public key (raw X25519, base64, from `dsh-teamwork-audit keygen`). New segments are sealed to it. */
|
|
63
|
+
setKey(publicKey: string): Promise<string>;
|
|
64
|
+
/** Records one frame of a member's; nothing is recorded before an audit key is set. */
|
|
65
|
+
record(entry: Omit<AuditRecord, 'at'>): void;
|
|
66
|
+
/** Seals what has collected into the next segment, queues it on disk, and uploads the queue. */
|
|
67
|
+
flush(): Promise<void>;
|
|
68
|
+
private seal;
|
|
69
|
+
/** Uploads queued segments in order; one the server refuses as out of order stops the queue and is said. */
|
|
70
|
+
drain(): Promise<void>;
|
|
71
|
+
stop(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Shared mode ended: what collected is sealed and sent if it can be, then the key goes, so nothing more is recorded.
|
|
74
|
+
* The chain's place stays: the same shared host enabled again continues its chain rather than restarting it.
|
|
75
|
+
*/
|
|
76
|
+
clear(): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=audit-archive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-archive.d.ts","sourceRoot":"","sources":["../../src/audit-archive.ts"],"names":[],"mappings":"AAeA,OAAO,EAAa,WAAW,EAAqC,MAAM,YAAY,CAAC;AAEvF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,eAAO,MAAM,KAAK,aAAsG,CAAC;AACzH,eAAO,MAAM,aAAa,QAAU,CAAC;AACrC,eAAO,MAAM,UAAU,QAAY,CAAC;AAGpC,MAAM,WAAW,OAAO;IAAG,CAAC,EAAE,CAAC,CAAC;IAAC,IAAI,EAAE,M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AC;CAChB;AAED,eAAO,MAAM,gBAAgB,GAAI,WAAW,MAAM,WAAmD,CAAC;AAEtG,qBAAa,YAAY;IAQX,OAAO,CAAC,QAAQ,CAAC,OAAO;IAPpC,OAAO,CAAC,KAAK,CAAC,CAAiB;IAC/B,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,KAAK,CAAC,CAAgC;IAC9C,OAAO,CAAC,OAAO,CAAoC;IACnD,OAAO,CAAC,QAAQ,CAAC,CAAgB;IACjC,OAAO,CAAC,SAAS,CAAC,CAAS;gBACE,OAAO,EAAE,mBAAmB;IAEzD,OAAO,KAAK,KAAK,GAA2C;IAC5D,OAAO,CAAC,IAAI;YAME,IAAI;IAOlB,8EAA8E;IACxE,KAAK;IACX,mEAAmE;IAC7D,WAAW;IAEjB,0HAA0H;IACpH,MAAM,CAAC,SAAS,EAAE,MAAM;IAe9B,uFAAuF;IACvF,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC;IASrC,gGAAgG;IAChG,KAAK;YASS,IAAI;IAiBlB,4GAA4G;IAC5G,KAAK;IAgBL,IAAI;IAEJ;;;OAGG;IACG,KAAK;CAMZ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export declare function keygen(file: string): Promise<{
|
|
3
|
+
publicKey: string;
|
|
4
|
+
fingerprint: string;
|
|
5
|
+
}>;
|
|
6
|
+
/** Every record in an exported archive, and every problem with it; the archive's lines are segments in order. */
|
|
7
|
+
export declare function read(archive: string, key: {
|
|
8
|
+
publicKey: string;
|
|
9
|
+
privateKey: string;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
records: unknown[];
|
|
12
|
+
problems: string[];
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=audit-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-cli.d.ts","sourceRoot":"","sources":["../../src/audit-cli.ts"],"names":[],"mappings":";AAuBA,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM;;;GAMxC;AAED,iHAAiH;AACjH,wBAAsB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE;;;GAoBzF"}
|
package/lib/types/bridge.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The phone's side of this DSH (
|
|
3
|
-
* `
|
|
2
|
+
* The phone's side of this DSH (the server's
|
|
3
|
+
* `docs/tech/relay.md`, "The allow-list"). The relay hands this
|
|
4
4
|
* plugin a confirmed pairing's `call` and `mux` frames; the bridge checks each
|
|
5
5
|
* against the allow-list and replays it against DSH's own Remote API on
|
|
6
6
|
* loopback, as an answering identity of that pairing's own, then sends the
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { z } from 'zod';
|
|
16
16
|
import { type PhoneSessionOps } from './phone-session.js';
|
|
17
|
+
import type { OwnerFilter } from './shared-owner.js';
|
|
17
18
|
/** Unary methods a phone may call. A test holds this list. */
|
|
18
19
|
export declare const ALLOWED_CALLS: ReadonlySet<string>;
|
|
19
20
|
/** Streams a phone may open on the mux. A test holds this list. */
|
|
@@ -50,6 +51,8 @@ export interface BridgeOptions {
|
|
|
50
51
|
log?: (message: string, error?: unknown) => void;
|
|
51
52
|
/** Only these session operations supplement DSH's native calls. */
|
|
52
53
|
session?: PhoneSessionOps;
|
|
54
|
+
/** On a shared DSH, whose sessions each pairing's member may reach (src/shared-owner.ts); none on a personal computer. */
|
|
55
|
+
owners?: () => OwnerFilter | undefined;
|
|
53
56
|
}
|
|
54
57
|
export declare class Bridge {
|
|
55
58
|
private readonly options;
|
|
@@ -57,13 +60,14 @@ export declare class Bridge {
|
|
|
57
60
|
private uploads;
|
|
58
61
|
private promptCalls;
|
|
59
62
|
constructor(options: BridgeOptions);
|
|
60
|
-
handle(frame: Forwarded):
|
|
63
|
+
handle(frame: Forwarded): undefined;
|
|
61
64
|
/** The relay connection ended: every phone is gone with it. */
|
|
62
65
|
dropAll(): void;
|
|
63
66
|
private link;
|
|
64
67
|
private drop;
|
|
65
68
|
private call;
|
|
66
69
|
private mux;
|
|
70
|
+
private muxNow;
|
|
67
71
|
private openMux;
|
|
68
72
|
/** Every open stream of a pairing ends, as DSH itself would end it. */
|
|
69
73
|
private closeStreams;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,8DAA8D;AAC9D,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,MAAM,CAM5C,CAAC;AAEH,mEAAmE;AACnE,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,MAAM,CAA0C,CAAC;AAO3F,8CAA8C;AAC9C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;mBAA8C,CAAC;AAC3E,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAUxD,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,SAAS,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACpC,uCAAuC;IACvC,I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