Socket
Book a DemoInstallSign in
Socket

@astii/monaco-chat

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@astii/monaco-chat

monaco-editor inline chat

0.0.6
latest
npmnpm
Version published
Weekly downloads
12
500%
Maintainers
1
Weekly downloads
 
Created
Source

@astii/monaco-chat

NPM version NPM downloads

inline AI chat tool for monaco-editor. with tool can use any model which response based on SSE

shot

Install

$ npm install @astii/monaco-chat

Usage

import { registerChat } from "@astii/monaco-chat";

useEffect(() => {
  if (!monaco || !editor) return;
  const dispose = registerChat(monaco, editor, {
    language: "typescript",
    request: new Request("", {
      method: "POST",
      headers: {
        "x-dmo-provider": "",
        authorization: "Bearer ",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        model: "",
        stream: true,
        temperature: 0.1,
      }),
    }),
    onAgree() {},
    onOppose() {},
  });
  return () => {
    dispose();
  };
}, [monaco, editor]);

with the Request params, developer can request custom model service

Options

NameTypeDefaultRequiredDescription
requestRequest-AI request
tools(keyof typeof TOOL_TYPE)[]-inbuilt tools
actionRecord<string, Action>-actions
durationnumber500msduration of action bar

Types

enum TOOL_TYPE {
  SPEAK = "SPEAK",
  COPY = "COPY",
  AGREE = "AGREE",
  OPPOSE = "OPPOSE",
  REFRESH = "REFRESH",
}

type Action = {
  key?: string;
  title: string;
  prompt: string;
  action?: (params: {
    event: monaco.IMouseEvent;
    target: monaco.editor.IMouseTarget;
    [key: string]: unknown;
  }) => void;
};

const defaultAction = {
  "code-explanation": {
    title: "代码解释",
    prompt: "请解释这段代码",
  },
  "code-optimization": {
    title: "代码优化",
    prompt: "请优化这段代码",
  },
  "code-comment": {
    title: "代码注释",
    prompt: "请给这段代码添加注释",
  },
};

LICENSE

MIT

Keywords

monaco-editor

FAQs

Package last updated on 08 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.