agentikit 0.0.9 → 0.0.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.
Files changed (107) hide show
  1. package/README.md +129 -214
  2. package/dist/index.d.ts +8 -2
  3. package/dist/index.js +4 -1
  4. package/dist/src/asset-spec.d.ts +2 -0
  5. package/dist/src/asset-spec.js +22 -3
  6. package/dist/src/asset-type-handler.d.ts +27 -0
  7. package/dist/src/asset-type-handler.js +33 -0
  8. package/dist/src/cli.js +201 -75
  9. package/dist/src/common.d.ts +6 -1
  10. package/dist/src/common.js +18 -4
  11. package/dist/src/config-cli.d.ts +9 -0
  12. package/dist/src/config-cli.js +473 -0
  13. package/dist/src/config.d.ts +19 -6
  14. package/dist/src/config.js +139 -29
  15. package/dist/src/db.d.ts +46 -0
  16. package/dist/src/db.js +299 -0
  17. package/dist/src/embedder.js +12 -7
  18. package/dist/src/github.d.ts +4 -0
  19. package/dist/src/github.js +19 -0
  20. package/dist/src/handlers/agent-handler.d.ts +2 -0
  21. package/dist/src/handlers/agent-handler.js +26 -0
  22. package/dist/src/handlers/command-handler.d.ts +2 -0
  23. package/dist/src/handlers/command-handler.js +23 -0
  24. package/dist/src/handlers/index.d.ts +6 -0
  25. package/dist/src/handlers/index.js +23 -0
  26. package/dist/src/handlers/knowledge-handler.d.ts +2 -0
  27. package/dist/src/handlers/knowledge-handler.js +56 -0
  28. package/dist/src/handlers/markdown-helpers.d.ts +7 -0
  29. package/dist/src/handlers/markdown-helpers.js +15 -0
  30. package/dist/src/handlers/script-handler.d.ts +2 -0
  31. package/dist/src/handlers/script-handler.js +78 -0
  32. package/dist/src/handlers/skill-handler.d.ts +2 -0
  33. package/dist/src/handlers/skill-handler.js +30 -0
  34. package/dist/src/handlers/tool-handler.d.ts +2 -0
  35. package/dist/src/handlers/tool-handler.js +58 -0
  36. package/dist/src/indexer.d.ts +1 -23
  37. package/dist/src/indexer.js +162 -155
  38. package/dist/src/init.d.ts +2 -2
  39. package/dist/src/init.js +21 -9
  40. package/dist/src/llm.js +4 -3
  41. package/dist/src/metadata.d.ts +0 -1
  42. package/dist/src/metadata.js +6 -64
  43. package/dist/src/origin-resolve.d.ts +19 -0
  44. package/dist/src/origin-resolve.js +53 -0
  45. package/dist/src/registry-install.d.ts +2 -2
  46. package/dist/src/registry-install.js +142 -35
  47. package/dist/src/registry-resolve.js +90 -22
  48. package/dist/src/registry-search.d.ts +22 -0
  49. package/dist/src/registry-search.js +231 -97
  50. package/dist/src/registry-types.d.ts +9 -2
  51. package/dist/src/stash-add.js +4 -4
  52. package/dist/src/stash-clone.d.ts +22 -0
  53. package/dist/src/stash-clone.js +83 -0
  54. package/dist/src/stash-ref.d.ts +27 -3
  55. package/dist/src/stash-ref.js +63 -24
  56. package/dist/src/stash-registry.js +12 -12
  57. package/dist/src/stash-resolve.js +3 -0
  58. package/dist/src/stash-search.js +168 -164
  59. package/dist/src/stash-show.d.ts +1 -1
  60. package/dist/src/stash-show.js +28 -96
  61. package/dist/src/stash-source.d.ts +24 -0
  62. package/dist/src/stash-source.js +81 -0
  63. package/dist/src/stash-types.d.ts +14 -4
  64. package/dist/src/stash.d.ts +6 -0
  65. package/dist/src/stash.js +3 -0
  66. package/dist/src/tool-runner.d.ts +1 -1
  67. package/dist/src/tool-runner.js +18 -5
  68. package/package.json +7 -2
  69. package/src/asset-spec.ts +20 -4
  70. package/src/asset-type-handler.ts +77 -0
  71. package/src/cli.ts +213 -82
  72. package/src/common.ts +23 -5
  73. package/src/config-cli.ts +499 -0
  74. package/src/config.ts +160 -38
  75. package/src/db.ts +411 -0
  76. package/src/embedder.ts +22 -11
  77. package/src/github.ts +21 -0
  78. package/src/handlers/agent-handler.ts +32 -0
  79. package/src/handlers/command-handler.ts +29 -0
  80. package/src/handlers/index.ts +25 -0
  81. package/src/handlers/knowledge-handler.ts +62 -0
  82. package/src/handlers/markdown-helpers.ts +19 -0
  83. package/src/handlers/script-handler.ts +92 -0
  84. package/src/handlers/skill-handler.ts +37 -0
  85. package/src/handlers/tool-handler.ts +71 -0
  86. package/src/indexer.ts +208 -187
  87. package/src/init.ts +17 -9
  88. package/src/llm.ts +4 -3
  89. package/src/metadata.ts +5 -65
  90. package/src/origin-resolve.ts +67 -0
  91. package/src/registry-install.ts +158 -42
  92. package/src/registry-resolve.ts +92 -23
  93. package/src/registry-search.ts +288 -98
  94. package/src/registry-types.ts +10 -2
  95. package/src/stash-add.ts +14 -17
  96. package/src/stash-clone.ts +127 -0
  97. package/src/stash-ref.ts +84 -26
  98. package/src/stash-registry.ts +12 -12
  99. package/src/stash-resolve.ts +3 -0
  100. package/src/stash-search.ts +202 -184
  101. package/src/stash-show.ts +33 -90
  102. package/src/stash-source.ts +103 -0
  103. package/src/stash-types.ts +14 -4
  104. package/src/stash.ts +8 -0
  105. package/src/tool-runner.ts +18 -5
  106. package/dist/src/similarity.d.ts +0 -34
  107. package/src/similarity.ts +0 -271
package/dist/src/cli.js CHANGED
@@ -3,13 +3,15 @@ import { defineCommand, runMain } from "citty";
3
3
  import { agentikitAdd, agentikitList, agentikitReinstall, agentikitRemove, agentikitSearch, agentikitShow, agentikitUpdate, } from "./stash";
4
4
  import { agentikitInit } from "./init";
5
5
  import { agentikitIndex } from "./indexer";
6
- import { loadConfig, updateConfig } from "./config";
7
- import { resolveStashDir } from "./common";
6
+ import { agentikitClone } from "./stash-clone";
7
+ import { resolveStashSources } from "./stash-source";
8
+ import { loadConfig, saveConfig } from "./config";
9
+ import { getConfigValue, listConfig, listProviders, parseConfigValue, setConfigValue, unsetConfigValue, useProvider, } from "./config-cli";
8
10
  const initCommand = defineCommand({
9
- meta: { name: "init", description: "Initialize agentikit stash directory and set AGENTIKIT_STASH_DIR" },
10
- run() {
11
- return runWithJsonErrors(() => {
12
- const result = agentikitInit();
11
+ meta: { name: "init", description: "Initialize Agent-i-Kit's working stash directory and set AKM_STASH_DIR" },
12
+ async run() {
13
+ await runWithJsonErrors(async () => {
14
+ const result = await agentikitInit();
13
15
  console.log(JSON.stringify(result, null, 2));
14
16
  });
15
17
  },
@@ -30,7 +32,7 @@ const searchCommand = defineCommand({
30
32
  meta: { name: "search", description: "Search the stash" },
31
33
  args: {
32
34
  query: { type: "positional", description: "Search query", required: false, default: "" },
33
- type: { type: "string", description: "Asset type filter (tool|skill|command|agent|knowledge|any)" },
35
+ type: { type: "string", description: "Asset type filter (tool|skill|command|agent|knowledge|script|any)" },
34
36
  limit: { type: "string", description: "Maximum number of results" },
35
37
  usage: { type: "string", description: "Usage metadata mode (none|both|item|guide)", default: "both" },
36
38
  source: { type: "string", description: "Search source (local|registry|both)", default: "local" },
@@ -46,9 +48,13 @@ const searchCommand = defineCommand({
46
48
  },
47
49
  });
48
50
  const addCommand = defineCommand({
49
- meta: { name: "add", description: "Install a registry package into the stash" },
51
+ meta: { name: "add", description: "Install a registry package or local git directory into the stash" },
50
52
  args: {
51
- ref: { type: "positional", description: "Registry ref (npm package, owner/repo, or github URL)", required: true },
53
+ ref: {
54
+ type: "positional",
55
+ description: "Registry ref (npm package, owner/repo, github URL, or local git directory)",
56
+ required: true,
57
+ },
52
58
  },
53
59
  async run({ args }) {
54
60
  await runWithJsonErrors(async () => {
@@ -108,8 +114,8 @@ const showCommand = defineCommand({
108
114
  start: { type: "string", description: "Start line (for --view lines)" },
109
115
  end: { type: "string", description: "End line (for --view lines)" },
110
116
  },
111
- run({ args }) {
112
- return runWithJsonErrors(() => {
117
+ async run({ args }) {
118
+ await runWithJsonErrors(async () => {
113
119
  let view;
114
120
  if (args.view) {
115
121
  switch (args.view) {
@@ -132,18 +138,111 @@ const showCommand = defineCommand({
132
138
  throw new Error(`Unknown view mode: ${args.view}. Expected one of: full|toc|frontmatter|section|lines`);
133
139
  }
134
140
  }
135
- console.log(JSON.stringify(agentikitShow({ ref: args.ref, view }), null, 2));
141
+ console.log(JSON.stringify(await agentikitShow({ ref: args.ref, view }), null, 2));
136
142
  });
137
143
  },
138
144
  });
139
145
  const configCommand = defineCommand({
140
- meta: { name: "config", description: "Show or update configuration" },
146
+ meta: { name: "config", description: "Show configuration, get/set keys, and manage embedding/LLM providers" },
141
147
  args: {
142
- set: { type: "string", description: "Update a config key (key=value format)" },
148
+ list: { type: "boolean", description: "List current configuration with effective defaults", default: false },
149
+ get: { type: "string", description: "Get a configuration value by key" },
150
+ unset: { type: "string", description: "Unset an optional configuration key or whole embedding/llm section" },
151
+ set: { type: "string", description: "Back-compat alias for updating a key (key=value format)" },
152
+ },
153
+ subCommands: {
154
+ list: defineCommand({
155
+ meta: { name: "list", description: "List current configuration with effective embedding/LLM settings" },
156
+ run() {
157
+ return runWithJsonErrors(() => {
158
+ console.log(JSON.stringify(listConfig(loadConfig()), null, 2));
159
+ });
160
+ },
161
+ }),
162
+ get: defineCommand({
163
+ meta: { name: "get", description: "Get a configuration value by key" },
164
+ args: {
165
+ key: { type: "positional", required: true, description: "Config key (for example: embedding.provider)" },
166
+ },
167
+ run({ args }) {
168
+ return runWithJsonErrors(() => {
169
+ console.log(JSON.stringify(getConfigValue(loadConfig(), args.key), null, 2));
170
+ });
171
+ },
172
+ }),
173
+ set: defineCommand({
174
+ meta: { name: "set", description: "Set a configuration value by key" },
175
+ args: {
176
+ key: { type: "positional", required: true, description: "Config key (for example: llm.temperature)" },
177
+ value: { type: "positional", required: true, description: "Config value" },
178
+ },
179
+ run({ args }) {
180
+ return runWithJsonErrors(() => {
181
+ const updated = setConfigValue(loadConfig(), args.key, args.value);
182
+ saveConfig(updated);
183
+ console.log(JSON.stringify(listConfig(updated), null, 2));
184
+ });
185
+ },
186
+ }),
187
+ unset: defineCommand({
188
+ meta: { name: "unset", description: "Unset an optional configuration key or whole embedding/llm section" },
189
+ args: {
190
+ key: { type: "positional", required: true, description: "Config key to unset" },
191
+ },
192
+ run({ args }) {
193
+ return runWithJsonErrors(() => {
194
+ const updated = unsetConfigValue(loadConfig(), args.key);
195
+ saveConfig(updated);
196
+ console.log(JSON.stringify(listConfig(updated), null, 2));
197
+ });
198
+ },
199
+ }),
200
+ providers: defineCommand({
201
+ meta: { name: "providers", description: "List available embedding or LLM providers" },
202
+ args: {
203
+ scope: { type: "positional", required: true, description: "Provider scope: embedding or llm" },
204
+ },
205
+ run({ args }) {
206
+ return runWithJsonErrors(() => {
207
+ const scope = parseProviderScope(args.scope);
208
+ console.log(JSON.stringify(listProviders(scope, loadConfig()), null, 2));
209
+ });
210
+ },
211
+ }),
212
+ use: defineCommand({
213
+ meta: { name: "use", description: "Switch the default embedding or LLM provider" },
214
+ args: {
215
+ scope: { type: "positional", required: true, description: "Provider scope: embedding or llm" },
216
+ provider: { type: "positional", required: true, description: "Provider name" },
217
+ },
218
+ run({ args }) {
219
+ return runWithJsonErrors(() => {
220
+ const scope = parseProviderScope(args.scope);
221
+ const updated = useProvider(loadConfig(), scope, args.provider);
222
+ saveConfig(updated);
223
+ console.log(JSON.stringify(listConfig(updated), null, 2));
224
+ });
225
+ },
226
+ }),
143
227
  },
144
228
  run({ args }) {
145
229
  return runWithJsonErrors(() => {
146
- const stashDir = resolveStashDir();
230
+ if (hasConfigSubcommand(args))
231
+ return;
232
+ if (args.list) {
233
+ console.log(JSON.stringify(listConfig(loadConfig()), null, 2));
234
+ return;
235
+ }
236
+ if (args.get) {
237
+ console.log(JSON.stringify(getConfigValue(loadConfig(), args.get), null, 2));
238
+ return;
239
+ }
240
+ if (args.unset) {
241
+ const updated = unsetConfigValue(loadConfig(), args.unset);
242
+ saveConfig(updated);
243
+ console.log(JSON.stringify(listConfig(updated), null, 2));
244
+ return;
245
+ }
147
246
  if (args.set) {
148
247
  const eqIndex = args.set.indexOf("=");
149
248
  if (eqIndex === -1) {
@@ -152,20 +251,47 @@ const configCommand = defineCommand({
152
251
  const key = args.set.slice(0, eqIndex);
153
252
  const value = args.set.slice(eqIndex + 1);
154
253
  const partial = parseConfigValue(key, value);
155
- const config = updateConfig(partial, stashDir);
156
- console.log(JSON.stringify(config, null, 2));
254
+ const config = { ...loadConfig(), ...partial };
255
+ saveConfig(config);
256
+ console.log(JSON.stringify(listConfig(config), null, 2));
157
257
  }
158
258
  else {
159
- const config = loadConfig(stashDir);
160
- console.log(JSON.stringify(config, null, 2));
259
+ console.log(JSON.stringify(listConfig(loadConfig()), null, 2));
161
260
  }
162
261
  });
163
262
  },
164
263
  });
264
+ const cloneCommand = defineCommand({
265
+ meta: { name: "clone", description: "Clone an asset from any stash source into the working stash" },
266
+ args: {
267
+ ref: { type: "positional", description: "Asset ref (e.g. @installed:pkg/tool:script.sh)", required: true },
268
+ name: { type: "string", description: "New name for the cloned asset" },
269
+ force: { type: "boolean", description: "Overwrite if asset already exists in working stash", default: false },
270
+ },
271
+ async run({ args }) {
272
+ await runWithJsonErrors(async () => {
273
+ const result = await agentikitClone({
274
+ sourceRef: args.ref,
275
+ newName: args.name,
276
+ force: args.force,
277
+ });
278
+ console.log(JSON.stringify(result, null, 2));
279
+ });
280
+ },
281
+ });
282
+ const sourcesCommand = defineCommand({
283
+ meta: { name: "sources", description: "List all stash sources with their kind, path, and status" },
284
+ run() {
285
+ return runWithJsonErrors(() => {
286
+ const sources = resolveStashSources();
287
+ console.log(JSON.stringify({ sources }, null, 2));
288
+ });
289
+ },
290
+ });
165
291
  const main = defineCommand({
166
292
  meta: {
167
293
  name: "akm",
168
- description: "CLI tool to search, open, and run extension assets from an agentikit stash directory.",
294
+ description: "CLI tool to search, open, and manage assets from Agent-i-Kit stash.",
169
295
  },
170
296
  subCommands: {
171
297
  init: initCommand,
@@ -177,12 +303,18 @@ const main = defineCommand({
177
303
  reinstall: reinstallCommand,
178
304
  search: searchCommand,
179
305
  show: showCommand,
306
+ clone: cloneCommand,
307
+ sources: sourcesCommand,
180
308
  config: configCommand,
181
309
  },
182
310
  });
183
- runMain(main);
184
311
  const SEARCH_USAGE_MODES = ["none", "both", "item", "guide"];
185
312
  const SEARCH_SOURCES = ["local", "registry", "both"];
313
+ const CONFIG_SUBCOMMAND_SET = new Set(["list", "get", "set", "unset", "providers", "use"]);
314
+ // Note: citty reads process.argv directly, so we must normalize it in-place.
315
+ // This is done once at startup before runMain.
316
+ normalizeConfigArgv(process.argv);
317
+ runMain(main);
186
318
  function parseSearchUsageMode(value) {
187
319
  if (SEARCH_USAGE_MODES.includes(value))
188
320
  return value;
@@ -193,58 +325,6 @@ function parseSearchSource(value) {
193
325
  return value;
194
326
  throw new Error(`Invalid value for --source: ${value}. Expected one of: ${SEARCH_SOURCES.join("|")}`);
195
327
  }
196
- function parseConnectionValue(key, value, exampleEndpoint, exampleModel) {
197
- if (value === "null" || value === "")
198
- return undefined;
199
- let parsed;
200
- try {
201
- parsed = JSON.parse(value);
202
- }
203
- catch {
204
- throw new Error(`Invalid value for ${key}: expected JSON object with endpoint and model`
205
- + ` (e.g. '{"endpoint":"${exampleEndpoint}","model":"${exampleModel}"}')`);
206
- }
207
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
208
- throw new Error(`Invalid value for ${key}: expected a JSON object`);
209
- }
210
- const obj = parsed;
211
- if (typeof obj.endpoint !== "string" || !obj.endpoint || typeof obj.model !== "string" || !obj.model) {
212
- throw new Error(`Invalid value for ${key}: "endpoint" and "model" are required string fields`);
213
- }
214
- const result = {
215
- endpoint: obj.endpoint,
216
- model: obj.model,
217
- };
218
- if (typeof obj.apiKey === "string" && obj.apiKey) {
219
- result.apiKey = obj.apiKey;
220
- }
221
- return result;
222
- }
223
- function parseConfigValue(key, value) {
224
- switch (key) {
225
- case "semanticSearch":
226
- if (value !== "true" && value !== "false") {
227
- throw new Error(`Invalid value for semanticSearch: expected "true" or "false"`);
228
- }
229
- return { semanticSearch: value === "true" };
230
- case "additionalStashDirs":
231
- try {
232
- const parsed = JSON.parse(value);
233
- if (!Array.isArray(parsed))
234
- throw new Error("expected JSON array");
235
- return { additionalStashDirs: parsed.filter((d) => typeof d === "string") };
236
- }
237
- catch {
238
- throw new Error(`Invalid value for additionalStashDirs: expected JSON array (e.g. '["/path/a","/path/b"]')`);
239
- }
240
- case "embedding":
241
- return { embedding: parseConnectionValue("embedding", value, "http://localhost:11434/v1/embeddings", "nomic-embed-text") };
242
- case "llm":
243
- return { llm: parseConnectionValue("llm", value, "http://localhost:11434/v1/chat/completions", "llama3.2") };
244
- default:
245
- throw new Error(`Unknown config key: ${key}`);
246
- }
247
- }
248
328
  async function runWithJsonErrors(fn) {
249
329
  try {
250
330
  await fn();
@@ -257,8 +337,8 @@ async function runWithJsonErrors(fn) {
257
337
  }
258
338
  }
259
339
  function buildHint(message) {
260
- if (message.includes("AGENTIKIT_STASH_DIR"))
261
- return "Run `akm init` or set AGENTIKIT_STASH_DIR to a valid directory.";
340
+ if (message.includes("AKM_STASH_DIR"))
341
+ return "Run `akm init` or set AKM_STASH_DIR to a valid directory.";
262
342
  if (message.includes("Either <target> or --all is required"))
263
343
  return "Use `akm update --all` or pass a target like `akm update npm:@scope/pkg`.";
264
344
  if (message.includes("Specify either <target> or --all"))
@@ -269,5 +349,51 @@ function buildHint(message) {
269
349
  return "Pick one of: local, registry, both.";
270
350
  if (message.includes("Invalid value for --usage"))
271
351
  return "Pick one of: none, both, item, guide.";
352
+ if (message.includes("expected JSON object with endpoint and model")) {
353
+ return "Quote JSON values in your shell, for example: akm config set embedding '{\"endpoint\":\"http://localhost:11434/v1/embeddings\",\"model\":\"nomic-embed-text\"}'.";
354
+ }
272
355
  return undefined;
273
356
  }
357
+ function parseProviderScope(value) {
358
+ if (value === "embedding" || value === "llm")
359
+ return value;
360
+ throw new Error(`Invalid provider scope: ${value}. Expected one of: embedding|llm`);
361
+ }
362
+ function hasConfigSubcommand(args) {
363
+ const command = Array.isArray(args._) ? args._[0] : undefined;
364
+ return typeof command === "string" && CONFIG_SUBCOMMAND_SET.has(command);
365
+ }
366
+ /**
367
+ * Mutate argv before citty parses it so git-style config forms like
368
+ * `akm config llm.maxTokens 512` and `akm config --get llm.maxTokens`
369
+ * are normalized into the existing config subcommands.
370
+ */
371
+ function normalizeConfigArgv(argv) {
372
+ const [, , command, argAfterCommand, argAfterKey, ...rest] = argv;
373
+ if (command !== "config")
374
+ return;
375
+ if (!argAfterCommand)
376
+ return;
377
+ if (argAfterCommand === "--list") {
378
+ argv.splice(3, argv.length - 3, "list");
379
+ return;
380
+ }
381
+ if (argAfterCommand === "--get" && argAfterKey) {
382
+ argv.splice(3, argv.length - 3, "get", argAfterKey, ...rest);
383
+ return;
384
+ }
385
+ if (argAfterCommand === "--unset" && argAfterKey) {
386
+ argv.splice(3, argv.length - 3, "unset", argAfterKey, ...rest);
387
+ return;
388
+ }
389
+ if (argAfterCommand.startsWith("-"))
390
+ return;
391
+ if (CONFIG_SUBCOMMAND_SET.has(argAfterCommand))
392
+ return;
393
+ // A single arg after `config` behaves like `git config <key>` and reads the value.
394
+ if (argAfterKey === undefined) {
395
+ argv.splice(3, argv.length - 3, "get", argAfterCommand);
396
+ return;
397
+ }
398
+ argv.splice(3, argv.length - 3, "set", argAfterCommand, argAfterKey, ...rest);
399
+ }
@@ -1,4 +1,4 @@
1
- export type AgentikitAssetType = "tool" | "skill" | "command" | "agent" | "knowledge";
1
+ export type AgentikitAssetType = "tool" | "skill" | "command" | "agent" | "knowledge" | "script";
2
2
  export declare const IS_WINDOWS: boolean;
3
3
  export { SCRIPT_EXTENSIONS, TYPE_DIRS } from "./asset-spec";
4
4
  export declare function isAssetType(type: string): type is AgentikitAssetType;
@@ -6,3 +6,8 @@ export declare function resolveStashDir(): string;
6
6
  export declare function toPosix(input: string): string;
7
7
  export declare function hasErrnoCode(error: unknown, code: string): boolean;
8
8
  export declare function isWithin(candidate: string, root: string): boolean;
9
+ /**
10
+ * Fetch with an AbortController timeout.
11
+ * Defaults to 30 seconds if no timeout is specified.
12
+ */
13
+ export declare function fetchWithTimeout(url: string, opts?: RequestInit, timeoutMs?: number): Promise<Response>;
@@ -10,9 +10,9 @@ export function isAssetType(type) {
10
10
  }
11
11
  // ── Utilities ───────────────────────────────────────────────────────────────
12
12
  export function resolveStashDir() {
13
- const raw = process.env.AGENTIKIT_STASH_DIR?.trim();
13
+ const raw = process.env.AKM_STASH_DIR?.trim();
14
14
  if (!raw) {
15
- throw new Error("AGENTIKIT_STASH_DIR is not set. Set it to your Agentikit stash path.");
15
+ throw new Error("AKM_STASH_DIR is not set. Set it to your Agentikit stash path.");
16
16
  }
17
17
  const stashDir = path.resolve(raw);
18
18
  let stat;
@@ -20,10 +20,10 @@ export function resolveStashDir() {
20
20
  stat = fs.statSync(stashDir);
21
21
  }
22
22
  catch {
23
- throw new Error(`Unable to read AGENTIKIT_STASH_DIR at "${stashDir}".`);
23
+ throw new Error(`Unable to read AKM_STASH_DIR at "${stashDir}".`);
24
24
  }
25
25
  if (!stat.isDirectory()) {
26
- throw new Error(`AGENTIKIT_STASH_DIR must point to a directory: "${stashDir}".`);
26
+ throw new Error(`AKM_STASH_DIR must point to a directory: "${stashDir}".`);
27
27
  }
28
28
  return stashDir;
29
29
  }
@@ -44,3 +44,17 @@ export function isWithin(candidate, root) {
44
44
  function normalizeFsPathForComparison(value) {
45
45
  return process.platform === "win32" ? value.toLowerCase() : value;
46
46
  }
47
+ /**
48
+ * Fetch with an AbortController timeout.
49
+ * Defaults to 30 seconds if no timeout is specified.
50
+ */
51
+ export async function fetchWithTimeout(url, opts, timeoutMs = 30_000) {
52
+ const controller = new AbortController();
53
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
54
+ try {
55
+ return await fetch(url, { ...opts, signal: controller.signal });
56
+ }
57
+ finally {
58
+ clearTimeout(timer);
59
+ }
60
+ }
@@ -0,0 +1,9 @@
1
+ import { type AgentikitConfig } from "./config";
2
+ export type ConfigProviderScope = "embedding" | "llm";
3
+ export declare function parseConfigValue(key: string, value: string): Partial<AgentikitConfig>;
4
+ export declare function getConfigValue(config: AgentikitConfig, key: string): unknown;
5
+ export declare function setConfigValue(config: AgentikitConfig, key: string, rawValue: string): AgentikitConfig;
6
+ export declare function unsetConfigValue(config: AgentikitConfig, key: string): AgentikitConfig;
7
+ export declare function listConfig(config: AgentikitConfig): Record<string, unknown>;
8
+ export declare function listProviders(scope: ConfigProviderScope, config: AgentikitConfig): Array<Record<string, unknown>>;
9
+ export declare function useProvider(config: AgentikitConfig, scope: ConfigProviderScope, providerName: string): AgentikitConfig;