@suwujs/king-ai 0.2.11 → 0.2.12

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.
@@ -32,5 +32,12 @@ export declare function doctorExitCode(results: DoctorResult[]): number;
32
32
  export declare function formatDoctorReport(results: DoctorResult[], version?: string): string;
33
33
  export declare function collectDoctorResults(): Promise<DoctorResult[]>;
34
34
  export declare function doPair(code: string, serverUrl: string, preferredEngine?: EngineId, tenantId?: string): Promise<void>;
35
+ export declare function clearLocalRuntimeState(paths?: {
36
+ agentsRoot: string;
37
+ sessionsDir: string;
38
+ triageDir: string;
39
+ runningStatePath: string;
40
+ heartbeatPath: string;
41
+ }): Promise<void>;
35
42
  export declare function runDoctor(): Promise<void>;
36
43
  export declare function doRun(serverOverride?: string, tenantOverride?: string): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { hostname } from "node:os";
2
- import { mkdtemp } from "node:fs/promises";
2
+ import { mkdtemp, rm } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import { promisify } from "node:util";
@@ -7,7 +7,7 @@ import { execFile } from "node:child_process";
7
7
  import { api, tenantHeader } from "./api.js";
8
8
  import { loadConfig, saveConfig } from "./config.js";
9
9
  import { detectEngines, getAdapter } from "./engine.js";
10
- import { CURRENT_VERSION, HEARTBEAT_PATH } from "./paths.js";
10
+ import { AGENTS_ROOT, CURRENT_VERSION, HEARTBEAT_PATH, RUNNING_STATE_PATH, SESSIONS_DIR, TRIAGE_DIR } from "./paths.js";
11
11
  import { checkForUpdate, recordRunningState, rotateLogsIfNeeded, writeRunningState } from "./service.js";
12
12
  import { AgentRunner } from "./runner.js";
13
13
  import { engineInstallAdvice, engineRemediationAdvice, formatRemediationBlock } from "./remediation.js";
@@ -185,8 +185,24 @@ export async function doPair(code, serverUrl, preferredEngine, tenantId) {
185
185
  });
186
186
  const savedTenantId = paired.tenantId ?? resolvedTenantId;
187
187
  await saveConfig({ serverUrl: resolvedServerUrl, computerId: paired.computerId, deviceToken: paired.deviceToken, ...(savedTenantId ? { tenantId: savedTenantId } : {}) });
188
+ await clearLocalRuntimeState();
188
189
  console.log(`paired as ${paired.computerId}${savedTenantId ? ` tenant=${savedTenantId}` : ""}; default engine: ${engines[0] ?? "none"}; available engines: ${engines.join(", ") || "none"}`);
189
190
  }
191
+ export async function clearLocalRuntimeState(paths = {
192
+ agentsRoot: AGENTS_ROOT,
193
+ sessionsDir: SESSIONS_DIR,
194
+ triageDir: TRIAGE_DIR,
195
+ runningStatePath: RUNNING_STATE_PATH,
196
+ heartbeatPath: HEARTBEAT_PATH
197
+ }) {
198
+ await Promise.all([
199
+ rm(paths.agentsRoot, { recursive: true, force: true }),
200
+ rm(paths.sessionsDir, { recursive: true, force: true }),
201
+ rm(paths.triageDir, { recursive: true, force: true }),
202
+ rm(paths.runningStatePath, { force: true }),
203
+ rm(paths.heartbeatPath, { force: true })
204
+ ]);
205
+ }
190
206
  export async function runDoctor() {
191
207
  const results = await collectDoctorResults();
192
208
  console.log(formatDoctorReport(results));
@@ -15,5 +15,5 @@ export declare const HEARTBEAT_PATH: string;
15
15
  export declare const HOST_EVENTS_PATH: string;
16
16
  export declare const HOST_RUNS_PATH: string;
17
17
  export declare const SERVICE_LABEL = "dev.king-ai";
18
- export declare const CURRENT_VERSION = "0.2.11";
18
+ export declare const CURRENT_VERSION = "0.2.12";
19
19
  export declare const DEFAULT_SERVER: string;
package/dist/src/paths.js CHANGED
@@ -22,5 +22,5 @@ export const HEARTBEAT_PATH = join(CONFIG_DIR, "heartbeat.json");
22
22
  export const HOST_EVENTS_PATH = join(CONFIG_DIR, "host-events.ndjson");
23
23
  export const HOST_RUNS_PATH = join(CONFIG_DIR, "host-runs.ndjson");
24
24
  export const SERVICE_LABEL = "dev.king-ai";
25
- export const CURRENT_VERSION = "0.2.11";
25
+ export const CURRENT_VERSION = "0.2.12";
26
26
  export const DEFAULT_SERVER = process.env.KING_AI_SERVER_URL || "https://api.king-ai.ai";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suwujs/king-ai",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "King AI, a local BYOA agent daemon that bridges remote runtime events to Claude or Codex CLI.",
5
5
  "type": "module",
6
6
  "bin": {