agenthub-multiagent-mcp 1.75.0 → 1.76.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/dist/client.d.ts +19 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +31 -0
- package/dist/client.js.map +1 -1
- package/dist/commands/setup-shell.js +11 -11
- package/dist/employee.d.ts +11 -0
- package/dist/employee.d.ts.map +1 -1
- package/dist/employee.js +64 -1
- package/dist/employee.js.map +1 -1
- package/dist/employee.test.js +88 -1
- package/dist/employee.test.js.map +1 -1
- package/dist/goshtiChannel/client.d.ts +9 -0
- package/dist/goshtiChannel/client.d.ts.map +1 -0
- package/dist/goshtiChannel/client.js +63 -0
- package/dist/goshtiChannel/client.js.map +1 -0
- package/dist/goshtiChannel/config.d.ts +42 -0
- package/dist/goshtiChannel/config.d.ts.map +1 -0
- package/dist/goshtiChannel/config.js +129 -0
- package/dist/goshtiChannel/config.js.map +1 -0
- package/dist/goshtiChannel/config.test.d.ts +2 -0
- package/dist/goshtiChannel/config.test.d.ts.map +1 -0
- package/dist/goshtiChannel/config.test.js +73 -0
- package/dist/goshtiChannel/config.test.js.map +1 -0
- package/dist/goshtiChannel/core.d.ts +63 -0
- package/dist/goshtiChannel/core.d.ts.map +1 -0
- package/dist/goshtiChannel/core.js +237 -0
- package/dist/goshtiChannel/core.js.map +1 -0
- package/dist/goshtiChannel/core.test.d.ts +2 -0
- package/dist/goshtiChannel/core.test.d.ts.map +1 -0
- package/dist/goshtiChannel/core.test.js +250 -0
- package/dist/goshtiChannel/core.test.js.map +1 -0
- package/dist/goshtiChannel/credential.d.ts +29 -0
- package/dist/goshtiChannel/credential.d.ts.map +1 -0
- package/dist/goshtiChannel/credential.js +160 -0
- package/dist/goshtiChannel/credential.js.map +1 -0
- package/dist/goshtiChannel/credential.test.d.ts +2 -0
- package/dist/goshtiChannel/credential.test.d.ts.map +1 -0
- package/dist/goshtiChannel/credential.test.js +127 -0
- package/dist/goshtiChannel/credential.test.js.map +1 -0
- package/dist/goshtiChannel/e2e.test.d.ts +2 -0
- package/dist/goshtiChannel/e2e.test.d.ts.map +1 -0
- package/dist/goshtiChannel/e2e.test.js +163 -0
- package/dist/goshtiChannel/e2e.test.js.map +1 -0
- package/dist/goshtiChannel/policy.d.ts +154 -0
- package/dist/goshtiChannel/policy.d.ts.map +1 -0
- package/dist/goshtiChannel/policy.js +240 -0
- package/dist/goshtiChannel/policy.js.map +1 -0
- package/dist/goshtiChannel/policy.test.d.ts +2 -0
- package/dist/goshtiChannel/policy.test.d.ts.map +1 -0
- package/dist/goshtiChannel/policy.test.js +263 -0
- package/dist/goshtiChannel/policy.test.js.map +1 -0
- package/dist/goshtiChannel/setup.d.ts +15 -0
- package/dist/goshtiChannel/setup.d.ts.map +1 -0
- package/dist/goshtiChannel/setup.js +125 -0
- package/dist/goshtiChannel/setup.js.map +1 -0
- package/dist/goshtiChannel/setup.test.d.ts +2 -0
- package/dist/goshtiChannel/setup.test.d.ts.map +1 -0
- package/dist/goshtiChannel/setup.test.js +96 -0
- package/dist/goshtiChannel/setup.test.js.map +1 -0
- package/dist/goshtiChannel/stream.d.ts +39 -0
- package/dist/goshtiChannel/stream.d.ts.map +1 -0
- package/dist/goshtiChannel/stream.js +174 -0
- package/dist/goshtiChannel/stream.js.map +1 -0
- package/dist/goshtiChannel/stream.test.d.ts +2 -0
- package/dist/goshtiChannel/stream.test.d.ts.map +1 -0
- package/dist/goshtiChannel/stream.test.js +164 -0
- package/dist/goshtiChannel/stream.test.js.map +1 -0
- package/dist/goshtiChannel.d.ts +22 -0
- package/dist/goshtiChannel.d.ts.map +1 -0
- package/dist/goshtiChannel.js +193 -0
- package/dist/goshtiChannel.js.map +1 -0
- package/dist/state.d.ts +2 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js.map +1 -1
- package/dist/tools/brainWriteCheck.test.d.ts +10 -0
- package/dist/tools/brainWriteCheck.test.d.ts.map +1 -0
- package/dist/tools/brainWriteCheck.test.js +67 -0
- package/dist/tools/brainWriteCheck.test.js.map +1 -0
- package/dist/tools/employeeTraining.d.ts +46 -0
- package/dist/tools/employeeTraining.d.ts.map +1 -0
- package/dist/tools/employeeTraining.js +329 -0
- package/dist/tools/employeeTraining.js.map +1 -0
- package/dist/tools/employeeTraining.test.d.ts +7 -0
- package/dist/tools/employeeTraining.test.d.ts.map +1 -0
- package/dist/tools/employeeTraining.test.js +190 -0
- package/dist/tools/employeeTraining.test.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +146 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/runs.d.ts +43 -0
- package/dist/tools/runs.d.ts.map +1 -0
- package/dist/tools/runs.js +280 -0
- package/dist/tools/runs.js.map +1 -0
- package/dist/tools/runs.test.d.ts +9 -0
- package/dist/tools/runs.test.d.ts.map +1 -0
- package/dist/tools/runs.test.js +114 -0
- package/dist/tools/runs.test.js.map +1 -0
- package/dist/tools/tools.test.js +54 -2
- package/dist/tools/tools.test.js.map +1 -1
- package/package.json +79 -78
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// Where the Goshti channel keeps the person's token (add-goshti-claude-connector §2.6).
|
|
2
|
+
//
|
|
3
|
+
// In the OS credential store where there is one — Keychain on macOS, the
|
|
4
|
+
// Secret Service on Linux (`secret-tool`), the Windows credential vault —
|
|
5
|
+
// otherwise in `credentials.json` with owner-only permissions beside the
|
|
6
|
+
// config. Never in an environment variable, because a variable is how a token
|
|
7
|
+
// ends up committed in a project's `.mcp.json` env block.
|
|
8
|
+
//
|
|
9
|
+
// The token never goes on a command line: every process on the machine can
|
|
10
|
+
// read another's arguments. Each store is driven with the secret on stdin.
|
|
11
|
+
import { spawnSync } from "node:child_process";
|
|
12
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
export const SERVICE = "goshti-channel";
|
|
15
|
+
export const defaultRunner = (cmd, args, input) => {
|
|
16
|
+
const r = spawnSync(cmd, args, {
|
|
17
|
+
input,
|
|
18
|
+
encoding: "utf8",
|
|
19
|
+
timeout: 15_000,
|
|
20
|
+
windowsHide: true,
|
|
21
|
+
});
|
|
22
|
+
return { status: r.error ? null : r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
23
|
+
};
|
|
24
|
+
function psEncoded(script) {
|
|
25
|
+
return Buffer.from(script, "utf16le").toString("base64");
|
|
26
|
+
}
|
|
27
|
+
const PS_VAULT = `$ErrorActionPreference='Stop'
|
|
28
|
+
try { [void][Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime] } catch { exit 3 }
|
|
29
|
+
$v = New-Object Windows.Security.Credentials.PasswordVault
|
|
30
|
+
$a = [Console]::In.ReadLine()
|
|
31
|
+
`;
|
|
32
|
+
const PS_GET = `${PS_VAULT}try { $c = $v.Retrieve('${SERVICE}', $a); $c.RetrievePassword(); [Console]::Out.Write($c.Password) } catch { exit 1 }`;
|
|
33
|
+
const PS_SET = `${PS_VAULT}$t = [Console]::In.ReadLine()
|
|
34
|
+
try { $o = $v.Retrieve('${SERVICE}', $a); $v.Remove($o) } catch {}
|
|
35
|
+
try { $v.Add((New-Object Windows.Security.Credentials.PasswordCredential('${SERVICE}', $a, $t))) } catch { exit 1 }`;
|
|
36
|
+
const PS_DEL = `${PS_VAULT}try { $o = $v.Retrieve('${SERVICE}', $a); $v.Remove($o) } catch { exit 1 }`;
|
|
37
|
+
function quoteForSecurity(s) {
|
|
38
|
+
return `"${s.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
39
|
+
}
|
|
40
|
+
/** The OS credential store for a platform, or null where there is none. */
|
|
41
|
+
export function platformKeychain(platform, run = defaultRunner) {
|
|
42
|
+
const ok = (r) => r.status === 0;
|
|
43
|
+
const value = (r) => {
|
|
44
|
+
if (!ok(r))
|
|
45
|
+
return null;
|
|
46
|
+
const v = r.stdout.replace(/[\r\n]+$/, "");
|
|
47
|
+
return v === "" ? null : v;
|
|
48
|
+
};
|
|
49
|
+
switch (platform) {
|
|
50
|
+
case "darwin":
|
|
51
|
+
return {
|
|
52
|
+
name: "macos-keychain",
|
|
53
|
+
get: (a) => value(run("security", ["find-generic-password", "-s", SERVICE, "-a", a, "-w"])),
|
|
54
|
+
// `security -i` reads its commands from stdin, which keeps `-w <token>`
|
|
55
|
+
// off the process list.
|
|
56
|
+
set: (a, s) => ok(run("security", ["-i"], `add-generic-password -U -s ${SERVICE} -a ${quoteForSecurity(a)} -w ${quoteForSecurity(s)}\n`)),
|
|
57
|
+
remove: (a) => ok(run("security", ["delete-generic-password", "-s", SERVICE, "-a", a])),
|
|
58
|
+
};
|
|
59
|
+
case "linux":
|
|
60
|
+
return {
|
|
61
|
+
name: "secret-service",
|
|
62
|
+
get: (a) => value(run("secret-tool", ["lookup", "service", SERVICE, "account", a])),
|
|
63
|
+
set: (a, s) => ok(run("secret-tool", ["store", "--label", "Goshti channel", "service", SERVICE, "account", a], s)),
|
|
64
|
+
remove: (a) => ok(run("secret-tool", ["clear", "service", SERVICE, "account", a])),
|
|
65
|
+
};
|
|
66
|
+
case "win32": {
|
|
67
|
+
const ps = (script, input) => run("powershell.exe", ["-NoProfile", "-NonInteractive", "-EncodedCommand", psEncoded(script)], input);
|
|
68
|
+
return {
|
|
69
|
+
name: "windows-credential-vault",
|
|
70
|
+
get: (a) => value(ps(PS_GET, `${a}\n`)),
|
|
71
|
+
set: (a, s) => ok(ps(PS_SET, `${a}\n${s}\n`)),
|
|
72
|
+
remove: (a) => ok(ps(PS_DEL, `${a}\n`)),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
default:
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function credFile(dir) {
|
|
80
|
+
return join(dir, "credentials.json");
|
|
81
|
+
}
|
|
82
|
+
function readFileStore(dir) {
|
|
83
|
+
const file = credFile(dir);
|
|
84
|
+
if (!existsSync(file))
|
|
85
|
+
return {};
|
|
86
|
+
if (process.platform !== "win32" && (statSync(file).mode & 0o077) !== 0) {
|
|
87
|
+
throw new Error(`${file} is readable by others; refusing to use it. Run \`chmod 600 ${file}\` or \`goshti-channel setup\` again.`);
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
91
|
+
const out = {};
|
|
92
|
+
for (const [k, v] of Object.entries(parsed.accounts ?? {}))
|
|
93
|
+
if (typeof v === "string")
|
|
94
|
+
out[k] = v;
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return {};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function writeFileStore(dir, accounts) {
|
|
102
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
103
|
+
const file = credFile(dir);
|
|
104
|
+
const tmp = `${file}.tmp`;
|
|
105
|
+
writeFileSync(tmp, `${JSON.stringify({ accounts }, null, 2)}\n`, { mode: 0o600 });
|
|
106
|
+
try {
|
|
107
|
+
chmodSync(tmp, 0o600);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// Windows: the per-user profile ACL is the protection.
|
|
111
|
+
}
|
|
112
|
+
renameSync(tmp, file);
|
|
113
|
+
}
|
|
114
|
+
/** Store a token. Returns where: `os:<store>` or `file:<path>`. */
|
|
115
|
+
export function storeCredential(account, token, stores) {
|
|
116
|
+
if (stores.keychain?.set(account, token)) {
|
|
117
|
+
// A copy left in the file from an earlier fallback would outlive a
|
|
118
|
+
// rotation and be the one an attacker reads.
|
|
119
|
+
dropFromFile(account, stores.dir);
|
|
120
|
+
return `os:${stores.keychain.name}`;
|
|
121
|
+
}
|
|
122
|
+
let accounts = {};
|
|
123
|
+
try {
|
|
124
|
+
accounts = readFileStore(stores.dir);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
accounts = {}; // a file others could read is replaced, not merged into
|
|
128
|
+
}
|
|
129
|
+
accounts[account] = token;
|
|
130
|
+
writeFileStore(stores.dir, accounts);
|
|
131
|
+
return `file:${credFile(stores.dir)}`;
|
|
132
|
+
}
|
|
133
|
+
/** The stored token, or null. Throws when the file exists but others can read it. */
|
|
134
|
+
export function loadCredential(account, stores) {
|
|
135
|
+
const fromStore = stores.keychain?.get(account);
|
|
136
|
+
if (fromStore)
|
|
137
|
+
return { token: fromStore, where: `os:${stores.keychain.name}` };
|
|
138
|
+
const token = readFileStore(stores.dir)[account];
|
|
139
|
+
return token ? { token, where: `file:${credFile(stores.dir)}` } : null;
|
|
140
|
+
}
|
|
141
|
+
function dropFromFile(account, dir) {
|
|
142
|
+
if (!existsSync(credFile(dir)))
|
|
143
|
+
return;
|
|
144
|
+
let accounts;
|
|
145
|
+
try {
|
|
146
|
+
accounts = readFileStore(dir);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
accounts = {};
|
|
150
|
+
}
|
|
151
|
+
if (account in accounts || Object.keys(accounts).length === 0) {
|
|
152
|
+
delete accounts[account];
|
|
153
|
+
writeFileStore(dir, accounts);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export function removeCredential(account, stores) {
|
|
157
|
+
stores.keychain?.remove(account);
|
|
158
|
+
dropFromFile(account, stores.dir);
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.js","sourceRoot":"","sources":["../../src/goshtiChannel/credential.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,yEAAyE;AACzE,8EAA8E;AAC9E,0DAA0D;AAC1D,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAA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AAC,IAAI,EAAE,EAAE,CAAC;IACjF,MAAM,KAAK,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;IACjD,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACzE,CAAC;AAED,SAAS,YAAY,CAAC,OAAe,EAAE,GAAW;IAChD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAAE,OAAO;IACvC,IAAI,QAAgC,CAAC;IACrC,IAAI,CAAC;QACH,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,QAAQ,GAAG,EAAE,CAAC;IAChB,CAAC;IACD,IAAI,OAAO,IAAI,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9D,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC;QACzB,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAe,EAAE,MAAc;IAC9D,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.test.d.ts","sourceRoot":"","sources":["../../src/goshtiChannel/credential.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Rule: the credential lives in the OS store, else in a file only its owner can
|
|
2
|
+
// read, and never in a project's MCP configuration (spec "keep its credential
|
|
3
|
+
// out of project files").
|
|
4
|
+
import { chmodSync, existsSync, mkdtempSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { describe, expect, it } from "vitest";
|
|
8
|
+
import { loadCredential, platformKeychain, removeCredential, storeCredential, } from "./credential.js";
|
|
9
|
+
const TOKEN = "s3cr3t-personal-access-token";
|
|
10
|
+
const ACCOUNT = "https://chat.example.com";
|
|
11
|
+
function dir() {
|
|
12
|
+
return mkdtempSync(join(tmpdir(), "goshti-cred-"));
|
|
13
|
+
}
|
|
14
|
+
function memoryKeychain() {
|
|
15
|
+
const items = new Map();
|
|
16
|
+
return {
|
|
17
|
+
name: "test-store",
|
|
18
|
+
items,
|
|
19
|
+
get: (a) => items.get(a) ?? null,
|
|
20
|
+
set: (a, s) => (items.set(a, s), true),
|
|
21
|
+
remove: (a) => items.delete(a),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
describe("storing the credential", () => {
|
|
25
|
+
it("uses the OS store when there is one, and writes no file", () => {
|
|
26
|
+
const d = dir();
|
|
27
|
+
const kc = memoryKeychain();
|
|
28
|
+
const where = storeCredential(ACCOUNT, TOKEN, { keychain: kc, dir: d });
|
|
29
|
+
expect(where).toBe("os:test-store");
|
|
30
|
+
expect(kc.items.get(ACCOUNT)).toBe(TOKEN);
|
|
31
|
+
expect(existsSync(join(d, "credentials.json"))).toBe(false);
|
|
32
|
+
expect(loadCredential(ACCOUNT, { keychain: kc, dir: d })).toEqual({ token: TOKEN, where: "os:test-store" });
|
|
33
|
+
});
|
|
34
|
+
it("falls back to an owner-only file when the OS store refuses", () => {
|
|
35
|
+
const d = dir();
|
|
36
|
+
const broken = { name: "broken", get: () => null, set: () => false, remove: () => false };
|
|
37
|
+
const where = storeCredential(ACCOUNT, TOKEN, { keychain: broken, dir: d });
|
|
38
|
+
const file = join(d, "credentials.json");
|
|
39
|
+
expect(where).toBe(`file:${file}`);
|
|
40
|
+
expect(JSON.parse(readFileSync(file, "utf8")).accounts[ACCOUNT]).toBe(TOKEN);
|
|
41
|
+
if (process.platform !== "win32")
|
|
42
|
+
expect(statSync(file).mode & 0o077).toBe(0);
|
|
43
|
+
expect(loadCredential(ACCOUNT, { keychain: broken, dir: d })?.token).toBe(TOKEN);
|
|
44
|
+
});
|
|
45
|
+
it("falls back to the file when there is no OS store at all", () => {
|
|
46
|
+
const d = dir();
|
|
47
|
+
expect(storeCredential(ACCOUNT, TOKEN, { keychain: null, dir: d })).toMatch(/^file:/);
|
|
48
|
+
expect(loadCredential(ACCOUNT, { keychain: null, dir: d })?.token).toBe(TOKEN);
|
|
49
|
+
});
|
|
50
|
+
it.skipIf(process.platform === "win32")("refuses a credential file others can read", () => {
|
|
51
|
+
const d = dir();
|
|
52
|
+
storeCredential(ACCOUNT, TOKEN, { keychain: null, dir: d });
|
|
53
|
+
chmodSync(join(d, "credentials.json"), 0o644);
|
|
54
|
+
expect(() => loadCredential(ACCOUNT, { keychain: null, dir: d })).toThrow(/readable by others/);
|
|
55
|
+
});
|
|
56
|
+
it("reports nothing stored as null", () => {
|
|
57
|
+
expect(loadCredential(ACCOUNT, { keychain: memoryKeychain(), dir: dir() })).toBeNull();
|
|
58
|
+
});
|
|
59
|
+
it("removes it from both places", () => {
|
|
60
|
+
const d = dir();
|
|
61
|
+
const kc = memoryKeychain();
|
|
62
|
+
storeCredential(ACCOUNT, TOKEN, { keychain: kc, dir: d });
|
|
63
|
+
storeCredential(ACCOUNT, TOKEN, { keychain: null, dir: d });
|
|
64
|
+
removeCredential(ACCOUNT, { keychain: kc, dir: d });
|
|
65
|
+
expect(loadCredential(ACCOUNT, { keychain: kc, dir: d })).toBeNull();
|
|
66
|
+
});
|
|
67
|
+
it("ignores an environment variable holding a token", () => {
|
|
68
|
+
// A variable is how a token ends up in `.mcp.json`'s env block.
|
|
69
|
+
process.env.GOSHTI_TOKEN = TOKEN;
|
|
70
|
+
try {
|
|
71
|
+
expect(loadCredential(ACCOUNT, { keychain: null, dir: dir() })).toBeNull();
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
delete process.env.GOSHTI_TOKEN;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
it("does not leave the file readable by others even if it existed before", () => {
|
|
78
|
+
if (process.platform === "win32")
|
|
79
|
+
return;
|
|
80
|
+
const d = dir();
|
|
81
|
+
const file = join(d, "credentials.json");
|
|
82
|
+
writeFileSync(file, JSON.stringify({ accounts: {} }), { mode: 0o644 });
|
|
83
|
+
storeCredential(ACCOUNT, TOKEN, { keychain: null, dir: d });
|
|
84
|
+
expect(statSync(file).mode & 0o077).toBe(0);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
describe("the OS stores", () => {
|
|
88
|
+
function recorder(status = 0, stdout = "") {
|
|
89
|
+
const calls = [];
|
|
90
|
+
return {
|
|
91
|
+
calls,
|
|
92
|
+
run: (cmd, args, input) => {
|
|
93
|
+
calls.push({ cmd, args, input });
|
|
94
|
+
return { status, stdout, stderr: "" };
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// A command line is visible to every process on the machine; stdin is not.
|
|
99
|
+
for (const platform of ["darwin", "linux", "win32"]) {
|
|
100
|
+
it(`${platform}: never puts the token on a command line`, () => {
|
|
101
|
+
const r = recorder();
|
|
102
|
+
const kc = platformKeychain(platform, r.run);
|
|
103
|
+
expect(kc).not.toBeNull();
|
|
104
|
+
kc.set(ACCOUNT, TOKEN);
|
|
105
|
+
expect(r.calls.length).toBeGreaterThan(0);
|
|
106
|
+
for (const c of r.calls) {
|
|
107
|
+
expect(c.args.join(" ")).not.toContain(TOKEN);
|
|
108
|
+
expect(c.cmd).not.toContain(TOKEN);
|
|
109
|
+
}
|
|
110
|
+
expect(r.calls.some((c) => c.input?.includes(TOKEN))).toBe(true);
|
|
111
|
+
});
|
|
112
|
+
it(`${platform}: reads the token from the store's output`, () => {
|
|
113
|
+
const r = recorder(0, `${TOKEN}\n`);
|
|
114
|
+
expect(platformKeychain(platform, r.run).get(ACCOUNT)).toBe(TOKEN);
|
|
115
|
+
});
|
|
116
|
+
it(`${platform}: a failing store reads as nothing stored`, () => {
|
|
117
|
+
const r = recorder(1, "");
|
|
118
|
+
const kc = platformKeychain(platform, r.run);
|
|
119
|
+
expect(kc.get(ACCOUNT)).toBeNull();
|
|
120
|
+
expect(kc.set(ACCOUNT, TOKEN)).toBe(false);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
it("has no store on an unknown platform", () => {
|
|
124
|
+
expect(platformKeychain("aix", recorder().run)).toBeNull();
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
//# sourceMappingURL=credential.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.test.js","sourceRoot":"","sources":["../../src/goshtiChannel/credential.test.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,8EAA8E;AAC9E,0BAA0B;AAE1B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpG,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAGhB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,KAAK,GAAG,8BAA8B,CAAC;AAC7C,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAE3C,SAAS,GAAG;IACV,OAAO,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,cAAc;IACrB,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,OAAO;QACL,IAA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 @@
|
|
|
1
|
+
{"version":3,"file":"e2e.test.d.ts","sourceRoot":"","sources":["../../src/goshtiChannel/e2e.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// The real entry point, spawned the way Claude Code spawns it, against a local
|
|
2
|
+
// stand-in for Goshti (REST + WebSocket). Covers what the unit tests cannot:
|
|
3
|
+
// that a failure reaches the session as a channel notification rather than a
|
|
4
|
+
// silent idle server, and that a trigger posted in Goshti arrives and can be
|
|
5
|
+
// answered in its thread.
|
|
6
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
7
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
8
|
+
import { mkdtempSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { createServer } from "node:http";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join, resolve } from "node:path";
|
|
12
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import { WebSocketServer } from "ws";
|
|
15
|
+
const ENTRY = resolve(__dirname, "..", "goshtiChannel.ts");
|
|
16
|
+
const TOKEN = "e2e-token-not-real";
|
|
17
|
+
const Note = z.object({
|
|
18
|
+
method: z.literal("notifications/claude/channel"),
|
|
19
|
+
params: z.object({ content: z.string(), meta: z.record(z.string(), z.string()) }),
|
|
20
|
+
});
|
|
21
|
+
const cleanups = [];
|
|
22
|
+
afterEach(async () => {
|
|
23
|
+
for (const c of cleanups.splice(0).reverse())
|
|
24
|
+
await c();
|
|
25
|
+
});
|
|
26
|
+
function home(config, credential = true) {
|
|
27
|
+
const d = mkdtempSync(join(tmpdir(), "goshti-e2e-"));
|
|
28
|
+
if (config)
|
|
29
|
+
writeFileSync(join(d, "config.json"), JSON.stringify(config));
|
|
30
|
+
if (credential && config) {
|
|
31
|
+
writeFileSync(join(d, "credentials.json"), JSON.stringify({ accounts: { [String(config.url)]: TOKEN } }), {
|
|
32
|
+
mode: 0o600,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return d;
|
|
36
|
+
}
|
|
37
|
+
async function start(dir) {
|
|
38
|
+
const notes = [];
|
|
39
|
+
const client = new Client({ name: "e2e", version: "0" }, { capabilities: {} });
|
|
40
|
+
client.setNotificationHandler(Note, async (n) => {
|
|
41
|
+
notes.push(n.params);
|
|
42
|
+
});
|
|
43
|
+
const transport = new StdioClientTransport({
|
|
44
|
+
command: process.execPath,
|
|
45
|
+
args: ["--import", "tsx", ENTRY],
|
|
46
|
+
env: { ...process.env, GOSHTI_CHANNEL_HOME: dir },
|
|
47
|
+
stderr: "pipe",
|
|
48
|
+
});
|
|
49
|
+
await client.connect(transport);
|
|
50
|
+
cleanups.push(() => client.close());
|
|
51
|
+
return { client, notes };
|
|
52
|
+
}
|
|
53
|
+
async function until(cond, ms = 15_000) {
|
|
54
|
+
const t = Date.now();
|
|
55
|
+
while (!cond()) {
|
|
56
|
+
if (Date.now() - t > ms)
|
|
57
|
+
throw new Error("timed out");
|
|
58
|
+
await new Promise((r) => setTimeout(r, 25));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function goshti(opts = {}) {
|
|
62
|
+
const posts = [];
|
|
63
|
+
const http = createServer((req, res) => {
|
|
64
|
+
if (req.headers.authorization !== `Bearer ${TOKEN}` || opts.refuse) {
|
|
65
|
+
res.writeHead(401).end("{}");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (req.url === "/api/v4/users/me") {
|
|
69
|
+
res.end(JSON.stringify({ id: "me1", username: "sumit", is_bot: false }));
|
|
70
|
+
}
|
|
71
|
+
else if (req.url === "/api/v4/posts" && req.method === "POST") {
|
|
72
|
+
let body = "";
|
|
73
|
+
req.on("data", (c) => (body += c));
|
|
74
|
+
req.on("end", () => {
|
|
75
|
+
posts.push(JSON.parse(body));
|
|
76
|
+
res.writeHead(201).end(JSON.stringify({ id: "reply1" }));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
res.writeHead(404).end("{}");
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const wss = new WebSocketServer({ noServer: true });
|
|
84
|
+
let current;
|
|
85
|
+
http.on("upgrade", (req, sock, head) => {
|
|
86
|
+
wss.handleUpgrade(req, sock, head, (ws) => {
|
|
87
|
+
current = ws;
|
|
88
|
+
ws.on("message", (raw) => {
|
|
89
|
+
const f = JSON.parse(raw.toString());
|
|
90
|
+
if (f.action === "authentication_challenge") {
|
|
91
|
+
ws.send(JSON.stringify({ seq_reply: f.seq, status: "OK" }));
|
|
92
|
+
ws.send(JSON.stringify({ event: "hello", data: {} }));
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
await new Promise((r) => http.listen(0, "127.0.0.1", r));
|
|
98
|
+
cleanups.push(() => new Promise((r) => {
|
|
99
|
+
for (const c of wss.clients)
|
|
100
|
+
c.terminate();
|
|
101
|
+
http.close(() => r());
|
|
102
|
+
}));
|
|
103
|
+
return { url: `http://127.0.0.1:${http.address().port}`, posts, socket: () => current };
|
|
104
|
+
}
|
|
105
|
+
describe("goshti-channel as Claude Code runs it", { timeout: 30_000 }, () => {
|
|
106
|
+
it("declares the channel capability and the reply tool", async () => {
|
|
107
|
+
const { client } = await start(home(null));
|
|
108
|
+
expect(client.getServerCapabilities()?.experimental).toHaveProperty("claude/channel");
|
|
109
|
+
const tools = await client.listTools();
|
|
110
|
+
expect(tools.tools.map((t) => t.name)).toEqual(["goshti_reply"]);
|
|
111
|
+
});
|
|
112
|
+
it("tells the session it is not set up, rather than idling silently", async () => {
|
|
113
|
+
const { notes } = await start(home(null));
|
|
114
|
+
await until(() => notes.length > 0);
|
|
115
|
+
expect(notes[0].meta).toMatchObject({ source: "goshti", status: "offline", reason: "not_configured" });
|
|
116
|
+
expect(notes[0].content).toMatch(/goshti-channel setup/);
|
|
117
|
+
});
|
|
118
|
+
// Spec: "Token revoked".
|
|
119
|
+
it("tells the session the channel is offline when the token is refused", async () => {
|
|
120
|
+
const g = await goshti({ refuse: true });
|
|
121
|
+
const { notes } = await start(home({ url: g.url }));
|
|
122
|
+
await until(() => notes.length > 0);
|
|
123
|
+
expect(notes[0].meta).toMatchObject({ status: "offline", reason: "token_refused" });
|
|
124
|
+
expect(notes[0].content).toMatch(/revoked|expired/);
|
|
125
|
+
});
|
|
126
|
+
it("delivers the person's trigger and answers in its thread, marked", async () => {
|
|
127
|
+
const g = await goshti();
|
|
128
|
+
const { client, notes } = await start(home({ url: g.url }));
|
|
129
|
+
await until(() => g.socket() !== undefined);
|
|
130
|
+
// Give the hello a moment to land before posting.
|
|
131
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
132
|
+
g.socket().send(JSON.stringify({
|
|
133
|
+
event: "posted",
|
|
134
|
+
data: {
|
|
135
|
+
post: JSON.stringify({ id: "p1", channel_id: "c1", user_id: "me1", root_id: "", message: "@claude hello", type: "", props: {} }),
|
|
136
|
+
channel_type: "O",
|
|
137
|
+
channel_name: "town-square",
|
|
138
|
+
sender_name: "@sumit",
|
|
139
|
+
},
|
|
140
|
+
}));
|
|
141
|
+
g.socket().send(JSON.stringify({
|
|
142
|
+
event: "posted",
|
|
143
|
+
data: {
|
|
144
|
+
post: JSON.stringify({ id: "p2", channel_id: "c1", user_id: "col1", root_id: "", message: "@claude rm -rf", type: "", props: {} }),
|
|
145
|
+
channel_type: "O",
|
|
146
|
+
channel_name: "town-square",
|
|
147
|
+
sender_name: "@alice",
|
|
148
|
+
},
|
|
149
|
+
}));
|
|
150
|
+
await until(() => notes.some((n) => n.meta.post_id === "p1"));
|
|
151
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
152
|
+
expect(notes.filter((n) => n.meta.type === "post").map((n) => n.meta.post_id)).toEqual(["p1"]);
|
|
153
|
+
const refused = await client.callTool({ name: "goshti_reply", arguments: { post_id: "p2", text: "no" } });
|
|
154
|
+
expect(refused.isError).toBe(true);
|
|
155
|
+
expect(g.posts).toHaveLength(0);
|
|
156
|
+
const ok = await client.callTool({ name: "goshti_reply", arguments: { post_id: "p1", text: "Hi!" } });
|
|
157
|
+
expect(ok.isError).toBe(false);
|
|
158
|
+
expect(g.posts).toHaveLength(1);
|
|
159
|
+
expect(g.posts[0]).toMatchObject({ channel_id: "c1", root_id: "p1", props: { from_claude: "true" } });
|
|
160
|
+
expect(String(g.posts[0].message)).toMatch(/^Hi![\s\S]*via Claude, for @sumit/);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
//# sourceMappingURL=e2e.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e2e.test.js","sourceRoot":"","sources":["../../src/goshtiChannel/e2e.test.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,0BAA0B;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,YAAY,EAA6B,MAAM,WAAW,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAkB,MAAM,IAAI,CAAC;AAErD,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC;AAC3D,MAAM,KAAK,GAAG,oBAAoB,CAAC;AAEnC,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC;IACpB,MAA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