@crowdstrike/aidr

中文文档
1.5.0发布于 2026/11/04MITTypeScriptESM + CJS构建来源已验证近 30 天下载 7656

用于 CrowdStrike AIDR 的脚本 SDK 类型

中文使用文档
文档目录9 节
  1. 安装
  2. 使用量
  3. 检索
  4. 超时
  5. 获取选项
  6. 配置代理人
  7. 节点.js
  8. 阿宝
  9. 德诺

人群攻击 AIDR 类型脚本 SDK

用于CrowdStrike AIDR的TypeScript SDK.

安装

npm install @crowdstrike/aidr
pnpm add @crowdstrike/aidr
yarn add @crowdstrike/aidr

使用量

import { AIGuard } from "@crowdstrike/aidr";

const client = new AIGuard({
  token: "your-api-token",
  baseURLTemplate: "https://api.crowdstrike.com/aidr/{SERVICE_NAME}",
});

const response = await client.guardChatCompletions({
  guard_input: {
    messages: [
      {
        role: "user",
        content: "Hello, how can I help you?",
      },
    ],
  },
});

console.log(response);

检索

SDK 支持针对临时故障的自动重试(网络出错或 HTTP/5XX 服务器错误. 它支持在客户端层面配置再试或 按要求计算.

// Set the default number of retries when creating the client.
const client = new AIGuard({
  token: "your-api-token",
  baseURLTemplate: "https://api.crowdstrike.com/aidr/{SERVICE_NAME}",
  maxRetries: 3, // Default is 2.
});

const response = await client.guardChatCompletions(
  {
    guard_input: {
      messages: [{ role: "user", content: "Hello" }],
    },
  },
  {
    // Override the default retry count for this specific request.
    maxRetries: 5,
  }
);

超时

配置请求超时以控制客户端等待响应的时间 时间不早了.

// Set the default timeout (in milliseconds) when creating the client.
const client = new AIGuard({
  token: "your-api-token",
  baseURLTemplate: "https://api.crowdstrike.com/{SERVICE_NAME}",
  timeout: 30000, // 30 seconds (default is 60 seconds).
});

const response = await client.guardChatCompletions(
  {
    guard_input: {
      messages: [{ role: "user", content: "Hello" }],
    },
  },
  {
    // Override the default timeout for a specific request.
    timeout: 10000, // 10 seconds.
  }
);

获取选项

如果你想设置自定义 fetch 选项,而不压倒 fetch 函数,您可以提供 fetchOptions 客户端瞬时对象 或提出要求。 请求特定选项覆盖客户端选项 .

const client = new AIGuard({
  fetchOptions: {
    // `RequestInit` options.
  },
});

配置代理人

要修改代理行为, 您可以提供自定义 fetchOptions 添加 请求的运行时间特定代理选项 :

节点.js

import * as undici from 'undici';

const proxyAgent = new undici.ProxyAgent('http://localhost:8888');
const client = new AIGuard({
  fetchOptions: {
    dispatcher: proxyAgent,
  },
});

阿宝

const client = new AIGuard({
  fetchOptions: {
    proxy: 'http://localhost:8888',
  },
});

德诺

const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });
const client = new AIGuard({
  fetchOptions: {
    client: httpClient,
  },
});

版本与发布记录

@crowdstrike/aidr 共发布 9 个版本,首次发布于 2025/12/14;过去 12 个月发布了 9 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.5.0latest2026/11/047 天前
1.4.02026/10/2813 天前
1.3.02026/08/212 个月前
1.2.22026/06/114 个月前
1.2.12026/05/235 个月前
1.2.02026/05/066 个月前

关于 @crowdstrike/aidr 的常见问题

@crowdstrike/aidr 是什么?

用于 CrowdStrike AIDR 的脚本 SDK 类型

如何安装 @crowdstrike/aidr?

在项目目录运行 npm install @crowdstrike/aidr,或使用 pnpm add / yarn add / bun add。

@crowdstrike/aidr 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@crowdstrike/aidr 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@crowdstrike/aidr 可以商用吗?

@crowdstrike/aidr 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@crowdstrike/aidr 的下载量有多少?

根据 npm 官方下载统计,@crowdstrike/aidr 在 2026/10/11 – 2026/11/09 这 30 天内被下载 7,656 次,日均约 255 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@crowdstrike/aidr 还在维护吗?

最新版本 1.5.0 发布于 2026/11/04(7 天前);至今共发布 9 个版本,其中过去 12 个月发布了 9 个;首次发布于 2025/12/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。