@falkenslab/agent-kit 0.31.0 → 0.33.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 +175 -175
- package/dist/chat/chatController.d.ts +5 -0
- package/dist/chat/chatController.js +13 -0
- package/dist/core/claudeAuth.d.ts +53 -21
- package/dist/core/claudeAuth.js +135 -22
- package/dist/core/hooks/transcriptLogger.d.ts +2 -2
- package/dist/core/hooks/transcriptLogger.js +2 -2
- package/dist/core/mcpDepth.d.ts +9 -0
- package/dist/core/mcpDepth.js +12 -0
- package/dist/core/messages/de.js +9 -7
- package/dist/core/messages/en.d.ts +7 -5
- package/dist/core/messages/en.js +9 -7
- package/dist/core/messages/es.js +9 -7
- package/dist/core/messages/fr.js +9 -7
- package/dist/core/packaged.d.ts +6 -0
- package/dist/core/packaged.js +18 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/serveMcp.d.ts +28 -0
- package/dist/mcp/serveMcp.js +177 -0
- package/dist/tui/claudeAuth.d.ts +12 -17
- package/dist/tui/claudeAuth.js +37 -66
- package/package.json +13 -1
package/dist/tui/claudeAuth.d.ts
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import { type ClaudeAuthConfig } from "../core/claudeAuth.js";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* Makes sure the agent can reach Claude before a terminal chat starts: returns at once when
|
|
3
|
+
* `claudeSignedIn()` says so (an API key or the person's own token in the environment, or a
|
|
4
|
+
* Claude Code sign-in). Otherwise it says why, asks whether to sign in, and runs Claude Code's
|
|
5
|
+
* own `claude auth login` (the binary the Agent SDK ships) on this terminal: Anthropic's page in
|
|
6
|
+
* the browser, the code it shows pasted here. The binary keeps the credentials; nothing is
|
|
7
|
+
* returned or stored (ADR-009: Anthropic's terms forbid an agent collecting them). Exits the
|
|
8
|
+
* process when the person declines or the sign-in doesn't complete: there's no agent to run
|
|
9
|
+
* without Claude.
|
|
8
10
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* the interactive flow does generate one, it's returned so the caller can save it wherever
|
|
12
|
-
* it wants (a file, an OS keychain, ...) and pass it back in as `config.claudeCodeOAuthToken`
|
|
13
|
-
* next time; returns `undefined` when auth was already resolved (an env var, or the `config`
|
|
14
|
-
* passed in) and nothing new was generated.
|
|
15
|
-
*
|
|
16
|
-
* Only makes sense with a real terminal in front of a human (a `runWizard()` confirm, colored console
|
|
17
|
-
* output), which is why it lives here rather than in the non-interactive core.
|
|
11
|
+
* Only makes sense with a terminal in front of a person (a `runWizard()` confirm, colored
|
|
12
|
+
* output); a host without one uses `startClaudeSignIn()` from the core.
|
|
18
13
|
*/
|
|
19
|
-
export declare function ensureClaudeAuth(
|
|
14
|
+
export declare function ensureClaudeAuth(options?: {
|
|
20
15
|
language?: string;
|
|
21
|
-
}): Promise<
|
|
16
|
+
}): Promise<void>;
|
package/dist/tui/claudeAuth.js
CHANGED
|
@@ -1,78 +1,47 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
import {
|
|
2
|
+
import { claudeCommand, claudeExecutable, claudeSignedIn } from "../core/claudeAuth.js";
|
|
3
3
|
import { isExitPromptError } from "./promptErrors.js";
|
|
4
4
|
import * as ui from "./ui.js";
|
|
5
5
|
import { runWizard } from "./ink/wizard.js";
|
|
6
6
|
import { applyLanguage } from "./language.js";
|
|
7
7
|
import { t } from "../core/messages/index.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* to running the command by hand; stdout is duplicated live and also buffered to extract
|
|
16
|
-
* the token it prints at the end ("Your OAuth token (...): sk-ant-oat01-...").
|
|
17
|
-
*/
|
|
18
|
-
function runSetupToken() {
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
// On Windows npx is npx.cmd, which only runs through a shell. The command is passed as
|
|
21
|
-
// one fixed string there (nothing user-supplied in it): an args array with
|
|
22
|
-
// `shell: true` triggers Node's DEP0190 warning, since args are concatenated unescaped.
|
|
23
|
-
const stdio = ["inherit", "pipe", "inherit"];
|
|
24
|
-
const child = process.platform === "win32"
|
|
25
|
-
? spawn("npx @anthropic-ai/claude-code setup-token", { stdio, shell: true })
|
|
26
|
-
: spawn("npx", ["@anthropic-ai/claude-code", "setup-token"], { stdio });
|
|
27
|
-
let output = "";
|
|
28
|
-
child.stdout.on("data", (chunk) => {
|
|
29
|
-
const text = chunk.toString("utf-8");
|
|
30
|
-
output += text;
|
|
31
|
-
process.stdout.write(text);
|
|
32
|
-
});
|
|
33
|
-
child.on("error", reject);
|
|
34
|
-
child.on("exit", (code) => {
|
|
35
|
-
if (code !== 0) {
|
|
36
|
-
reject(new Error(`"claude setup-token" exited with code ${code}.`));
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const match = output.match(TOKEN_PATTERN);
|
|
40
|
-
if (!match) {
|
|
41
|
-
reject(new Error('"claude setup-token" exited without errors, but no token was found in its ' +
|
|
42
|
-
"output (sk-ant-oat...). Copy it by hand into CLAUDE_CODE_OAUTH_TOKEN if you see it above."));
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
resolve(match[0]);
|
|
46
|
-
});
|
|
8
|
+
/** Runs Claude Code's own `auth login` on this terminal: it opens the browser, and the person pastes the code here. */
|
|
9
|
+
function runLogin(executable) {
|
|
10
|
+
const command = claudeCommand(executable, ["auth", "login"]);
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
const child = spawn(command.file, command.args, { stdio: "inherit" });
|
|
13
|
+
child.on("error", () => resolve());
|
|
14
|
+
child.on("close", () => resolve());
|
|
47
15
|
});
|
|
48
16
|
}
|
|
49
17
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* the interactive flow does generate one, it's returned so the caller can save it wherever
|
|
59
|
-
* it wants (a file, an OS keychain, ...) and pass it back in as `config.claudeCodeOAuthToken`
|
|
60
|
-
* next time; returns `undefined` when auth was already resolved (an env var, or the `config`
|
|
61
|
-
* passed in) and nothing new was generated.
|
|
18
|
+
* Makes sure the agent can reach Claude before a terminal chat starts: returns at once when
|
|
19
|
+
* `claudeSignedIn()` says so (an API key or the person's own token in the environment, or a
|
|
20
|
+
* Claude Code sign-in). Otherwise it says why, asks whether to sign in, and runs Claude Code's
|
|
21
|
+
* own `claude auth login` (the binary the Agent SDK ships) on this terminal: Anthropic's page in
|
|
22
|
+
* the browser, the code it shows pasted here. The binary keeps the credentials; nothing is
|
|
23
|
+
* returned or stored (ADR-009: Anthropic's terms forbid an agent collecting them). Exits the
|
|
24
|
+
* process when the person declines or the sign-in doesn't complete: there's no agent to run
|
|
25
|
+
* without Claude.
|
|
62
26
|
*
|
|
63
|
-
* Only makes sense with a
|
|
64
|
-
* output)
|
|
27
|
+
* Only makes sense with a terminal in front of a person (a `runWizard()` confirm, colored
|
|
28
|
+
* output); a host without one uses `startClaudeSignIn()` from the core.
|
|
65
29
|
*/
|
|
66
|
-
export async function ensureClaudeAuth(
|
|
67
|
-
if (
|
|
68
|
-
return
|
|
30
|
+
export async function ensureClaudeAuth(options = {}) {
|
|
31
|
+
if (await claudeSignedIn())
|
|
32
|
+
return;
|
|
69
33
|
applyLanguage(options.language);
|
|
70
34
|
const texts = t().auth;
|
|
71
|
-
|
|
72
|
-
|
|
35
|
+
const executable = claudeExecutable();
|
|
36
|
+
if (!executable) {
|
|
37
|
+
console.log(ui.error(`\n${texts.noClaude}`));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
console.log(ui.warn(`\n${texts.notSignedIn}`));
|
|
41
|
+
console.log(ui.dim(texts.notSignedInDetail));
|
|
73
42
|
try {
|
|
74
|
-
const {
|
|
75
|
-
if (!
|
|
43
|
+
const { signIn } = await runWizard([{ type: "confirm", name: "signIn", message: texts.signInQuestion, default: true }]);
|
|
44
|
+
if (!signIn) {
|
|
76
45
|
console.log(ui.error(`\n${texts.cantStart}`));
|
|
77
46
|
process.exit(0);
|
|
78
47
|
}
|
|
@@ -82,10 +51,12 @@ export async function ensureClaudeAuth(config = {}, options = {}) {
|
|
|
82
51
|
process.exit(0);
|
|
83
52
|
throw error;
|
|
84
53
|
}
|
|
85
|
-
console.log(ui.heading(`\n${texts.
|
|
54
|
+
console.log(ui.heading(`\n${texts.signingInHeading}`));
|
|
86
55
|
console.log(ui.dim(`${texts.browserWillOpen}\n`));
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
56
|
+
await runLogin(executable);
|
|
57
|
+
if (!(await claudeSignedIn())) {
|
|
58
|
+
console.log(ui.error(`\n${texts.notCompleted}`));
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
console.log(ui.success(`\n${texts.signedIn}\n`));
|
|
91
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@falkenslab/agent-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Library for building an agent on top of the Claude Agent SDK",
|
|
5
5
|
"author": "Francisco Vargas Ruiz",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,6 +30,17 @@
|
|
|
30
30
|
},
|
|
31
31
|
"main": "./dist/index.js",
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"default": "./dist/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./mcp": {
|
|
39
|
+
"types": "./dist/mcp/index.d.ts",
|
|
40
|
+
"default": "./dist/mcp/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
33
44
|
"files": [
|
|
34
45
|
"dist",
|
|
35
46
|
"assets",
|
|
@@ -52,6 +63,7 @@
|
|
|
52
63
|
"@anthropic-ai/claude-agent-sdk": "^0.3.300",
|
|
53
64
|
"@inkjs/ui": "^2.0.0",
|
|
54
65
|
"@inquirer/prompts": "^8.5.2",
|
|
66
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
55
67
|
"@types/react": "^19.3.0",
|
|
56
68
|
"ink": "^6.8.0",
|
|
57
69
|
"isomorphic-git": "^1.44.5",
|