@love-moon/ai-sdk 0.7.5 → 0.7.6
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/CHANGELOG.md +11 -0
- package/dist/manager/config.js +2 -2
- package/dist/manager/manager.d.ts +2 -2
- package/dist/manager/manager.js +3 -3
- package/dist/manager/paths.d.ts +5 -0
- package/dist/manager/paths.js +35 -7
- package/dist/manager/quota/cache.js +2 -2
- package/dist/shared.js +23 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @love-moon/ai-sdk
|
|
2
2
|
|
|
3
|
+
## 0.7.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7bbb412: Add `CONDUCTOR_HOME` support for relocating user-level configuration, logs,
|
|
8
|
+
Fire locks, sessions, update metadata, and AI manager caches while leaving
|
|
9
|
+
project-scoped `.conductor` directories and Fire task markers in place.
|
|
10
|
+
|
|
11
|
+
Migrate device authorization to `conductor.conductor-ai.top` while preserving
|
|
12
|
+
compatibility with the legacy official endpoint and self-hosted backends.
|
|
13
|
+
|
|
3
14
|
## 0.7.5
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/manager/config.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { parse as parseYaml } from "yaml";
|
|
3
|
-
import {
|
|
3
|
+
import { expandHome, resolveDefaultConductorConfig } from "./paths.js";
|
|
4
4
|
const EMPTY = { codex: { authJson: [] } };
|
|
5
5
|
/**
|
|
6
6
|
* Load the `ai_manager` section from a conductor config file.
|
|
7
7
|
* Returns an empty config if the file does not exist or the section is missing.
|
|
8
8
|
*/
|
|
9
|
-
export async function loadAiManagerConfig(configPath =
|
|
9
|
+
export async function loadAiManagerConfig(configPath = resolveDefaultConductorConfig()) {
|
|
10
10
|
let raw;
|
|
11
11
|
try {
|
|
12
12
|
raw = await readFile(configPath, "utf8");
|
|
@@ -5,7 +5,7 @@ import { type GetCopilotQuotaOptions } from "./quota/copilot.js";
|
|
|
5
5
|
import { type GetExternalQuotaListOptions, type GetExternalQuotaOptions } from "./quota/external.js";
|
|
6
6
|
import type { AiManagerConfig, CodexAccount, CodexQuota, ClaudeQuota, ExternalQuota, ExternalQuotaList, KimiQuota, CopilotQuota, InstallStatus, NetworkStatus, SwitchResult, Tool } from "./types.js";
|
|
7
7
|
export interface AiManagerOptions {
|
|
8
|
-
/** Path to conductor config.yaml. Default:
|
|
8
|
+
/** Path to conductor config.yaml. Default: $CONDUCTOR_HOME/config.yaml. */
|
|
9
9
|
configPath?: string;
|
|
10
10
|
/** Path to the active codex auth.json. Default: ~/.codex/auth.json */
|
|
11
11
|
codexAuthPath?: string;
|
|
@@ -20,7 +20,7 @@ export declare class AiManager {
|
|
|
20
20
|
constructor(opts?: AiManagerOptions);
|
|
21
21
|
/**
|
|
22
22
|
* Read the latest ai_manager config. Cached against the config file's mtime,
|
|
23
|
-
* so edits to
|
|
23
|
+
* so edits to the resolved Conductor config.yaml are picked up immediately without
|
|
24
24
|
* restarting the daemon, while a 30s polling cycle does not re-parse YAML
|
|
25
25
|
* on every action. Falls back to always-reload if stat() fails.
|
|
26
26
|
* The `config` constructor option short-circuits disk reads (used by tests).
|
package/dist/manager/manager.js
CHANGED
|
@@ -8,20 +8,20 @@ import { getClaudeQuota } from "./quota/claude.js";
|
|
|
8
8
|
import { getKimiQuota } from "./quota/kimi.js";
|
|
9
9
|
import { getCopilotQuota } from "./quota/copilot.js";
|
|
10
10
|
import { getExternalQuota, getExternalQuotaList, } from "./quota/external.js";
|
|
11
|
-
import { DEFAULT_CODEX_AUTH,
|
|
11
|
+
import { DEFAULT_CODEX_AUTH, resolveDefaultConductorConfig } from "./paths.js";
|
|
12
12
|
export class AiManager {
|
|
13
13
|
configPath;
|
|
14
14
|
codexAuthPath;
|
|
15
15
|
configOverride;
|
|
16
16
|
cached;
|
|
17
17
|
constructor(opts = {}) {
|
|
18
|
-
this.configPath = opts.configPath ??
|
|
18
|
+
this.configPath = opts.configPath ?? resolveDefaultConductorConfig();
|
|
19
19
|
this.codexAuthPath = opts.codexAuthPath ?? DEFAULT_CODEX_AUTH;
|
|
20
20
|
this.configOverride = opts.config;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Read the latest ai_manager config. Cached against the config file's mtime,
|
|
24
|
-
* so edits to
|
|
24
|
+
* so edits to the resolved Conductor config.yaml are picked up immediately without
|
|
25
25
|
* restarting the daemon, while a 30s polling cycle does not re-parse YAML
|
|
26
26
|
* on every action. Falls back to always-reload if stat() fails.
|
|
27
27
|
* The `config` constructor option short-circuits disk reads (used by tests).
|
package/dist/manager/paths.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
type PathEnv = Record<string, string | undefined>;
|
|
1
2
|
export declare function expandHome(p: string): string;
|
|
3
|
+
export declare function resolveConductorHome(env?: PathEnv): string;
|
|
4
|
+
export declare function resolveDefaultConductorConfig(env?: PathEnv): string;
|
|
5
|
+
export declare function resolveDefaultQuotaCacheDir(env?: PathEnv): string;
|
|
2
6
|
export declare const DEFAULT_CONDUCTOR_CONFIG: string;
|
|
3
7
|
export declare const DEFAULT_CODEX_AUTH: string;
|
|
4
8
|
export declare const DEFAULT_CODEX_CONFIG: string;
|
|
@@ -6,3 +10,4 @@ export declare const DEFAULT_KIMI_CODE_HOME: string;
|
|
|
6
10
|
export declare const DEFAULT_KIMI_CREDENTIAL: string;
|
|
7
11
|
export declare const LEGACY_KIMI_CREDENTIAL: string;
|
|
8
12
|
export declare const DEFAULT_QUOTA_CACHE_DIR: string;
|
|
13
|
+
export {};
|
package/dist/manager/paths.js
CHANGED
|
@@ -1,18 +1,46 @@
|
|
|
1
1
|
import { homedir } from "node:os";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
function optionalString(value) {
|
|
4
|
+
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
5
|
+
}
|
|
6
|
+
function userHome(env = process.env) {
|
|
7
|
+
return optionalString(env.HOME) || optionalString(env.USERPROFILE) || homedir();
|
|
8
|
+
}
|
|
9
|
+
function expandHomeWithEnv(p, env = process.env) {
|
|
4
10
|
if (!p)
|
|
5
11
|
return p;
|
|
12
|
+
const home = userHome(env);
|
|
6
13
|
if (p === "~")
|
|
7
|
-
return
|
|
8
|
-
if (p.startsWith("~/"))
|
|
9
|
-
return join(
|
|
14
|
+
return home;
|
|
15
|
+
if (p.startsWith("~/") || p.startsWith("~\\"))
|
|
16
|
+
return join(home, p.slice(2));
|
|
10
17
|
return p;
|
|
11
18
|
}
|
|
12
|
-
export
|
|
19
|
+
export function expandHome(p) {
|
|
20
|
+
return expandHomeWithEnv(p);
|
|
21
|
+
}
|
|
22
|
+
export function resolveConductorHome(env = process.env) {
|
|
23
|
+
const configured = optionalString(env.CONDUCTOR_HOME);
|
|
24
|
+
if (configured) {
|
|
25
|
+
const expanded = expandHomeWithEnv(configured, env);
|
|
26
|
+
return resolve(expanded);
|
|
27
|
+
}
|
|
28
|
+
return join(resolve(userHome(env)), ".conductor");
|
|
29
|
+
}
|
|
30
|
+
export function resolveDefaultConductorConfig(env = process.env) {
|
|
31
|
+
const configured = optionalString(env.CONDUCTOR_CONFIG);
|
|
32
|
+
if (configured) {
|
|
33
|
+
return resolve(expandHomeWithEnv(configured, env));
|
|
34
|
+
}
|
|
35
|
+
return join(resolveConductorHome(env), "config.yaml");
|
|
36
|
+
}
|
|
37
|
+
export function resolveDefaultQuotaCacheDir(env = process.env) {
|
|
38
|
+
return join(resolveConductorHome(env), "cache", "ai-manager");
|
|
39
|
+
}
|
|
40
|
+
export const DEFAULT_CONDUCTOR_CONFIG = resolveDefaultConductorConfig();
|
|
13
41
|
export const DEFAULT_CODEX_AUTH = join(homedir(), ".codex", "auth.json");
|
|
14
42
|
export const DEFAULT_CODEX_CONFIG = join(homedir(), ".codex", "config.toml");
|
|
15
43
|
export const DEFAULT_KIMI_CODE_HOME = process.env.KIMI_CODE_HOME?.trim() || join(homedir(), ".kimi-code");
|
|
16
44
|
export const DEFAULT_KIMI_CREDENTIAL = join(DEFAULT_KIMI_CODE_HOME, "credentials", "kimi-code.json");
|
|
17
45
|
export const LEGACY_KIMI_CREDENTIAL = join(homedir(), ".kimi", "credentials", "kimi-code.json");
|
|
18
|
-
export const DEFAULT_QUOTA_CACHE_DIR =
|
|
46
|
+
export const DEFAULT_QUOTA_CACHE_DIR = resolveDefaultQuotaCacheDir();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
|
-
import {
|
|
4
|
+
import { resolveDefaultQuotaCacheDir } from "../paths.js";
|
|
5
5
|
export function fingerprintKey(parts) {
|
|
6
6
|
const h = createHash("sha1");
|
|
7
7
|
for (const p of parts)
|
|
@@ -23,7 +23,7 @@ export async function writeCache(file, value) {
|
|
|
23
23
|
await writeFile(file, JSON.stringify(entry), "utf8");
|
|
24
24
|
return entry;
|
|
25
25
|
}
|
|
26
|
-
export function cacheFile(tool, fingerprint, dir =
|
|
26
|
+
export function cacheFile(tool, fingerprint, dir = resolveDefaultQuotaCacheDir()) {
|
|
27
27
|
return join(dir, `quota-${tool}-${fingerprint}.json`);
|
|
28
28
|
}
|
|
29
29
|
export function isFresh(entry, ttlSeconds) {
|
package/dist/shared.js
CHANGED
|
@@ -280,8 +280,29 @@ export function extractLongFlagFromCommandLine(commandLine, flag) {
|
|
|
280
280
|
return "";
|
|
281
281
|
}
|
|
282
282
|
export function resolveConductorConfigPath(configFilePath) {
|
|
283
|
-
|
|
284
|
-
|
|
283
|
+
if (configFilePath) {
|
|
284
|
+
return configFilePath;
|
|
285
|
+
}
|
|
286
|
+
const userHome = process.env.HOME || process.env.USERPROFILE || os.homedir();
|
|
287
|
+
if (typeof process.env.CONDUCTOR_CONFIG === "string" && process.env.CONDUCTOR_CONFIG.trim()) {
|
|
288
|
+
const configuredPath = process.env.CONDUCTOR_CONFIG.trim();
|
|
289
|
+
const expandedPath = configuredPath === "~"
|
|
290
|
+
? userHome
|
|
291
|
+
: configuredPath.startsWith("~/") || configuredPath.startsWith("~\\")
|
|
292
|
+
? path.join(userHome, configuredPath.slice(2))
|
|
293
|
+
: configuredPath;
|
|
294
|
+
return path.resolve(expandedPath);
|
|
295
|
+
}
|
|
296
|
+
const configuredHome = typeof process.env.CONDUCTOR_HOME === "string" ? process.env.CONDUCTOR_HOME.trim() : "";
|
|
297
|
+
if (configuredHome) {
|
|
298
|
+
const expandedHome = configuredHome === "~"
|
|
299
|
+
? userHome
|
|
300
|
+
: configuredHome.startsWith("~/") || configuredHome.startsWith("~\\")
|
|
301
|
+
? path.join(userHome, configuredHome.slice(2))
|
|
302
|
+
: configuredHome;
|
|
303
|
+
return path.join(path.resolve(expandedHome), "config.yaml");
|
|
304
|
+
}
|
|
305
|
+
return path.join(userHome, ".conductor", "config.yaml");
|
|
285
306
|
}
|
|
286
307
|
export function loadYamlConfig(configFilePath) {
|
|
287
308
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@love-moon/ai-sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/lovemoon-ai/conductor.git"
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"zod": "^4.1.5"
|
|
33
33
|
},
|
|
34
34
|
"optionalDependencies": {
|
|
35
|
-
"@love-moon/chat-web": "^0.7.
|
|
35
|
+
"@love-moon/chat-web": "^0.7.6"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^22.10.2",
|
|
39
39
|
"tsx": "^4.20.6",
|
|
40
40
|
"typescript": "^5.6.3"
|
|
41
41
|
},
|
|
42
|
-
"gitCommitId": "
|
|
42
|
+
"gitCommitId": "c939df2"
|
|
43
43
|
}
|