@agi-cli/sdk 0.1.165 → 0.1.166

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agi-cli/sdk",
3
- "version": "0.1.165",
3
+ "version": "0.1.166",
4
4
  "description": "AI agent SDK for building intelligent assistants - tree-shakable and comprehensive",
5
5
  "author": "nitishxyz",
6
6
  "license": "MIT",
@@ -7,29 +7,15 @@ import {
7
7
  } from './paths.ts';
8
8
  import type { AGIConfig } from '../../types/src/index.ts';
9
9
 
10
- export type { ProviderConfig, AGIConfig } from '../../types/src/index.ts';
10
+ export type { AGIConfig } from '../../types/src/index.ts';
11
11
 
12
- const DEFAULTS: {
13
- defaults: AGIConfig['defaults'];
14
- providers: AGIConfig['providers'];
15
- } = {
12
+ const DEFAULTS: { defaults: AGIConfig['defaults'] } = {
16
13
  defaults: {
17
14
  agent: 'build',
18
- provider: 'openai',
19
- model: 'gpt-4o-mini',
15
+ provider: 'setu',
16
+ model: 'kimi-k2.5',
20
17
  toolApproval: 'auto',
21
18
  },
22
- providers: {
23
- openai: { enabled: true },
24
- anthropic: { enabled: true },
25
- google: { enabled: true },
26
- openrouter: { enabled: false },
27
- opencode: { enabled: false },
28
- setu: { enabled: false },
29
- zai: { enabled: false },
30
- 'zai-coding': { enabled: false },
31
- moonshot: { enabled: false },
32
- },
33
19
  };
34
20
 
35
21
  export async function loadConfig(
@@ -54,7 +40,6 @@ export async function loadConfig(
54
40
  return {
55
41
  projectRoot,
56
42
  defaults: merged.defaults as AGIConfig['defaults'],
57
- providers: merged.providers as AGIConfig['providers'],
58
43
  paths: {
59
44
  dataDir,
60
45
  dbPath,
@@ -6,7 +6,12 @@ import {
6
6
  type ProviderId,
7
7
  type AuthInfo,
8
8
  } from '../../auth/src/index.ts';
9
- import { getGlobalConfigDir, getGlobalConfigPath } from './paths.ts';
9
+ import {
10
+ getGlobalConfigDir,
11
+ getGlobalConfigPath,
12
+ getLocalDataDir,
13
+ joinPath,
14
+ } from './paths.ts';
10
15
  import {
11
16
  providerIds,
12
17
  readEnvKey,
@@ -62,35 +67,60 @@ export async function writeDefaults(
62
67
  }>,
63
68
  projectRoot?: string,
64
69
  ) {
65
- const { cfg } = await read(projectRoot);
70
+ const root = projectRoot ? String(projectRoot) : process.cwd();
71
+
66
72
  if (scope === 'local') {
73
+ const localDir = getLocalDataDir(root);
74
+ const localPath = joinPath(localDir, 'config.json');
75
+ const existing = await readJsonFile(localPath);
76
+ const prevDefaults =
77
+ existing && typeof existing.defaults === 'object'
78
+ ? (existing.defaults as Record<string, unknown>)
79
+ : {};
67
80
  const next = {
68
- defaults: {
69
- ...cfg.defaults,
70
- ...updates,
71
- provider: (updates.provider ?? cfg.defaults.provider) as ProviderId,
72
- },
73
- providers: cfg.providers,
81
+ ...existing,
82
+ defaults: { ...prevDefaults, ...updates },
74
83
  };
75
- const path = `${cfg.paths.dataDir}/config.json`;
76
- await Bun.write(path, JSON.stringify(next, null, 2));
84
+ try {
85
+ const { promises: fs } = await import('node:fs');
86
+ await fs.mkdir(localDir, { recursive: true }).catch(() => {});
87
+ } catch {}
88
+ await Bun.write(localPath, JSON.stringify(next, null, 2));
77
89
  return;
78
90
  }
79
- const base = getGlobalConfigDir();
80
- const path = getGlobalConfigPath();
91
+
92
+ const globalPath = getGlobalConfigPath();
93
+ const existing = await readJsonFile(globalPath);
94
+ const prevDefaults =
95
+ existing && typeof existing.defaults === 'object'
96
+ ? (existing.defaults as Record<string, unknown>)
97
+ : {};
81
98
  const next = {
82
- defaults: {
83
- ...cfg.defaults,
84
- ...updates,
85
- provider: (updates.provider ?? cfg.defaults.provider) as ProviderId,
86
- },
87
- providers: cfg.providers,
99
+ ...existing,
100
+ defaults: { ...prevDefaults, ...updates },
88
101
  };
102
+ const base = getGlobalConfigDir();
89
103
  try {
90
104
  const { promises: fs } = await import('node:fs');
91
105
  await fs.mkdir(base, { recursive: true }).catch(() => {});
92
106
  } catch {}
93
- await Bun.write(path, JSON.stringify(next, null, 2));
107
+ await Bun.write(globalPath, JSON.stringify(next, null, 2));
108
+ }
109
+
110
+ async function readJsonFile(
111
+ filePath: string,
112
+ ): Promise<Record<string, unknown> | undefined> {
113
+ const f = Bun.file(filePath);
114
+ if (!(await f.exists())) return undefined;
115
+ try {
116
+ const parsed = await f.json();
117
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
118
+ return parsed as Record<string, unknown>;
119
+ }
120
+ return undefined;
121
+ } catch {
122
+ return undefined;
123
+ }
94
124
  }
95
125
 
96
126
  export async function writeAuth(
package/src/index.ts CHANGED
@@ -25,7 +25,6 @@ export type { ApiAuth, OAuth, AuthInfo, AuthFile } from './types/src/index.ts';
25
25
 
26
26
  // Config types
27
27
  export type {
28
- ProviderConfig,
29
28
  DefaultConfig,
30
29
  PathConfig,
31
30
  AGIConfig,
@@ -1,15 +1,8 @@
1
- import type { ProviderId } from './provider';
2
-
3
1
  /**
4
2
  * Configuration scope - where settings are stored
5
3
  */
6
4
  export type Scope = 'global' | 'local';
7
5
 
8
- /**
9
- * Provider-specific configuration
10
- */
11
- export type ProviderConfig = { enabled: boolean; apiKey?: string };
12
-
13
6
  /**
14
7
  * Default settings for the CLI
15
8
  */
@@ -38,7 +31,6 @@ export type PathConfig = {
38
31
  export type AGIConfig = {
39
32
  projectRoot: string;
40
33
  defaults: DefaultConfig;
41
- providers: Record<ProviderId, ProviderConfig>;
42
34
  paths: PathConfig;
43
35
  onboardingComplete?: boolean;
44
36
  };
@@ -12,7 +12,6 @@ export type { ApiAuth, OAuth, AuthInfo, AuthFile } from './auth';
12
12
  // Config types
13
13
  export type {
14
14
  Scope,
15
- ProviderConfig,
16
15
  DefaultConfig,
17
16
  PathConfig,
18
17
  AGIConfig,