@aifight/aifight 0.1.0-alpha.7 → 0.1.0-alpha.8
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 +51 -0
- package/dist/bin.mjs +171 -137
- package/dist/index.mjs +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/types/agents/agent.d.ts +0 -82
- package/dist/types/agents/state-machine.d.ts +0 -96
- package/dist/types/bridge/auto-update.d.ts +0 -53
- package/dist/types/bridge/config.d.ts +0 -35
- package/dist/types/bridge/hermes-provider.d.ts +0 -9
- package/dist/types/bridge/openclaw-provider.d.ts +0 -9
- package/dist/types/bridge/pairing.d.ts +0 -18
- package/dist/types/bridge/provider.d.ts +0 -18
- package/dist/types/bridge/runner.d.ts +0 -30
- package/dist/types/bridge/service.d.ts +0 -55
- package/dist/types/bridge/update-check.d.ts +0 -23
- package/dist/types/cli/agent-resolver.d.ts +0 -25
- package/dist/types/cli/argv.d.ts +0 -13
- package/dist/types/cli/commands/agent-list.d.ts +0 -2
- package/dist/types/cli/commands/agent-status.d.ts +0 -2
- package/dist/types/cli/commands/bridge-accept.d.ts +0 -2
- package/dist/types/cli/commands/bridge-challenge.d.ts +0 -2
- package/dist/types/cli/commands/bridge-connect.d.ts +0 -2
- package/dist/types/cli/commands/bridge-register.d.ts +0 -7
- package/dist/types/cli/commands/bridge-run.d.ts +0 -7
- package/dist/types/cli/commands/bridge-service.d.ts +0 -5
- package/dist/types/cli/commands/bridge-set.d.ts +0 -2
- package/dist/types/cli/commands/bridge-start.d.ts +0 -2
- package/dist/types/cli/commands/bridge-status.d.ts +0 -2
- package/dist/types/cli/commands/bridge-uninstall.d.ts +0 -4
- package/dist/types/cli/commands/bridge-update.d.ts +0 -2
- package/dist/types/cli/commands/config-init.d.ts +0 -2
- package/dist/types/cli/commands/config-probe.d.ts +0 -2
- package/dist/types/cli/commands/config-validate.d.ts +0 -2
- package/dist/types/cli/commands/daily-off.d.ts +0 -2
- package/dist/types/cli/commands/daily-on.d.ts +0 -2
- package/dist/types/cli/commands/daily-set.d.ts +0 -2
- package/dist/types/cli/commands/daily-show.d.ts +0 -2
- package/dist/types/cli/commands/doctor.d.ts +0 -2
- package/dist/types/cli/commands/init.d.ts +0 -2
- package/dist/types/cli/commands/join.d.ts +0 -2
- package/dist/types/cli/commands/leave.d.ts +0 -2
- package/dist/types/cli/commands/mcp.d.ts +0 -2
- package/dist/types/cli/commands/runtime-management.d.ts +0 -18
- package/dist/types/cli/commands/runtime-setup-state.d.ts +0 -21
- package/dist/types/cli/commands/runtime-setup.d.ts +0 -25
- package/dist/types/cli/commands/serve.d.ts +0 -2
- package/dist/types/cli/commands/service/launchd.d.ts +0 -71
- package/dist/types/cli/commands/service/platform.d.ts +0 -69
- package/dist/types/cli/commands/service/systemd.d.ts +0 -55
- package/dist/types/cli/commands/service/types.d.ts +0 -64
- package/dist/types/cli/commands/service-install.d.ts +0 -29
- package/dist/types/cli/commands/setup.d.ts +0 -2
- package/dist/types/cli/commands/shutdown.d.ts +0 -2
- package/dist/types/cli/commands/stubs.d.ts +0 -24
- package/dist/types/cli/commands/version.d.ts +0 -2
- package/dist/types/cli/control-client.d.ts +0 -59
- package/dist/types/cli/format.d.ts +0 -52
- package/dist/types/cli/main.d.ts +0 -18
- package/dist/types/cli/runtime-files.d.ts +0 -11
- package/dist/types/cli/shared.d.ts +0 -74
- package/dist/types/controlapi/profile-routes.d.ts +0 -49
- package/dist/types/controlapi/server.d.ts +0 -3
- package/dist/types/controlapi/types.d.ts +0 -136
- package/dist/types/daemon/agent-decision-adapter.d.ts +0 -40
- package/dist/types/daemon/lifecycle.d.ts +0 -85
- package/dist/types/daemon/router.d.ts +0 -97
- package/dist/types/daemon/runtime-files-write.d.ts +0 -76
- package/dist/types/identity/identity-manager.d.ts +0 -59
- package/dist/types/llm/adapter-registry.d.ts +0 -27
- package/dist/types/llm/adapters/anthropic-messages.d.ts +0 -2
- package/dist/types/llm/adapters/deepseek-chat-completions.d.ts +0 -2
- package/dist/types/llm/adapters/openai-chat-compat.d.ts +0 -2
- package/dist/types/llm/adapters/openai-chat-completions.d.ts +0 -2
- package/dist/types/llm/adapters/openai-responses.d.ts +0 -2
- package/dist/types/llm/adapters/types.d.ts +0 -128
- package/dist/types/llm/capabilities/validate-capabilities.d.ts +0 -68
- package/dist/types/mcp/control-client.d.ts +0 -54
- package/dist/types/mcp/profile-tools.d.ts +0 -10
- package/dist/types/mcp/server.d.ts +0 -10
- package/dist/types/mcp/tools.d.ts +0 -31
- package/dist/types/mcp/types.d.ts +0 -27
- package/dist/types/profile/config-schema.d.ts +0 -199
- package/dist/types/profile/identity-schema.d.ts +0 -75
- package/dist/types/profile/index.d.ts +0 -7
- package/dist/types/profile/migrate.d.ts +0 -16
- package/dist/types/profile/profile-loader.d.ts +0 -64
- package/dist/types/profile/secret-ref.d.ts +0 -82
- package/dist/types/profile/soul.d.ts +0 -46
- package/dist/types/profile/strategy-schema.d.ts +0 -70
- package/dist/types/reflection/proposal-store.d.ts +0 -50
- package/dist/types/reflection/reflection-engine.d.ts +0 -81
- package/dist/types/scheduler/daily.d.ts +0 -47
- package/dist/types/scheduler/types.d.ts +0 -42
- package/dist/types/session/match-session-manager.d.ts +0 -113
- package/dist/types/session/session-context-builder.d.ts +0 -68
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
export type ReasoningEffort = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto";
|
|
2
|
-
export interface CanonicalReasoningConfig {
|
|
3
|
-
readonly enabled?: boolean | "auto";
|
|
4
|
-
readonly mode?: "disabled" | "enabled" | "adaptive" | "auto";
|
|
5
|
-
readonly effort?: ReasoningEffort;
|
|
6
|
-
readonly budgetTokens?: number | null;
|
|
7
|
-
readonly taskBudgetTokens?: number | null;
|
|
8
|
-
readonly thinkingLevel?: "minimal" | "low" | "medium" | "high" | null;
|
|
9
|
-
readonly thinkingBudget?: number | null;
|
|
10
|
-
readonly display?: "omitted" | "summarized" | null;
|
|
11
|
-
readonly summary?: "off" | "auto" | "concise" | "detailed" | null;
|
|
12
|
-
readonly includeEncryptedReasoning?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare const SUPPORTED_PROTOCOLS: readonly ["anthropic_messages", "openai_responses", "openai_chat_completions", "openai_chat_compat", "deepseek_chat_completions", "gemini_generate_content", "gemini_openai_compat"];
|
|
15
|
-
export type LLMProtocol = (typeof SUPPORTED_PROTOCOLS)[number];
|
|
16
|
-
export interface DecisionInput {
|
|
17
|
-
/** System prompt assembled from soul + strategy + rules + context */
|
|
18
|
-
readonly systemPrompt: string;
|
|
19
|
-
/** User prompt with current state + legal actions + output contract */
|
|
20
|
-
readonly userPrompt: string;
|
|
21
|
-
/** Max output tokens for this decision */
|
|
22
|
-
readonly maxTokens: number;
|
|
23
|
-
/** Temperature (null = provider default) */
|
|
24
|
-
readonly temperature: number | null;
|
|
25
|
-
/** Canonical reasoning config (adapter translates to provider format) */
|
|
26
|
-
readonly reasoning?: CanonicalReasoningConfig;
|
|
27
|
-
/** Response format hint */
|
|
28
|
-
readonly responseFormat?: "json" | "json_object" | "json_schema" | "text";
|
|
29
|
-
/** Abort signal for timeout */
|
|
30
|
-
readonly signal?: AbortSignal;
|
|
31
|
-
}
|
|
32
|
-
export interface DecisionOutput {
|
|
33
|
-
/** Raw text response from the model */
|
|
34
|
-
readonly text: string;
|
|
35
|
-
/** Input tokens used */
|
|
36
|
-
readonly inputTokens?: number;
|
|
37
|
-
/** Output tokens used (includes reasoning tokens for some providers) */
|
|
38
|
-
readonly outputTokens?: number;
|
|
39
|
-
/** Reasoning/thinking tokens (if separately reported) */
|
|
40
|
-
readonly reasoningTokens?: number;
|
|
41
|
-
/** Cached tokens (if provider reports) */
|
|
42
|
-
readonly cachedTokens?: number;
|
|
43
|
-
/** Response latency in ms */
|
|
44
|
-
readonly latencyMs: number;
|
|
45
|
-
/** Short reasoning summary if provider supports it */
|
|
46
|
-
readonly reasoningSummary?: string;
|
|
47
|
-
/** Raw provider response (for debugging, usually redacted before storage) */
|
|
48
|
-
readonly raw?: unknown;
|
|
49
|
-
/** Provider-specific continuation state to preserve within this match session */
|
|
50
|
-
readonly continuationState?: unknown;
|
|
51
|
-
}
|
|
52
|
-
export interface UsageRecord {
|
|
53
|
-
readonly protocol: string;
|
|
54
|
-
readonly providerLabel: string;
|
|
55
|
-
readonly model: string;
|
|
56
|
-
readonly inputTokens?: number;
|
|
57
|
-
readonly outputTokens?: number;
|
|
58
|
-
readonly reasoningTokens?: number;
|
|
59
|
-
readonly cachedTokens?: number;
|
|
60
|
-
readonly estimatedCostUSD?: number;
|
|
61
|
-
readonly latencyMs: number;
|
|
62
|
-
readonly timestamp: string;
|
|
63
|
-
}
|
|
64
|
-
export interface ProbeResult {
|
|
65
|
-
readonly success: boolean;
|
|
66
|
-
readonly latencyMs: number;
|
|
67
|
-
readonly error?: string;
|
|
68
|
-
readonly model: string;
|
|
69
|
-
readonly protocol: string;
|
|
70
|
-
/** Whether the model returned valid JSON when asked */
|
|
71
|
-
readonly jsonValid?: boolean;
|
|
72
|
-
}
|
|
73
|
-
export interface ValidationResult {
|
|
74
|
-
readonly ok: boolean;
|
|
75
|
-
readonly errors: string[];
|
|
76
|
-
readonly warnings: string[];
|
|
77
|
-
}
|
|
78
|
-
export interface LLMProfile {
|
|
79
|
-
readonly profileId: string;
|
|
80
|
-
readonly displayName: string;
|
|
81
|
-
readonly protocol: LLMProtocol;
|
|
82
|
-
readonly baseURL: string;
|
|
83
|
-
readonly model: string;
|
|
84
|
-
readonly apiKey: string;
|
|
85
|
-
readonly temperature: number | null;
|
|
86
|
-
readonly maxTokens: number;
|
|
87
|
-
readonly responseFormat?: string;
|
|
88
|
-
readonly reasoning?: CanonicalReasoningConfig;
|
|
89
|
-
readonly timeouts: {
|
|
90
|
-
readonly requestMs: number;
|
|
91
|
-
readonly connectMs: number;
|
|
92
|
-
};
|
|
93
|
-
readonly retries: {
|
|
94
|
-
readonly maxAttempts: number;
|
|
95
|
-
readonly backoffMs: number;
|
|
96
|
-
};
|
|
97
|
-
readonly budgets?: {
|
|
98
|
-
readonly maxCostUSDPerMatch?: number;
|
|
99
|
-
readonly maxCostUSDPerDay?: number;
|
|
100
|
-
readonly maxOutputTokensPerDecision?: number;
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
export interface LLMAdapter {
|
|
104
|
-
/** Protocol this adapter handles */
|
|
105
|
-
readonly protocol: LLMProtocol;
|
|
106
|
-
/** Validate a profile against this adapter's capabilities */
|
|
107
|
-
validateProfile(profile: LLMProfile): ValidationResult;
|
|
108
|
-
/** Make a probe/test call to verify connectivity and JSON response */
|
|
109
|
-
probe(profile: LLMProfile): Promise<ProbeResult>;
|
|
110
|
-
/** Build and send a decision request, return parsed output */
|
|
111
|
-
generateDecision(input: DecisionInput, profile: LLMProfile, continuationState?: unknown): Promise<DecisionOutput>;
|
|
112
|
-
/** Estimate cost from a completed response */
|
|
113
|
-
estimateUsage(output: DecisionOutput, profile: LLMProfile): UsageRecord;
|
|
114
|
-
/** Redact sensitive data from raw provider response */
|
|
115
|
-
redact(raw: unknown): unknown;
|
|
116
|
-
}
|
|
117
|
-
export type AdapterErrorKind = "auth_failed" | "rate_limited" | "model_not_found" | "invalid_request" | "server_error" | "timeout" | "network" | "aborted" | "invalid_response" | "unsupported" | "budget_exceeded" | "unknown";
|
|
118
|
-
export declare class AdapterError extends Error {
|
|
119
|
-
readonly name = "AdapterError";
|
|
120
|
-
readonly kind: AdapterErrorKind;
|
|
121
|
-
readonly protocol: string;
|
|
122
|
-
readonly retryable: boolean;
|
|
123
|
-
readonly cause: unknown;
|
|
124
|
-
constructor(kind: AdapterErrorKind, protocol: string, message: string, opts?: {
|
|
125
|
-
retryable?: boolean;
|
|
126
|
-
cause?: unknown;
|
|
127
|
-
});
|
|
128
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
export interface ModelCapability {
|
|
2
|
-
/** Regex pattern matched against the model string (e.g. "^claude-opus-4-7"). */
|
|
3
|
-
pattern: string;
|
|
4
|
-
/** Thinking modes the model accepts, e.g. ["adaptive"]. */
|
|
5
|
-
thinkingModes?: string[];
|
|
6
|
-
/** Effort levels accepted by this specific model (subset of protocol effortValues). */
|
|
7
|
-
efforts?: string[];
|
|
8
|
-
/** Per-model default effort override (falls back to protocol defaultEffort). */
|
|
9
|
-
defaultEffort?: string;
|
|
10
|
-
/** True if the model accepts a manual budget_tokens parameter. */
|
|
11
|
-
supportsManualBudget?: boolean;
|
|
12
|
-
/** False if the model ignores temperature even when the protocol supports it. */
|
|
13
|
-
supportsTemperature?: boolean;
|
|
14
|
-
/** True if temperature/top_p are silently ignored in thinking mode. */
|
|
15
|
-
samplingIgnoredWhenThinking?: boolean;
|
|
16
|
-
/** Maximum output tokens the model can produce. */
|
|
17
|
-
maxOutputTokens: number;
|
|
18
|
-
/** Protocol-specific thinking API parameter name, e.g. "thinkingLevel" | "thinkingBudget". */
|
|
19
|
-
thinkingParam?: string;
|
|
20
|
-
/** Free-text notes for operators. Not used in validation logic. */
|
|
21
|
-
notes?: string;
|
|
22
|
-
}
|
|
23
|
-
export interface ProtocolCapability {
|
|
24
|
-
displayName: string;
|
|
25
|
-
defaultBaseURL: string;
|
|
26
|
-
supportsBaseURL: boolean;
|
|
27
|
-
/** true | false | "ignored_when_thinking" */
|
|
28
|
-
supportsTemperature: boolean | string;
|
|
29
|
-
supportsJSONMode: boolean;
|
|
30
|
-
supportsThinking: boolean;
|
|
31
|
-
supportsReasoningSummary: boolean;
|
|
32
|
-
/** Request parameter name for the token limit, e.g. "max_tokens". */
|
|
33
|
-
maxTokensParam: string;
|
|
34
|
-
/** All effort levels the protocol understands. */
|
|
35
|
-
effortValues: string[];
|
|
36
|
-
defaultEffort?: string;
|
|
37
|
-
/** Optional effort remapping for protocols with a restricted effort vocabulary. */
|
|
38
|
-
compatEffortMap?: Record<string, string>;
|
|
39
|
-
models: ModelCapability[];
|
|
40
|
-
notes?: string;
|
|
41
|
-
}
|
|
42
|
-
export interface CapabilityRegistry {
|
|
43
|
-
schemaVersion: number;
|
|
44
|
-
protocols: Record<string, ProtocolCapability>;
|
|
45
|
-
}
|
|
46
|
-
export interface ThinkingConfig {
|
|
47
|
-
/** "adaptive" | "enabled" | "disabled" or protocol-specific value */
|
|
48
|
-
mode?: string;
|
|
49
|
-
/** Explicit budget_tokens (only for protocols/models that support manual budget). */
|
|
50
|
-
budgetTokens?: number;
|
|
51
|
-
/** "low" | "medium" | "high" | "xhigh" | "max" | "none" | "minimal" */
|
|
52
|
-
effort?: string;
|
|
53
|
-
}
|
|
54
|
-
export declare function loadCapabilityRegistry(): CapabilityRegistry;
|
|
55
|
-
export declare function validateProfileAgainstCapabilities(protocol: string, model: string, thinking: ThinkingConfig | undefined, registry: CapabilityRegistry): {
|
|
56
|
-
ok: true;
|
|
57
|
-
} | {
|
|
58
|
-
ok: false;
|
|
59
|
-
errors: string[];
|
|
60
|
-
warnings: string[];
|
|
61
|
-
};
|
|
62
|
-
export declare function getDefaultBaseURL(protocol: string, registry: CapabilityRegistry): string | undefined;
|
|
63
|
-
export declare function mapEffortForProtocol(effort: string, protocol: string, registry: CapabilityRegistry): {
|
|
64
|
-
mapped: string;
|
|
65
|
-
warning?: string;
|
|
66
|
-
} | {
|
|
67
|
-
error: string;
|
|
68
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export interface ControlClientPaths {
|
|
2
|
-
tokenPath: string;
|
|
3
|
-
portPath: string;
|
|
4
|
-
}
|
|
5
|
-
export interface ControlCredentials {
|
|
6
|
-
token: string;
|
|
7
|
-
port: number;
|
|
8
|
-
}
|
|
9
|
-
export interface RequestOptions {
|
|
10
|
-
method?: "GET" | "POST" | "DELETE" | "PUT" | "PATCH";
|
|
11
|
-
body?: unknown;
|
|
12
|
-
signal?: AbortSignal;
|
|
13
|
-
}
|
|
14
|
-
export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
15
|
-
export interface ControlClientOptions {
|
|
16
|
-
paths?: ControlClientPaths;
|
|
17
|
-
fetch?: FetchLike;
|
|
18
|
-
/**
|
|
19
|
-
* Per-request timeout (covers fetch headers + body read). Default
|
|
20
|
-
* 10000ms — same baseline as the M1 CLI control-client. Tests inject
|
|
21
|
-
* a small value (e.g. 50ms) to assert the timeout path without
|
|
22
|
-
* waiting in real time.
|
|
23
|
-
*/
|
|
24
|
-
baseTimeoutMs?: number;
|
|
25
|
-
}
|
|
26
|
-
export interface ControlClient {
|
|
27
|
-
request<T = unknown>(path: string, opts?: RequestOptions): Promise<T>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Discriminated kind for RuntimeUnavailableError. Used by mcp/tools.ts
|
|
31
|
-
* to emit a whitelist user-facing message that does NOT echo the raw
|
|
32
|
-
* fetch error / URL / port — those would leak via MCP `text` content
|
|
33
|
-
* which the host typically records and uploads to telemetry.
|
|
34
|
-
*/
|
|
35
|
-
export type RuntimeUnavailableKind = "unreachable" | "timeout" | "unauthorized" | "files_corrupt" | "other";
|
|
36
|
-
export declare class RuntimeUnavailableError extends Error {
|
|
37
|
-
readonly name = "RuntimeUnavailableError";
|
|
38
|
-
readonly kind: RuntimeUnavailableKind;
|
|
39
|
-
readonly attempts: number;
|
|
40
|
-
constructor(kind: RuntimeUnavailableKind, message: string, attempts: number, options?: ErrorOptions);
|
|
41
|
-
}
|
|
42
|
-
export declare function getDefaultControlClientPaths(homedir?: string): ControlClientPaths;
|
|
43
|
-
/**
|
|
44
|
-
* Non-retryable HTTP error from the controlapi (4xx/5xx other than 401).
|
|
45
|
-
* Tool handlers turn this into a structured `{isError:true}` MCP
|
|
46
|
-
* result so the client sees a tool-level error.
|
|
47
|
-
*/
|
|
48
|
-
export declare class ControlHttpError extends Error {
|
|
49
|
-
readonly name = "ControlHttpError";
|
|
50
|
-
readonly status: number;
|
|
51
|
-
readonly bodyText: string;
|
|
52
|
-
constructor(status: number, bodyText: string);
|
|
53
|
-
}
|
|
54
|
-
export declare function createControlClient(opts?: ControlClientOptions): ControlClient;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type ControlClient } from "./control-client.js";
|
|
2
|
-
import type { McpTool, McpToolResult } from "./tools.js";
|
|
3
|
-
export declare const PROFILE_TOOLS: readonly McpTool[];
|
|
4
|
-
export declare const PROFILE_TOOL_NAMES: string[];
|
|
5
|
-
/**
|
|
6
|
-
* Dispatch a profile tool call by name.
|
|
7
|
-
* Returns a structured McpToolResult — never throws.
|
|
8
|
-
* Call this from mcp/server.ts CallTool handler after checking MCP_TOOL_NAMES.
|
|
9
|
-
*/
|
|
10
|
-
export declare function handleProfileTool(client: ControlClient, name: string, args: Record<string, unknown>): Promise<McpToolResult>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
-
import { type McpServerOptions } from "./types.js";
|
|
3
|
-
export declare function createMcpServer(opts?: McpServerOptions): Server;
|
|
4
|
-
/**
|
|
5
|
-
* Spawn the MCP server bound to the process's stdio. Returns the
|
|
6
|
-
* connected server instance — the caller is expected to keep the
|
|
7
|
-
* process alive (the SDK handles JSON-RPC dispatch via its own event
|
|
8
|
-
* loop). Caller may call `server.close()` for graceful shutdown.
|
|
9
|
-
*/
|
|
10
|
-
export declare function runMcpServer(opts?: McpServerOptions): Promise<Server>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type ControlClient } from "./control-client.js";
|
|
2
|
-
export interface McpToolResult {
|
|
3
|
-
content: Array<{
|
|
4
|
-
type: "text";
|
|
5
|
-
text: string;
|
|
6
|
-
}>;
|
|
7
|
-
isError?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface McpTool {
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly description: string;
|
|
12
|
-
readonly inputSchema: Record<string, unknown>;
|
|
13
|
-
readonly handler: (client: ControlClient, args: Record<string, unknown>) => Promise<McpToolResult>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* M5-13 B7 — `ping` is intercepted by mcp/server.ts BEFORE registry
|
|
17
|
-
* dispatch, because the response includes daemon-independent uptime_ms
|
|
18
|
-
* which only the server-construction path knows. The metadata is
|
|
19
|
-
* exported separately (not in MCP_TOOLS) so ListTools can still
|
|
20
|
-
* advertise it without keeping a dead handler stub in the registry.
|
|
21
|
-
*
|
|
22
|
-
* Sealed contract: ListTools must return ping FIRST in the tool list;
|
|
23
|
-
* see runtime/tests/mcp-tools.test.ts:87 for the order assertion.
|
|
24
|
-
*/
|
|
25
|
-
export declare const PING_METADATA: {
|
|
26
|
-
name: "ping";
|
|
27
|
-
description: string;
|
|
28
|
-
inputSchema: Record<string, unknown>;
|
|
29
|
-
};
|
|
30
|
-
export declare const MCP_TOOLS: readonly McpTool[];
|
|
31
|
-
export declare const MCP_TOOL_NAMES: string[];
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { ControlClient } from "./control-client.js";
|
|
2
|
-
export declare const MCP_SERVER_NAME = "aifight";
|
|
3
|
-
/**
|
|
4
|
-
* Re-export of the canonical tool-name list. Sourced from tools.ts so
|
|
5
|
-
* the MCP_TOOL_NAMES constant stays in lockstep with MCP_TOOLS itself.
|
|
6
|
-
* (M3-01 had this constant local; M3-02 promotes it to tools.ts because
|
|
7
|
-
* the tool definitions are now the source of truth.)
|
|
8
|
-
*/
|
|
9
|
-
export { MCP_TOOL_NAMES } from "./tools.js";
|
|
10
|
-
export interface McpServerOptions {
|
|
11
|
-
/** Override the server name (default "aifight"). */
|
|
12
|
-
serverName?: string;
|
|
13
|
-
/** Server version reported on initialize handshake. */
|
|
14
|
-
version?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Used by `ping` to compute uptime_ms. Defaults to `Date.now()`
|
|
17
|
-
* at construction time. Tests inject a fixed value so the uptime
|
|
18
|
-
* assertion is deterministic.
|
|
19
|
-
*/
|
|
20
|
-
startedAtMs?: number;
|
|
21
|
-
/**
|
|
22
|
-
* (M3-02) HTTP client to the local controlapi. When omitted,
|
|
23
|
-
* controlapi-bound tools (everything except `ping`) return
|
|
24
|
-
* isError:true with a message telling the user to start the daemon.
|
|
25
|
-
*/
|
|
26
|
-
controlClient?: ControlClient;
|
|
27
|
-
}
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* config-schema.ts
|
|
3
|
-
*
|
|
4
|
-
* TypeScript interfaces, types, and validator for the AIFight daemon's
|
|
5
|
-
* config.json file. Covers LLM provider configuration ONLY — no game
|
|
6
|
-
* strategy, no personality settings.
|
|
7
|
-
*
|
|
8
|
-
* Design principles:
|
|
9
|
-
* - Protocol-first (not vendor-first): the same model can be reached via
|
|
10
|
-
* multiple protocols; the protocol field dictates wire format.
|
|
11
|
-
* - SecretRef indirection: API keys are never stored as raw strings.
|
|
12
|
-
* - Normalized reasoning/thinking config that maps onto every provider.
|
|
13
|
-
* - Per-game routing with a fallback profile.
|
|
14
|
-
* - No runtime dependencies beyond Node built-ins.
|
|
15
|
-
*/
|
|
16
|
-
/** Wire-level protocol used to call the LLM provider. */
|
|
17
|
-
export type Protocol = "anthropic_messages" | "openai_responses" | "openai_chat_completions" | "openai_chat_compat" | "deepseek_chat_completions" | "gemini_generate_content" | "gemini_openai_compat";
|
|
18
|
-
/** Reasoning/thinking effort level. "auto" lets the provider decide. */
|
|
19
|
-
export type ReasoningEffort = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto";
|
|
20
|
-
/** Games supported for per-game routing. */
|
|
21
|
-
export type GameType = "texas_holdem" | "liars_dice" | "coup";
|
|
22
|
-
/** How much of the prompt to persist in logs. */
|
|
23
|
-
export type PromptStoreMode = "full" | "redacted" | "none";
|
|
24
|
-
/** Read the secret from an environment variable. */
|
|
25
|
-
export interface SecretRefEnv {
|
|
26
|
-
type: "env";
|
|
27
|
-
/** Name of the environment variable (e.g. "ANTHROPIC_API_KEY"). */
|
|
28
|
-
name: string;
|
|
29
|
-
}
|
|
30
|
-
/** Read a specific key from a .env-style file. */
|
|
31
|
-
export interface SecretRefEnvFile {
|
|
32
|
-
type: "env_file";
|
|
33
|
-
/** Absolute or relative path to the env file. */
|
|
34
|
-
path: string;
|
|
35
|
-
/** Variable name inside the file. */
|
|
36
|
-
name: string;
|
|
37
|
-
}
|
|
38
|
-
/** Read the entire file content as the secret. */
|
|
39
|
-
export interface SecretRefFile {
|
|
40
|
-
type: "file";
|
|
41
|
-
/** Absolute or relative path to the file. */
|
|
42
|
-
path: string;
|
|
43
|
-
}
|
|
44
|
-
/** Read from the OS keychain (macOS Keychain, Windows Credential Manager, etc.). */
|
|
45
|
-
export interface SecretRefKeychain {
|
|
46
|
-
type: "keychain";
|
|
47
|
-
service: string;
|
|
48
|
-
account: string;
|
|
49
|
-
}
|
|
50
|
-
/** Obtain the secret by running an external command (e.g. `op run`). */
|
|
51
|
-
export interface SecretRefCommand {
|
|
52
|
-
type: "command";
|
|
53
|
-
command: string;
|
|
54
|
-
args?: string[];
|
|
55
|
-
/** Milliseconds to wait for the command to exit. Defaults to 5000. */
|
|
56
|
-
timeoutMs?: number;
|
|
57
|
-
}
|
|
58
|
-
export type SecretRef = SecretRefEnv | SecretRefEnvFile | SecretRefFile | SecretRefKeychain | SecretRefCommand;
|
|
59
|
-
export interface RequestConfig {
|
|
60
|
-
/**
|
|
61
|
-
* Sampling temperature. null means "use the provider default" (useful when
|
|
62
|
-
* thinking/extended-thinking is active, since many providers require
|
|
63
|
-
* temperature=1 in that mode).
|
|
64
|
-
*/
|
|
65
|
-
temperature?: number | null;
|
|
66
|
-
/** Maximum output tokens per LLM call. */
|
|
67
|
-
maxTokens?: number;
|
|
68
|
-
/**
|
|
69
|
-
* Response format hint. "json" instructs the provider to return JSON where
|
|
70
|
-
* supported; "text" is plain text.
|
|
71
|
-
*/
|
|
72
|
-
responseFormat?: "json" | "text";
|
|
73
|
-
}
|
|
74
|
-
export interface ThinkingConfig {
|
|
75
|
-
enabled: boolean;
|
|
76
|
-
/**
|
|
77
|
-
* "adaptive" — let the daemon decide per-request based on game complexity.
|
|
78
|
-
* "always" — always activate thinking.
|
|
79
|
-
* "never" — never activate thinking (overrides enabled=true).
|
|
80
|
-
*/
|
|
81
|
-
mode?: "adaptive" | "always" | "never";
|
|
82
|
-
/** Effort level passed to the provider (provider-specific mapping applied). */
|
|
83
|
-
effort?: ReasoningEffort;
|
|
84
|
-
/** Hard cap on reasoning/thinking tokens (provider-specific field name). */
|
|
85
|
-
maxReasoningTokens?: number;
|
|
86
|
-
}
|
|
87
|
-
export interface TimeoutsConfig {
|
|
88
|
-
/** Total request timeout in milliseconds. */
|
|
89
|
-
requestMs?: number;
|
|
90
|
-
/** TCP connection timeout in milliseconds. */
|
|
91
|
-
connectMs?: number;
|
|
92
|
-
}
|
|
93
|
-
export interface RetriesConfig {
|
|
94
|
-
/** Maximum number of attempts (1 = no retry). */
|
|
95
|
-
maxAttempts?: number;
|
|
96
|
-
/** Base back-off in milliseconds (exponential back-off applied). */
|
|
97
|
-
backoffMs?: number;
|
|
98
|
-
}
|
|
99
|
-
export interface BudgetsConfig {
|
|
100
|
-
/** Abort a match if cumulative LLM cost exceeds this (USD). */
|
|
101
|
-
maxCostUSDPerMatch?: number;
|
|
102
|
-
/** Truncate / warn when a single decision consumes more than this many tokens. */
|
|
103
|
-
maxOutputTokensPerDecision?: number;
|
|
104
|
-
}
|
|
105
|
-
export interface LLMProfile {
|
|
106
|
-
/** Human-readable label shown in logs and the CLI. */
|
|
107
|
-
displayName?: string;
|
|
108
|
-
/** Wire protocol used to call this provider. */
|
|
109
|
-
protocol: Protocol;
|
|
110
|
-
/**
|
|
111
|
-
* Provider base URL. Omit to use the protocol's canonical default
|
|
112
|
-
* (e.g. https://api.anthropic.com for anthropic_messages).
|
|
113
|
-
*/
|
|
114
|
-
baseURL?: string;
|
|
115
|
-
/** Indirection to the API key — never a raw string. */
|
|
116
|
-
apiKeyRef: SecretRef;
|
|
117
|
-
/**
|
|
118
|
-
* Model identifier in the provider's namespace
|
|
119
|
-
* (e.g. "claude-opus-4-7", "gpt-4o", "deepseek-chat").
|
|
120
|
-
*/
|
|
121
|
-
model: string;
|
|
122
|
-
/** Sampling and format parameters. */
|
|
123
|
-
request?: RequestConfig;
|
|
124
|
-
/** Extended-thinking / reasoning configuration. */
|
|
125
|
-
thinking?: ThinkingConfig;
|
|
126
|
-
/** Network timeouts. */
|
|
127
|
-
timeouts?: TimeoutsConfig;
|
|
128
|
-
/** Retry policy on transient errors (429, 503, network). */
|
|
129
|
-
retries?: RetriesConfig;
|
|
130
|
-
/** Cost and token budgets that trigger warnings or hard stops. */
|
|
131
|
-
budgets?: BudgetsConfig;
|
|
132
|
-
}
|
|
133
|
-
export interface RoutingConfig {
|
|
134
|
-
/** Profile name used when no per-game route is configured. */
|
|
135
|
-
default: string;
|
|
136
|
-
/** Optional per-game overrides. Keys are GameType values. */
|
|
137
|
-
byGame?: Partial<Record<GameType, string>>;
|
|
138
|
-
/**
|
|
139
|
-
* Profile name to fall back to when the primary profile fails (rate limit,
|
|
140
|
-
* outage, budget exhaustion). Must differ from the profiles it backs up.
|
|
141
|
-
*/
|
|
142
|
-
fallbackProfile?: string;
|
|
143
|
-
}
|
|
144
|
-
export interface LoggingConfig {
|
|
145
|
-
/**
|
|
146
|
-
* "full" — store the full prompt (may contain strategy details).
|
|
147
|
-
* "redacted" — store only metadata + token counts.
|
|
148
|
-
* "none" — do not log prompts.
|
|
149
|
-
*/
|
|
150
|
-
storePrompts?: PromptStoreMode;
|
|
151
|
-
/** Whether to store the raw JSON response from the provider. */
|
|
152
|
-
storeRawProviderResponses?: boolean;
|
|
153
|
-
/** Whether to store the reasoning/thinking content (can be large). */
|
|
154
|
-
storeReasoningContent?: boolean;
|
|
155
|
-
}
|
|
156
|
-
export interface LLMConfig {
|
|
157
|
-
/** Schema version for forward compatibility. Currently must be 1. */
|
|
158
|
-
schemaVersion: 1;
|
|
159
|
-
/** Key into `profiles` that the daemon uses by default. */
|
|
160
|
-
activeProfile: string;
|
|
161
|
-
/** Map of profile name → profile definition. At least one entry required. */
|
|
162
|
-
profiles: Record<string, LLMProfile>;
|
|
163
|
-
/** Game-level routing rules. */
|
|
164
|
-
routing: RoutingConfig;
|
|
165
|
-
/** Logging preferences. */
|
|
166
|
-
logging?: LoggingConfig;
|
|
167
|
-
}
|
|
168
|
-
type ValidationResult = {
|
|
169
|
-
ok: true;
|
|
170
|
-
config: LLMConfig;
|
|
171
|
-
} | {
|
|
172
|
-
ok: false;
|
|
173
|
-
errors: string[];
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* Validate an unknown value (typically from JSON.parse) as an LLMConfig.
|
|
177
|
-
*
|
|
178
|
-
* Returns `{ ok: true, config }` on success, or
|
|
179
|
-
* `{ ok: false, errors }` with a list of human-readable messages on failure.
|
|
180
|
-
*
|
|
181
|
-
* Example:
|
|
182
|
-
* ```ts
|
|
183
|
-
* const raw = JSON.parse(fs.readFileSync("config.json", "utf8"));
|
|
184
|
-
* const result = validateConfig(raw);
|
|
185
|
-
* if (!result.ok) {
|
|
186
|
-
* console.error(result.errors.join("\n"));
|
|
187
|
-
* process.exit(1);
|
|
188
|
-
* }
|
|
189
|
-
* const config = result.config;
|
|
190
|
-
* ```
|
|
191
|
-
*/
|
|
192
|
-
export declare function validateConfig(raw: unknown): ValidationResult;
|
|
193
|
-
/**
|
|
194
|
-
* A minimal valid LLMConfig that uses Claude claude-sonnet-4-6 via the
|
|
195
|
-
* Anthropic Messages API, reading the API key from the ANTHROPIC_API_KEY
|
|
196
|
-
* environment variable. Suitable as a starter template or fallback.
|
|
197
|
-
*/
|
|
198
|
-
export declare const DEFAULT_CONFIG: LLMConfig;
|
|
199
|
-
export {};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
export type SecretRef = {
|
|
2
|
-
type: "env";
|
|
3
|
-
name: string;
|
|
4
|
-
} | {
|
|
5
|
-
type: "env_file";
|
|
6
|
-
path: string;
|
|
7
|
-
name: string;
|
|
8
|
-
} | {
|
|
9
|
-
type: "file";
|
|
10
|
-
path: string;
|
|
11
|
-
} | {
|
|
12
|
-
type: "keychain";
|
|
13
|
-
service: string;
|
|
14
|
-
account: string;
|
|
15
|
-
} | {
|
|
16
|
-
type: "command";
|
|
17
|
-
command: string;
|
|
18
|
-
args?: string[];
|
|
19
|
-
timeoutMs?: number;
|
|
20
|
-
};
|
|
21
|
-
export type PlatformEnvironment = "local" | "beta" | "prod";
|
|
22
|
-
export type HostType = "openclaw" | "hermes" | "claude_desktop" | "qclaw" | "cowork" | "cli" | "other";
|
|
23
|
-
export interface HostInfo {
|
|
24
|
-
/** Which runtime is hosting this daemon. */
|
|
25
|
-
type: HostType;
|
|
26
|
-
/** Human-readable label for display (e.g. "OpenClaw local"). */
|
|
27
|
-
label?: string;
|
|
28
|
-
/** Which plugin or tool created this identity file. */
|
|
29
|
-
createdBy?: string;
|
|
30
|
-
}
|
|
31
|
-
export interface PlatformInfo {
|
|
32
|
-
/** Target AIFight environment. */
|
|
33
|
-
environment: PlatformEnvironment;
|
|
34
|
-
/** Base URL of the AIFight API (e.g. "https://beta.aifight.ai"). */
|
|
35
|
-
baseURL: string;
|
|
36
|
-
/** Owner account ID on the AIFight platform (e.g. "owner_..."). */
|
|
37
|
-
ownerId: string;
|
|
38
|
-
/** Agent ID on the AIFight platform (e.g. "agt_..."). */
|
|
39
|
-
agentId: string;
|
|
40
|
-
/** Public URL slug for this agent (e.g. "roy-openclaw-lobster"). */
|
|
41
|
-
publicSlug: string;
|
|
42
|
-
/** Rating system in use. */
|
|
43
|
-
ratingSystem: "glicko2" | string;
|
|
44
|
-
}
|
|
45
|
-
export interface AuthInfo {
|
|
46
|
-
/** SecretRef pointing to the agent API key. */
|
|
47
|
-
agentApiKeyRef: SecretRef;
|
|
48
|
-
}
|
|
49
|
-
export interface RuntimeMeta {
|
|
50
|
-
/** Schema version for forward-compat checks. Must equal schemaVersion at the top level. */
|
|
51
|
-
profileVersion: number;
|
|
52
|
-
/** ISO 8601 timestamp when this profile was first created. */
|
|
53
|
-
createdAt: string;
|
|
54
|
-
/** ISO 8601 timestamp when this profile was last updated. */
|
|
55
|
-
updatedAt: string;
|
|
56
|
-
}
|
|
57
|
-
export interface AgentIdentity {
|
|
58
|
-
/** Integer schema version — bump when breaking changes are made. */
|
|
59
|
-
schemaVersion: number;
|
|
60
|
-
/** URL-safe slug identifying this agent (e.g. "roy-openclaw-lobster"). */
|
|
61
|
-
agentSlug: string;
|
|
62
|
-
/** Human-readable display name (e.g. "Roy's OpenClaw Lobster"). */
|
|
63
|
-
displayName?: string;
|
|
64
|
-
host: HostInfo;
|
|
65
|
-
platform: PlatformInfo;
|
|
66
|
-
auth: AuthInfo;
|
|
67
|
-
runtime: RuntimeMeta;
|
|
68
|
-
}
|
|
69
|
-
export declare function validateIdentity(raw: unknown): {
|
|
70
|
-
ok: true;
|
|
71
|
-
identity: AgentIdentity;
|
|
72
|
-
} | {
|
|
73
|
-
ok: false;
|
|
74
|
-
errors: string[];
|
|
75
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { type LLMConfig, type LLMProfile as LLMConfigProfile, type Protocol, type ReasoningEffort, type GameType, type SecretRef as ConfigSecretRef, validateConfig, DEFAULT_CONFIG, } from "./config-schema.js";
|
|
2
|
-
export { type Strategy, type GameStrategy, type GlobalStrategy, validateStrategy, DEFAULT_STRATEGY, } from "./strategy-schema.js";
|
|
3
|
-
export { type AgentIdentity, validateIdentity, } from "./identity-schema.js";
|
|
4
|
-
export { loadSoul, validateSoul, SOUL_EXPORT_PROMPT, DEFAULT_SOUL, } from "./soul.js";
|
|
5
|
-
export { type AgentProfile, type AgentProfileHashes, loadAgentProfile, computeFileHash, resolveAgentDir, ensureAgentDir, } from "./profile-loader.js";
|
|
6
|
-
export { type SecretRef, type SecretRefP0, type SecretStatus, type DetectedEnvKey, SecretResolutionError, resolveSecret, checkSecretStatus, describeRef, storeSecretFile, checkSecretFilePermissions, detectLLMEnvironment, validateSecretRef, KNOWN_LLM_ENV_VARS, } from "./secret-ref.js";
|
|
7
|
-
export { type MigrationResult, migrateOldStrategy, } from "./migrate.js";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface MigrationResult {
|
|
2
|
-
readonly migrated: boolean;
|
|
3
|
-
readonly backupPath: string;
|
|
4
|
-
readonly configPath: string;
|
|
5
|
-
readonly strategyPath: string;
|
|
6
|
-
readonly soulPath: string;
|
|
7
|
-
readonly warnings: string[];
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Migrate an old strategy.json to the new split format.
|
|
11
|
-
* Creates backup, writes config.json + strategy.json + soul.md.
|
|
12
|
-
*
|
|
13
|
-
* @param oldStrategyPath Path to the old strategy.json
|
|
14
|
-
* @param agentDir Target directory (~/.aifight/agents/<slug>/)
|
|
15
|
-
*/
|
|
16
|
-
export declare function migrateOldStrategy(oldStrategyPath: string, agentDir: string): Promise<MigrationResult>;
|