@elsikora/ai-core

中文文档
1.0.0发布于 2026/05/21MITESM + CJS近 30 天下载 6084

Unified AI runtime for ElsiKora modules

原始使用文档
文档目录8 节
  1. What this package provides
  2. Install
  3. Configuration
  4. Runtime generation options
  5. Public adapter API
  6. Profile readiness behavior
  7. Typed profile errors
  8. Validation scripts

@elsikora/ai-core

Unified AI runtime for ElsiKora packages and CLIs.

What this package provides

  • Single adapter for generation across providers.
  • profile mode for module-based runtime configuration.
  • Interactive configuration wizard for first-time setup.
  • Typed profile readiness contract (inspectProfile, ensureProfile).
  • Fail-fast typed errors for missing or invalid profile state.

Install

npm install @elsikora/ai-core

Configuration

Create .elsikora/ai-core.config.js in your project:

export default {
    modules: {
        "your-module-id": {
            model: "gpt-4o",
            provider: "openai",
            reasoning: {
                effort: "medium",
            },
            responseFormat: {
                isStrict: true,
                name: "commit_message",
                schema: {
                    type: "object",
                    properties: {
                        message: { type: "string" },
                    },
                    required: ["message"],
                },
                type: "json_schema",
            },
            retries: 3,
            shouldRepromptCredentialOnAuthenticationFailure: true,
            shouldUseParallelToolCalls: true,
            validationRetries: 3,
        },
    },
};

Credentials are resolved from environment variables by provider (for example OPENAI_API_KEY).

Runtime generation options

Profiles and direct generation requests accept provider-neutral controls such as maxTokens, temperature, topP, topK, seed, stopSequences, timeoutMs, reasoning, responseFormat, tools, toolChoice, shouldUseParallelToolCalls, and shouldRepromptCredentialOnAuthenticationFailure.

Set shouldRepromptCredentialOnAuthenticationFailure: true when an interactive CLI should ask for a replacement credential if the current runtime credential, including one resolved from the environment, is rejected by the provider.

Provider-specific options live under providerOptions and are mapped only inside infrastructure adapters. Examples include OpenAI apiMode, serviceTier, textVerbosity, and shouldStore; Anthropic speed, serviceTier, and thinking; Google thinkingConfig; AWS Bedrock guardrail and performance options; Cerebras reasoning/logprob options; Ollama reasoning controls; and Vercel AI Gateway provider options.

Public adapter API

import { AiCoreAdapter, EGenerateMode } from "@elsikora/ai-core";

const adapter = AiCoreAdapter.create();

const inspection = await adapter.inspectProfile("your-module-id");
const profile = await adapter.ensureProfile("your-module-id");

const result = await adapter.generate({
    mode: EGenerateMode.PROFILE,
    moduleId: "your-module-id",
    prompt: "Generate a concise commit message",
});

Profile readiness behavior

  • inspectProfile(moduleId) never prompts and returns a typed status:
    • ready
    • missing_profile
    • missing_credential
    • invalid_profile
  • ensureProfile(moduleId) applies canonical orchestration:
    • missing profile + TTY -> run full interactive configure
    • missing credential + TTY -> prompt credential only
    • non-TTY missing state -> throw typed ProfileResolutionError

Typed profile errors

ProfileResolutionError exposes:

  • code: missing_profile | missing_credential | invalid_profile
  • moduleId
  • provider (when known)
  • environmentVariableName (when known)

Validation scripts

  • npm run validate:fast
  • npm run validate:pr
  • npm run validate:heavy

版本与发布记录

@elsikora/ai-core 共发布 2 个版本,首次发布于 2026/05/21;过去 12 个月发布了 2 个版本。

版本发布日期距今
1.0.0latest2026/05/215 个月前
1.0.0-dev.1beta2026/05/215 个月前

关于 @elsikora/ai-core 的常见问题

@elsikora/ai-core 是什么?

Unified AI runtime for ElsiKora modules

如何安装 @elsikora/ai-core?

在项目目录运行 npm install @elsikora/ai-core,或使用 pnpm add / yarn add / bun add。

@elsikora/ai-core 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/elsikora__ai-core 是否存在。

@elsikora/ai-core 支持 ESM 还是 CommonJS?

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

@elsikora/ai-core 可以商用吗?

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

@elsikora/ai-core 的下载量有多少?

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

@elsikora/ai-core 还在维护吗?

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