@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,18 +0,0 @@
|
|
|
1
|
-
import type { HandlerEnv } from "../shared";
|
|
2
|
-
export interface ExecResult {
|
|
3
|
-
readonly code: number;
|
|
4
|
-
readonly stdout: string;
|
|
5
|
-
readonly stderr: string;
|
|
6
|
-
}
|
|
7
|
-
type RuntimeName = "openclaw" | "hermes";
|
|
8
|
-
export declare function findExecutable(name: string): string | undefined;
|
|
9
|
-
export declare function execCommand(command: string, args: readonly string[]): Promise<ExecResult>;
|
|
10
|
-
export declare function writeExecResult(env: HandlerEnv, label: string, result: ExecResult): void;
|
|
11
|
-
export declare function promptYesNo(env: HandlerEnv, question: string): Promise<boolean>;
|
|
12
|
-
export declare function promptYesNoDefaultNo(env: HandlerEnv, question: string): Promise<boolean>;
|
|
13
|
-
export declare function offerGatewayRestart(env: HandlerEnv, runtime: RuntimeName, reason: string, opts?: {
|
|
14
|
-
readonly approvedLocalSetup?: boolean;
|
|
15
|
-
}): Promise<boolean>;
|
|
16
|
-
export declare function systemdUnitIsActive(result: ExecResult): boolean;
|
|
17
|
-
export declare function hermesRestartUnavailable(result: ExecResult): boolean;
|
|
18
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export interface EnvKeyPrevious {
|
|
2
|
-
readonly wasActive: boolean;
|
|
3
|
-
readonly value?: string;
|
|
4
|
-
}
|
|
5
|
-
export interface RuntimeSetupState {
|
|
6
|
-
readonly version: 1;
|
|
7
|
-
readonly updatedAt: string;
|
|
8
|
-
readonly openclaw?: {
|
|
9
|
-
readonly responsesEnabledByAIFight: boolean;
|
|
10
|
-
readonly updatedAt: string;
|
|
11
|
-
};
|
|
12
|
-
readonly hermes?: {
|
|
13
|
-
readonly envPath: string;
|
|
14
|
-
readonly previous: Record<string, EnvKeyPrevious>;
|
|
15
|
-
readonly updatedAt: string;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export declare function getRuntimeSetupStatePath(): string;
|
|
19
|
-
export declare function readRuntimeSetupState(): RuntimeSetupState | undefined;
|
|
20
|
-
export declare function mergeRuntimeSetupState(patch: Omit<Partial<RuntimeSetupState>, "version" | "updatedAt">): void;
|
|
21
|
-
export declare function removeRuntimeSetupState(): void;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { BridgeRuntimeType } from "../../bridge/config";
|
|
2
|
-
import type { HandlerEnv } from "../shared";
|
|
3
|
-
export interface RuntimeSetupResult {
|
|
4
|
-
readonly runtimeLocalToken?: string;
|
|
5
|
-
readonly blockedReason?: string;
|
|
6
|
-
}
|
|
7
|
-
interface RuntimeSetupOptions {
|
|
8
|
-
readonly env: HandlerEnv;
|
|
9
|
-
readonly runtimeType: BridgeRuntimeType;
|
|
10
|
-
readonly runtimeLocalUrl: string;
|
|
11
|
-
readonly runtimeLocalToken?: string;
|
|
12
|
-
readonly runtimeModel?: string;
|
|
13
|
-
readonly jsonMode: boolean;
|
|
14
|
-
readonly approvedLocalSetup?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export type ProbeStatus = "ready" | "endpoint_reachable" | "disabled" | "auth_failed" | "unreachable";
|
|
17
|
-
export interface ProbeResult {
|
|
18
|
-
readonly status: ProbeStatus;
|
|
19
|
-
readonly detail: string;
|
|
20
|
-
}
|
|
21
|
-
export declare function offerRuntimeSetup(opts: RuntimeSetupOptions): Promise<RuntimeSetupResult>;
|
|
22
|
-
export declare function probeOpenClaw(env: HandlerEnv, baseUrl: string, token?: string, model?: string): Promise<ProbeResult>;
|
|
23
|
-
export declare function probeHermes(env: HandlerEnv, baseUrl: string, token?: string, model?: string): Promise<ProbeResult>;
|
|
24
|
-
export declare function upsertEnvText(existing: string, values: Record<string, string>): string;
|
|
25
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { ServiceTarget } from "./types";
|
|
2
|
-
import { type ServiceExecFile } from "./platform";
|
|
3
|
-
export declare class LaunchdAlreadyInstalledDiffError extends Error {
|
|
4
|
-
readonly code: "client_already_installed_diff";
|
|
5
|
-
readonly hint?: string;
|
|
6
|
-
constructor(message: string, hint?: string);
|
|
7
|
-
}
|
|
8
|
-
export declare class LaunchdNotInstalledError extends Error {
|
|
9
|
-
readonly code: "client_not_installed";
|
|
10
|
-
readonly hint?: string;
|
|
11
|
-
constructor(message: string, hint?: string);
|
|
12
|
-
}
|
|
13
|
-
export declare class LaunchdInstallFailedError extends Error {
|
|
14
|
-
readonly code: "client_install_failed";
|
|
15
|
-
readonly hint?: string;
|
|
16
|
-
/** Stage taxonomy distinct from systemd's (which is daemon-reload /
|
|
17
|
-
* enable / start). Launchd combines register+start into bootstrap, so
|
|
18
|
-
* the natural stages are the prerequisites (log dir + plist write),
|
|
19
|
-
* the bootstrap call itself, and the post-bootstrap verify. */
|
|
20
|
-
readonly stage: "log-dir" | "write-plist" | "bootstrap" | "verify";
|
|
21
|
-
constructor(stage: LaunchdInstallFailedError["stage"], message: string, hint?: string);
|
|
22
|
-
}
|
|
23
|
-
export declare class LaunchdUninstallFailedError extends Error {
|
|
24
|
-
readonly code: "client_uninstall_failed";
|
|
25
|
-
readonly hint?: string;
|
|
26
|
-
constructor(message: string, hint?: string);
|
|
27
|
-
}
|
|
28
|
-
export declare class LaunchdStartFailedError extends Error {
|
|
29
|
-
readonly code: "client_start_failed";
|
|
30
|
-
readonly hint?: string;
|
|
31
|
-
constructor(message: string, hint?: string);
|
|
32
|
-
}
|
|
33
|
-
export declare class LaunchdStopFailedError extends Error {
|
|
34
|
-
readonly code: "client_stop_failed";
|
|
35
|
-
readonly hint?: string;
|
|
36
|
-
constructor(message: string, hint?: string);
|
|
37
|
-
}
|
|
38
|
-
export declare function escapeXmlText(s: string): string;
|
|
39
|
-
export declare const LAUNCHD_LABEL = "ai.aifight.runtime";
|
|
40
|
-
export interface LaunchdTargetOptions {
|
|
41
|
-
/** Absolute path of the resolved `aifight` binary. Step 4
|
|
42
|
-
* `resolveAifightExec()` produces this; tests inject any string. */
|
|
43
|
-
readonly aifightExec: string;
|
|
44
|
-
/** Absolute path of the plist — typically
|
|
45
|
-
* `~/Library/LaunchAgents/ai.aifight.runtime.plist`. Tests inject a
|
|
46
|
-
* tmp dir. */
|
|
47
|
-
readonly plistPath: string;
|
|
48
|
-
/** Absolute log directory — typically `~/Library/Logs/aifight`.
|
|
49
|
-
* Install creates this if missing; uninstall preserves it unless
|
|
50
|
-
* `--purge`. */
|
|
51
|
-
readonly logDir: string;
|
|
52
|
-
/** AIFIGHT_RUNTIME_HOME baked into the plist EnvironmentVariables. */
|
|
53
|
-
readonly runtimeHome: string;
|
|
54
|
-
/** Effective user id for `gui/$UID` selector. Production uses
|
|
55
|
-
* `process.getuid?.() ?? 0`; tests inject any integer. */
|
|
56
|
-
readonly uid: number;
|
|
57
|
-
/** Factory-time `RunAtLoad` setting (rev3 B4 — see module header for
|
|
58
|
-
* the systemd vs launchd asymmetry rationale).
|
|
59
|
-
* - true: plist writes `RunAtLoad=true`; install bootstraps and
|
|
60
|
-
* then verifies via `launchctl print` (daemon should be running).
|
|
61
|
-
* - false: plist writes `RunAtLoad=false`; install still bootstraps
|
|
62
|
-
* (registers LaunchAgent) but does NOT verify (the daemon is
|
|
63
|
-
* intentionally idle until `aifight service start` kickstarts
|
|
64
|
-
* it). */
|
|
65
|
-
readonly autoStart: boolean;
|
|
66
|
-
/** Defaults to `defaultExecFile` (production). Tests pass a mock that
|
|
67
|
-
* records calls + returns canned stdout/stderr without spawning a
|
|
68
|
-
* real subprocess. */
|
|
69
|
-
readonly execFile?: ServiceExecFile;
|
|
70
|
-
}
|
|
71
|
-
export declare function createLaunchdTarget(opts: LaunchdTargetOptions): ServiceTarget;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { ServicePlatform } from "./types";
|
|
2
|
-
/** OS-level platform — intermediate value before service-manager probe.
|
|
3
|
-
* - "linux" / "darwin": candidate for service install; needs probe.
|
|
4
|
-
* - "unsupported": Windows / FreeBSD / other; short-circuits without probe. */
|
|
5
|
-
export type OsPlatform = "linux" | "darwin" | "unsupported";
|
|
6
|
-
/** Sync, pure, `process.platform`-only OS detection (rev4 B2 + F4 fold).
|
|
7
|
-
* No I/O, no subprocess. Tests stub `process.platform` via Object.defineProperty. */
|
|
8
|
-
export declare function detectOsPlatform(): OsPlatform;
|
|
9
|
-
/** Result of an injected execFile call. Promise resolves on exit 0;
|
|
10
|
-
* rejects with `ServiceExecFileError` on ENOENT, non-zero exit, or
|
|
11
|
-
* any other subprocess error. Mirrors `util.promisify(child_process.execFile)`
|
|
12
|
-
* semantics so the production default below is a thin adapter. */
|
|
13
|
-
export interface ServiceExecFileResult {
|
|
14
|
-
readonly stdout: string;
|
|
15
|
-
readonly stderr: string;
|
|
16
|
-
}
|
|
17
|
-
export interface ServiceExecFileError extends Error {
|
|
18
|
-
/** Node ErrnoException code, e.g. "ENOENT" when the binary is not in PATH. */
|
|
19
|
-
readonly code?: string;
|
|
20
|
-
/** Captured before failure (when the subprocess emitted output then exited
|
|
21
|
-
* non-zero). Empty string when no output was captured. */
|
|
22
|
-
readonly stdout?: string;
|
|
23
|
-
readonly stderr?: string;
|
|
24
|
-
}
|
|
25
|
-
export type ServiceExecFile = (file: string, args: readonly string[]) => Promise<ServiceExecFileResult>;
|
|
26
|
-
/** Production default — wraps Node `child_process.execFile` with a 2 s
|
|
27
|
-
* timeout suitable for cheap version probes. Tests pass an explicit mock
|
|
28
|
-
* so this is never invoked in CI. Exposed so callers (service-install.ts
|
|
29
|
-
* in Step 4) can reuse it instead of recreating the adapter. */
|
|
30
|
-
export declare const defaultExecFile: ServiceExecFile;
|
|
31
|
-
export interface ProbeServicePlatformOptions {
|
|
32
|
-
readonly execFile: ServiceExecFile;
|
|
33
|
-
/** Defaults to `detectOsPlatform()`; tests pass explicit value to avoid
|
|
34
|
-
* Object.defineProperty(process, "platform") gymnastics. */
|
|
35
|
-
readonly osPlatform?: OsPlatform;
|
|
36
|
-
}
|
|
37
|
-
/** Async, injectable, only-read probe.
|
|
38
|
-
* - osPlatform == "unsupported" → short-circuit `unsupported` (NEVER
|
|
39
|
-
* invokes execFile). Tests assert this with a spy that throws if called.
|
|
40
|
-
* - osPlatform == "linux" → `execFile("systemctl", ["--user", "--version"])`.
|
|
41
|
-
* - osPlatform == "darwin" → `execFile("launchctl", ["version"])`.
|
|
42
|
-
* - any rejection (ENOENT / non-zero exit / timeout / unexpected throw),
|
|
43
|
-
* or stdout/stderr containing a known failure marker (e.g.
|
|
44
|
-
* "Failed to connect to bus" — systemd `--user` not running) → `unsupported`.
|
|
45
|
-
* - resolution + clean stdout/stderr → corresponding `linux-systemd-user`
|
|
46
|
-
* or `darwin-launchd-user`. */
|
|
47
|
-
export declare function probeServicePlatform(opts: ProbeServicePlatformOptions): Promise<ServicePlatform>;
|
|
48
|
-
/** rev4 contract — service-specific error class. NOT a `UsageError`,
|
|
49
|
-
* because plain `UsageError` funnels through `main.ts emitUsageError` and
|
|
50
|
-
* produces only `client_usage_error`. Service handlers catch
|
|
51
|
-
* `ServicePlatformError` and call `emitServiceError(env, jsonMode, 2,
|
|
52
|
-
* e.code, e.message, e.hint)`. */
|
|
53
|
-
export declare class ServicePlatformError extends Error {
|
|
54
|
-
readonly code: "client_platform_unsupported" | "client_service_manager_missing";
|
|
55
|
-
readonly hint?: string;
|
|
56
|
-
constructor(code: ServicePlatformError["code"], message: string, hint?: string);
|
|
57
|
-
}
|
|
58
|
-
export interface EnsureSupportedPlatformOptions extends Partial<ProbeServicePlatformOptions> {
|
|
59
|
-
}
|
|
60
|
-
/** Composes `detectOsPlatform()` + `probeServicePlatform()`.
|
|
61
|
-
* - Returns the resolved supported platform on success.
|
|
62
|
-
* - Throws `ServicePlatformError` on unsupported with:
|
|
63
|
-
* Windows / non-linux + non-darwin → `client_platform_unsupported`
|
|
64
|
-
* + hint mentioning Windows or "platform <p>".
|
|
65
|
-
* linux / darwin but service manager unreachable →
|
|
66
|
-
* `client_service_manager_missing` + hint mentioning systemd `--user`
|
|
67
|
-
* or launchctl.
|
|
68
|
-
* Caller handler maps the error via `emitServiceError(... e.code, e.message, e.hint)`. */
|
|
69
|
-
export declare function ensureSupportedPlatform(opts?: EnsureSupportedPlatformOptions): Promise<"linux-systemd-user" | "darwin-launchd-user">;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { ServiceTarget } from "./types";
|
|
2
|
-
import { type ServiceExecFile } from "./platform";
|
|
3
|
-
export declare class AlreadyInstalledDiffError extends Error {
|
|
4
|
-
readonly code: "client_already_installed_diff";
|
|
5
|
-
readonly hint?: string;
|
|
6
|
-
constructor(message: string, hint?: string);
|
|
7
|
-
}
|
|
8
|
-
export declare class NotInstalledError extends Error {
|
|
9
|
-
readonly code: "client_not_installed";
|
|
10
|
-
readonly hint?: string;
|
|
11
|
-
constructor(message: string, hint?: string);
|
|
12
|
-
}
|
|
13
|
-
export declare class InstallFailedError extends Error {
|
|
14
|
-
readonly code: "client_install_failed";
|
|
15
|
-
readonly hint?: string;
|
|
16
|
-
/** Stage the failure happened at — useful for human-mode messages. */
|
|
17
|
-
readonly stage: "daemon-reload" | "enable" | "start";
|
|
18
|
-
constructor(stage: InstallFailedError["stage"], message: string, hint?: string);
|
|
19
|
-
}
|
|
20
|
-
export declare class UninstallFailedError extends Error {
|
|
21
|
-
readonly code: "client_uninstall_failed";
|
|
22
|
-
readonly hint?: string;
|
|
23
|
-
constructor(message: string, hint?: string);
|
|
24
|
-
}
|
|
25
|
-
export declare class StartFailedError extends Error {
|
|
26
|
-
readonly code: "client_start_failed";
|
|
27
|
-
readonly hint?: string;
|
|
28
|
-
constructor(message: string, hint?: string);
|
|
29
|
-
}
|
|
30
|
-
export declare class StopFailedError extends Error {
|
|
31
|
-
readonly code: "client_stop_failed";
|
|
32
|
-
readonly hint?: string;
|
|
33
|
-
constructor(message: string, hint?: string);
|
|
34
|
-
}
|
|
35
|
-
export declare function quoteSystemdExecPath(p: string): string;
|
|
36
|
-
export declare const SYSTEMD_UNIT_NAME = "aifight.service";
|
|
37
|
-
export interface SystemdTargetOptions {
|
|
38
|
-
/** Absolute path of the resolved `aifight` binary. Step 4
|
|
39
|
-
* `resolveAifightExec()` produces this; tests inject any string. */
|
|
40
|
-
readonly aifightExec: string;
|
|
41
|
-
/** Absolute path of the unit file — typically
|
|
42
|
-
* `~/.config/systemd/user/aifight.service`. Tests inject a tmp dir. */
|
|
43
|
-
readonly unitPath: string;
|
|
44
|
-
/** AIFIGHT_RUNTIME_HOME baked into the unit. Tests inject any string. */
|
|
45
|
-
readonly runtimeHome: string;
|
|
46
|
-
/** Optional `--env-file` absolute path (rev3 B3 — systemd-only).
|
|
47
|
-
* Handler validates existence + chmod before passing here; target
|
|
48
|
-
* trusts the value. */
|
|
49
|
-
readonly envFile?: string;
|
|
50
|
-
/** Defaults to `defaultExecFile` (production). Tests pass a mock that
|
|
51
|
-
* records calls + returns canned stdout/stderr without spawning a
|
|
52
|
-
* real subprocess. */
|
|
53
|
-
readonly execFile?: ServiceExecFile;
|
|
54
|
-
}
|
|
55
|
-
export declare function createSystemdTarget(opts: SystemdTargetOptions): ServiceTarget;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/** Service platform identifier — combines OS + service manager.
|
|
2
|
-
* - "linux-systemd-user": Linux with `systemctl --user` reachable.
|
|
3
|
-
* - "darwin-launchd-user": macOS with `launchctl` reachable.
|
|
4
|
-
* - "unsupported": Windows native, Linux without systemd `--user`,
|
|
5
|
-
* macOS without launchctl, or any other POSIX. */
|
|
6
|
-
export type ServicePlatform = "linux-systemd-user" | "darwin-launchd-user" | "unsupported";
|
|
7
|
-
/** install() options. Passed from `runServiceInstall` handler to the
|
|
8
|
-
* selected `ServiceTarget` (systemd or launchd).
|
|
9
|
-
*
|
|
10
|
-
* rev4 contract:
|
|
11
|
-
* - `autoStart=false` (--no-start) on linux: skip `systemctl start` after enable.
|
|
12
|
-
* - `autoStart=false` (--no-start) on launchd: plist writes RunAtLoad=false,
|
|
13
|
-
* still runs `launchctl bootstrap` (registers LaunchAgent) but skips kickstart.
|
|
14
|
-
* - `printOnly=true` (--print): generator emits unit/plist text to stdout,
|
|
15
|
-
* writes nothing, runs no systemctl/launchctl. exit 0.
|
|
16
|
-
* - `envFile` is systemd-only; darwin handlers exit 2 with
|
|
17
|
-
* `client_env_file_unsupported_on_darwin` BEFORE createLaunchdTarget. */
|
|
18
|
-
export interface ServiceInstallOptions {
|
|
19
|
-
readonly autoStart: boolean;
|
|
20
|
-
readonly printOnly: boolean;
|
|
21
|
-
readonly envFile?: string;
|
|
22
|
-
}
|
|
23
|
-
/** uninstall() options. */
|
|
24
|
-
export interface ServiceUninstallOptions {
|
|
25
|
-
/** When true, also `rm -rf $AIFIGHT_RUNTIME_HOME` after stop+disable+removing
|
|
26
|
-
* unit/plist (拍板点 #8). Plain `--purge` flag is the user's destructive
|
|
27
|
-
* opt-in; handler prints a warning line in human mode but does NOT prompt. */
|
|
28
|
-
readonly purge: boolean;
|
|
29
|
-
}
|
|
30
|
-
/** status() result — three-state contract (拍板点 #6). */
|
|
31
|
-
export type ServiceStatus = {
|
|
32
|
-
kind: "not_installed";
|
|
33
|
-
} | {
|
|
34
|
-
kind: "stopped";
|
|
35
|
-
/** Optional sub-status from the underlying service manager:
|
|
36
|
-
* - systemd: `is-active` raw output (`inactive` / `failed` / `activating` / ...)
|
|
37
|
-
* - launchd: parsed state (`waiting` / `unknown` / ...) */
|
|
38
|
-
substatus?: string;
|
|
39
|
-
} | {
|
|
40
|
-
kind: "running";
|
|
41
|
-
/** systemd: parsed `MainPID`; launchd: parsed `pid`.
|
|
42
|
-
* Best-effort; absent when parser fails (Open Question #6). */
|
|
43
|
-
pid?: number;
|
|
44
|
-
/** systemd: parsed `ActiveEnterTimestamp`; launchd: not always available.
|
|
45
|
-
* ISO 8601 string when present. */
|
|
46
|
-
since?: string;
|
|
47
|
-
};
|
|
48
|
-
/** Common shape for systemd + launchd targets. The handlers in
|
|
49
|
-
* `service-install.ts` consume this interface; both target factories
|
|
50
|
-
* (`createSystemdTarget` + `createLaunchdTarget`) return implementations. */
|
|
51
|
-
export interface ServiceTarget {
|
|
52
|
-
/** Absolute path of the generated unit/plist:
|
|
53
|
-
* - systemd: `~/.config/systemd/user/aifight.service`
|
|
54
|
-
* - launchd: `~/Library/LaunchAgents/ai.aifight.runtime.plist` */
|
|
55
|
-
readonly unitPath: string;
|
|
56
|
-
/** Pure — produces the unit/plist text. Used for `--print` dry-run +
|
|
57
|
-
* snapshot tests + diff detection on existing files. */
|
|
58
|
-
generate(): string;
|
|
59
|
-
install(opts: ServiceInstallOptions): Promise<void>;
|
|
60
|
-
uninstall(opts: ServiceUninstallOptions): Promise<void>;
|
|
61
|
-
start(): Promise<void>;
|
|
62
|
-
stop(): Promise<void>;
|
|
63
|
-
status(): Promise<ServiceStatus>;
|
|
64
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { HandlerArgs, HandlerEnv } from "../shared";
|
|
2
|
-
import { type OsPlatform, type ServiceExecFile } from "./service/platform";
|
|
3
|
-
export type ServiceErrorCode = "client_unsupported_flag" | "client_platform_unsupported" | "client_service_manager_missing" | "client_env_file_missing" | "client_env_file_unsupported_on_darwin" | "client_already_installed_diff" | "client_not_installed" | "client_aifight_exec_unresolved" | "client_install_failed" | "client_uninstall_failed" | "client_start_failed" | "client_stop_failed";
|
|
4
|
-
export declare function emitServiceError(env: HandlerEnv, jsonMode: boolean, exitCode: number, code: ServiceErrorCode, humanMessage: string, hint?: string): number;
|
|
5
|
-
export declare function resolveAifightExec(candidate: string | undefined, execFile: ServiceExecFile): Promise<string>;
|
|
6
|
-
export interface ServiceDeps {
|
|
7
|
-
/** ExecFile injection for tests. Defaults to `defaultExecFile`. */
|
|
8
|
-
readonly execFile?: ServiceExecFile;
|
|
9
|
-
/** Pre-resolved aifight binary path. When provided, the install
|
|
10
|
-
* handler skips `resolveAifightExec(process.argv[1], ...)` —
|
|
11
|
-
* necessary in tests because `process.argv[1]` typically points at
|
|
12
|
-
* the vitest worker, not a real aifight binary. */
|
|
13
|
-
readonly aifightExec?: string;
|
|
14
|
-
/** OS platform override for tests. Defaults to `detectOsPlatform()`. */
|
|
15
|
-
readonly osPlatform?: OsPlatform;
|
|
16
|
-
/** Effective UID for `gui/$UID` selector on darwin. Defaults to
|
|
17
|
-
* `process.getuid?.() ?? 0`. */
|
|
18
|
-
readonly uid?: number;
|
|
19
|
-
/** Path overrides — production picks under `~`. Tests inject tmp dirs. */
|
|
20
|
-
readonly systemdUnitPath?: string;
|
|
21
|
-
readonly launchdPlistPath?: string;
|
|
22
|
-
readonly launchdLogDir?: string;
|
|
23
|
-
readonly runtimeHome?: string;
|
|
24
|
-
}
|
|
25
|
-
export declare function runServiceInstall(args: HandlerArgs, env: HandlerEnv, deps?: ServiceDeps): Promise<number>;
|
|
26
|
-
export declare function runServiceUninstall(args: HandlerArgs, env: HandlerEnv, deps?: ServiceDeps): Promise<number>;
|
|
27
|
-
export declare function runServiceStart(args: HandlerArgs, env: HandlerEnv, deps?: ServiceDeps): Promise<number>;
|
|
28
|
-
export declare function runServiceStop(args: HandlerArgs, env: HandlerEnv, deps?: ServiceDeps): Promise<number>;
|
|
29
|
-
export declare function runServiceStatus(args: HandlerArgs, env: HandlerEnv, deps?: ServiceDeps): Promise<number>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { HandlerArgs, HandlerEnv } from "../shared";
|
|
2
|
-
interface PureStubOptions {
|
|
3
|
-
/** User-visible canonical name, e.g. "setup" / "service install" / "results". */
|
|
4
|
-
readonly command: string;
|
|
5
|
-
readonly arityMin: number;
|
|
6
|
-
readonly arityMax: number;
|
|
7
|
-
readonly usage: string;
|
|
8
|
-
/** Tier B carries milestone (e.g. "M1-18 daemon lifecycle"); Tier C omits. */
|
|
9
|
-
readonly milestone?: string;
|
|
10
|
-
}
|
|
11
|
-
/** Factory that returns a Tier B / Tier C stub handler. */
|
|
12
|
-
export declare function pureStub(opts: PureStubOptions): (args: HandlerArgs, env: HandlerEnv) => Promise<number>;
|
|
13
|
-
export declare function tierBStub(command: string, milestone: string, arity?: {
|
|
14
|
-
readonly min: number;
|
|
15
|
-
readonly max: number;
|
|
16
|
-
}, usage?: string): (args: HandlerArgs, env: HandlerEnv) => Promise<number>;
|
|
17
|
-
export declare function tierCStub(command: string, arity?: {
|
|
18
|
-
readonly min: number;
|
|
19
|
-
readonly max: number;
|
|
20
|
-
}, usage?: string): (args: HandlerArgs, env: HandlerEnv) => Promise<number>;
|
|
21
|
-
export declare function runAgentAdd(args: HandlerArgs, env: HandlerEnv): Promise<number>;
|
|
22
|
-
export declare function runAgentRemove(args: HandlerArgs, env: HandlerEnv): Promise<number>;
|
|
23
|
-
export declare function doctorFixSkillOverrideStub(): (args: HandlerArgs, env: HandlerEnv) => Promise<number>;
|
|
24
|
-
export {};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export type ControlErrorCodeLocal = "unauthorized" | "not_found" | "method_not_allowed" | "bad_request" | "unsupported_media_type" | "payload_too_large" | "not_implemented" | "service_unavailable" | "internal_error";
|
|
2
|
-
export declare function isControlErrorCode(x: unknown): x is ControlErrorCodeLocal;
|
|
3
|
-
export interface ControlErrorBodyLocal {
|
|
4
|
-
readonly error: {
|
|
5
|
-
readonly code: ControlErrorCodeLocal;
|
|
6
|
-
readonly message: string;
|
|
7
|
-
readonly details?: Readonly<Record<string, unknown>>;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export declare function isControlErrorBody(x: unknown): x is ControlErrorBodyLocal;
|
|
11
|
-
export type ControlClientErrorKind = "daemon_unreachable" | "runtime_files_corrupt" | "auth_failed" | "request_timeout" | "server_error" | "transport_unparseable";
|
|
12
|
-
export interface ControlClientErrorInit {
|
|
13
|
-
readonly serverCode?: ControlErrorCodeLocal;
|
|
14
|
-
readonly status?: number;
|
|
15
|
-
readonly body?: unknown;
|
|
16
|
-
readonly cause?: unknown;
|
|
17
|
-
}
|
|
18
|
-
export declare class ControlClientError extends Error {
|
|
19
|
-
readonly name = "ControlClientError";
|
|
20
|
-
readonly kind: ControlClientErrorKind;
|
|
21
|
-
readonly serverCode?: ControlErrorCodeLocal;
|
|
22
|
-
readonly status: number;
|
|
23
|
-
readonly body?: unknown;
|
|
24
|
-
readonly cause?: unknown;
|
|
25
|
-
constructor(kind: ControlClientErrorKind, message: string, init?: ControlClientErrorInit);
|
|
26
|
-
}
|
|
27
|
-
export interface ControlClient {
|
|
28
|
-
/** GET <path>. Returns parsed JSON body. 4xx/5xx → throw ControlClientError. */
|
|
29
|
-
get<T = unknown>(path: string): Promise<T>;
|
|
30
|
-
/** POST <path> with body.
|
|
31
|
-
* - body === undefined → no Content-Type / no payload (use this for
|
|
32
|
-
* /shutdown, /pause, /resume, /leave).
|
|
33
|
-
* - body === null → Content-Type: application/json + literal "null".
|
|
34
|
-
* - object → Content-Type: application/json + JSON.stringify. */
|
|
35
|
-
post<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
36
|
-
/** DELETE <path>. */
|
|
37
|
-
delete<T = unknown>(path: string): Promise<T>;
|
|
38
|
-
}
|
|
39
|
-
export interface CreateControlClientOptions {
|
|
40
|
-
/** Sync, lazy — invoked at the moment of each request, NOT at client
|
|
41
|
-
* construction. Construction MUST succeed even if the source would
|
|
42
|
-
* throw, so bridge-independent commands (version / --help / doctor)
|
|
43
|
-
* can construct a client without a running Bridge. */
|
|
44
|
-
readonly tokenSource: () => string;
|
|
45
|
-
/** Same lazy semantics + same wrap-at-boundary contract as tokenSource. */
|
|
46
|
-
readonly portSource: () => number;
|
|
47
|
-
/** Default "127.0.0.1". */
|
|
48
|
-
readonly host?: string;
|
|
49
|
-
/** Per-request timeout. Default 10000 ms. */
|
|
50
|
-
readonly baseTimeoutMs?: number;
|
|
51
|
-
/** Injectable for tests. Default globalThis.fetch. */
|
|
52
|
-
readonly fetchImpl?: typeof fetch;
|
|
53
|
-
/** Optional log hook (rebootstrap reason etc.). MUST NOT receive token. */
|
|
54
|
-
readonly onLog?: (event: {
|
|
55
|
-
code: string;
|
|
56
|
-
message: string;
|
|
57
|
-
}) => void;
|
|
58
|
-
}
|
|
59
|
-
export declare function createControlClient(opts: CreateControlClientOptions): ControlClient;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/** Minimal duck-type of M1-16 SanitizedAgentSnapshot we render. */
|
|
2
|
-
interface AgentSnapshotLike {
|
|
3
|
-
readonly name: string;
|
|
4
|
-
readonly started: boolean;
|
|
5
|
-
readonly stopped: boolean;
|
|
6
|
-
readonly transport?: string;
|
|
7
|
-
readonly state: AgentStateLike | null;
|
|
8
|
-
}
|
|
9
|
-
interface AgentStateLike {
|
|
10
|
-
readonly phase?: string;
|
|
11
|
-
readonly agentId?: string;
|
|
12
|
-
readonly agentName?: string;
|
|
13
|
-
readonly availableGames?: readonly string[];
|
|
14
|
-
readonly autoConfirmMatches?: boolean;
|
|
15
|
-
readonly queue?: {
|
|
16
|
-
readonly game: string;
|
|
17
|
-
readonly mode: string;
|
|
18
|
-
};
|
|
19
|
-
readonly activeMatch?: {
|
|
20
|
-
readonly sessionId: string;
|
|
21
|
-
readonly game: string;
|
|
22
|
-
readonly startedAt: number;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
interface DailyScheduleConfigLike {
|
|
26
|
-
readonly enabled: boolean;
|
|
27
|
-
readonly timezone: string;
|
|
28
|
-
readonly minIntervalSec?: number;
|
|
29
|
-
readonly days: Readonly<Record<string, {
|
|
30
|
-
readonly count: number;
|
|
31
|
-
}>>;
|
|
32
|
-
}
|
|
33
|
-
export declare function formatAgentTable(agents: readonly AgentSnapshotLike[]): string;
|
|
34
|
-
export declare function formatAgentStatus(agent: AgentSnapshotLike): string;
|
|
35
|
-
interface ScheduleSnapshotLike {
|
|
36
|
-
readonly running: boolean;
|
|
37
|
-
/** YYYY-MM-DD local date (M1-15 DailySchedulerSnapshot.today) or null
|
|
38
|
-
* when scheduler has not yet computed the boundary. */
|
|
39
|
-
readonly today?: string | null;
|
|
40
|
-
readonly remaining?: Readonly<Record<string, number>>;
|
|
41
|
-
readonly nextFireInMs?: number | null;
|
|
42
|
-
readonly lastAttempt?: {
|
|
43
|
-
readonly outcome?: string;
|
|
44
|
-
readonly game?: string | null;
|
|
45
|
-
readonly atMs?: number;
|
|
46
|
-
} | null;
|
|
47
|
-
}
|
|
48
|
-
export declare function formatScheduleShow(cfg: DailyScheduleConfigLike | null, snap: ScheduleSnapshotLike): string;
|
|
49
|
-
/** Compose a JSON-mode error envelope. Used by main.ts error funnel and
|
|
50
|
-
* by handlers that surface a usage error in JSON mode. */
|
|
51
|
-
export declare function jsonErrorEnvelope(code: string, message: string, details?: Readonly<Record<string, unknown>>): string;
|
|
52
|
-
export {};
|
package/dist/types/cli/main.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { HelloResult } from "../index";
|
|
2
|
-
import type { BridgeServiceDeps } from "../bridge/service";
|
|
3
|
-
export interface RunOptions {
|
|
4
|
-
readonly stdout?: (s: string) => void;
|
|
5
|
-
readonly stderr?: (s: string) => void;
|
|
6
|
-
/** Override for M1-01 hello() (used by doctor schemas check). */
|
|
7
|
-
readonly hello?: () => HelloResult;
|
|
8
|
-
/** Override fetch (used by tests). */
|
|
9
|
-
readonly fetchImpl?: typeof fetch;
|
|
10
|
-
/** Reserved for injected command handlers that need a shorter network timeout. */
|
|
11
|
-
readonly baseTimeoutMs?: number;
|
|
12
|
-
readonly onLog?: (event: {
|
|
13
|
-
code: string;
|
|
14
|
-
message: string;
|
|
15
|
-
}) => void;
|
|
16
|
-
readonly bridgeService?: BridgeServiceDeps;
|
|
17
|
-
}
|
|
18
|
-
export declare function run(argv: readonly string[], opts?: RunOptions): Promise<number>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type RuntimeFilesErrorKind = "token_missing" | "port_missing" | "token_corrupt" | "port_corrupt";
|
|
2
|
-
export declare class RuntimeFilesError extends Error {
|
|
3
|
-
readonly name = "RuntimeFilesError";
|
|
4
|
-
readonly kind: RuntimeFilesErrorKind;
|
|
5
|
-
readonly filePath: string;
|
|
6
|
-
constructor(kind: RuntimeFilesErrorKind, filePath: string, message: string);
|
|
7
|
-
}
|
|
8
|
-
export declare function tokenFilePath(): string;
|
|
9
|
-
export declare function portFilePath(): string;
|
|
10
|
-
export declare function readToken(): string;
|
|
11
|
-
export declare function readPort(): number;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { ControlClient, CreateControlClientOptions } from "./control-client";
|
|
2
|
-
import type { HelloResult } from "../index";
|
|
3
|
-
import type { BridgeServiceDeps } from "../bridge/service";
|
|
4
|
-
/** Per-handler injectable environment. Defaults wired to process I/O +
|
|
5
|
-
* real fs + native fetch. Tests pass overrides for stdout/stderr capture
|
|
6
|
-
* + hello stub + fetchImpl pointing at a temporary M1-16 server. */
|
|
7
|
-
export interface HandlerEnv {
|
|
8
|
-
readonly stdout: (s: string) => void;
|
|
9
|
-
readonly stderr: (s: string) => void;
|
|
10
|
-
/** Override for the M1-01 schemas/types self-test used by `doctor`.
|
|
11
|
-
* Default: real `hello` from runtime/src/index.ts (lazy-imported by
|
|
12
|
-
* the doctor handler so other commands do not pull in the
|
|
13
|
-
* schemas-loading cost). */
|
|
14
|
-
readonly hello?: () => HelloResult;
|
|
15
|
-
/** Override fetch implementation for tests. Default globalThis.fetch. */
|
|
16
|
-
readonly fetchImpl?: typeof fetch;
|
|
17
|
-
/** Optional rebootstrap log hook (forwarded to control-client). */
|
|
18
|
-
readonly onLog?: (event: {
|
|
19
|
-
code: string;
|
|
20
|
-
message: string;
|
|
21
|
-
}) => void;
|
|
22
|
-
/** Default 10000 ms per Step 2b directive (must not drop below ~3000
|
|
23
|
-
* for normal commands). doctor uses its own 3000 ms one-shot fetch. */
|
|
24
|
-
readonly baseTimeoutMs?: number;
|
|
25
|
-
/** Optional bridge service manager overrides for tests and controlled installs. */
|
|
26
|
-
readonly bridgeService?: BridgeServiceDeps;
|
|
27
|
-
}
|
|
28
|
-
export interface HandlerArgs {
|
|
29
|
-
/** Positional argv with the command (and subcommand for `agent`/`daily`)
|
|
30
|
-
* already stripped by the dispatcher in main.ts. */
|
|
31
|
-
readonly positional: readonly string[];
|
|
32
|
-
/** All globally-known flags merged from the single argv pass. */
|
|
33
|
-
readonly flags: Readonly<Record<string, string | number | boolean>>;
|
|
34
|
-
/** True when `--json` was set (any position — floating flag, rev2 fix #1). */
|
|
35
|
-
readonly jsonMode: boolean;
|
|
36
|
-
}
|
|
37
|
-
/** Build a controlClient that lazily reads token+port from the daemon
|
|
38
|
-
* files. version / doctor / Tier B/C stubs do NOT call this. */
|
|
39
|
-
export declare function makeClient(env: HandlerEnv, extra?: Partial<CreateControlClientOptions>): ControlClient;
|
|
40
|
-
/** Centralised game enum for client-side validation (Risks #11 — CLI
|
|
41
|
-
* hard-codes the supported list rather than fetching from server, so a
|
|
42
|
-
* contract drift surfaces as a usage error rather than a daemon round
|
|
43
|
-
* trip). */
|
|
44
|
-
export declare const SUPPORTED_GAMES: ReadonlyArray<string>;
|
|
45
|
-
export declare function isSupportedGame(g: string): boolean;
|
|
46
|
-
/** Class for argv-parser-style usage errors that should map to exit 2.
|
|
47
|
-
* Distinct from AgentResolverError (which uses its own kind discriminator). */
|
|
48
|
-
export declare class UsageError extends Error {
|
|
49
|
-
readonly name = "UsageError";
|
|
50
|
-
readonly hint?: string;
|
|
51
|
-
constructor(message: string, hint?: string);
|
|
52
|
-
}
|
|
53
|
-
/** Expected runtime/API failures that should be shown as ordinary command
|
|
54
|
-
* errors (exit 1), not catchall programmer failures (exit 99). */
|
|
55
|
-
export declare class CommandError extends Error {
|
|
56
|
-
readonly name = "CommandError";
|
|
57
|
-
readonly code: string;
|
|
58
|
-
readonly exitCode: number;
|
|
59
|
-
readonly hint?: string;
|
|
60
|
-
constructor(code: string, message: string, opts?: {
|
|
61
|
-
readonly exitCode?: number;
|
|
62
|
-
readonly hint?: string;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
/** Step 3b — assert positional arity at the top of every handler BEFORE
|
|
66
|
-
* any side-effect (controlClient / network / fs). Extra positionals
|
|
67
|
-
* must NOT silently fall through to a successful POST (e.g.
|
|
68
|
-
* `aifight shutdown anything` previously still POSTed /v1/shutdown).
|
|
69
|
-
*
|
|
70
|
-
* Throws UsageError → main.ts funnel maps to exit 2 + usage hint.
|
|
71
|
-
* No-args handlers call `expectArity(args, 0, 0, "...")`;
|
|
72
|
-
* optional-arg handlers (e.g. agent status [<name>]) use min=0 max=1;
|
|
73
|
-
* fixed-arity handlers (e.g. daily set <game> <count>) use min=max=N. */
|
|
74
|
-
export declare function expectArity(args: HandlerArgs, min: number, max: number, usage: string): void;
|