@agentskit/cli 0.13.46 → 0.13.47

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/dist/index.d.cts CHANGED
@@ -4,8 +4,18 @@ import React from 'react';
4
4
  import { ChildProcess } from 'node:child_process';
5
5
  import { RAG } from '@agentskit/rag';
6
6
 
7
+ /**
8
+ * Creates the Commander program and registers the AgentsKit CLI commands.
9
+ * @returns A configured Commander program.
10
+ * @example
11
+ * const program = createCli()
12
+ */
7
13
  declare function createCli(): Command;
8
14
 
15
+ /**
16
+ * Configuration values loaded by the AgentsKit CLI, including defaults and integrations.
17
+
18
+ */
9
19
  interface AgentsKitConfig {
10
20
  tools?: {
11
21
  filesystem?: {
@@ -101,6 +111,10 @@ interface AgentsKitConfig {
101
111
  }>;
102
112
  };
103
113
  }
114
+ /**
115
+ * Path and environment settings used while loading CLI configuration.
116
+
117
+ */
104
118
  interface LoadConfigOptions {
105
119
  cwd?: string;
106
120
  /**
@@ -123,18 +137,38 @@ interface LoadConfigOptions {
123
137
  */
124
138
  declare function loadConfig(options?: LoadConfigOptions): Promise<AgentsKitConfig | undefined>;
125
139
 
140
+ /**
141
+ * Default policy mode used when evaluating tool permissions.
142
+
143
+ */
126
144
  type PermissionMode = 'default' | 'plan' | 'acceptEdits' | 'bypassPermissions';
145
+ /**
146
+ * Action the CLI applies to a tool: allow, ask for confirmation, or deny.
147
+
148
+ */
127
149
  type PermissionAction = 'allow' | 'ask' | 'deny';
150
+ /**
151
+ * Tool matcher, permission action, and optional rule scope.
152
+
153
+ */
128
154
  interface PermissionRule {
129
155
  /** Exact name, or a `RegExp` / `"re:pattern"` string matching the tool name. */
130
156
  tool: string | RegExp;
131
157
  action: PermissionAction;
132
158
  scope?: 'session' | 'project' | 'global';
133
159
  }
160
+ /**
161
+ * Default permission mode and explicit tool rules for a CLI session.
162
+
163
+ */
134
164
  interface PermissionPolicy {
135
165
  mode: PermissionMode;
136
166
  rules: PermissionRule[];
137
167
  }
168
+ /**
169
+ * Default permission policy with ask-on-unmatched behavior.
170
+
171
+ */
138
172
  declare const defaultPolicy: PermissionPolicy;
139
173
  /**
140
174
  * Resolve an action for a tool name. Modes override specific rules:
@@ -203,6 +237,10 @@ interface Plugin {
203
237
  init?: (ctx: PluginContext) => void | Promise<void>;
204
238
  dispose?: () => void | Promise<void>;
205
239
  }
240
+ /**
241
+ * CLI services and project context passed to plugin factories.
242
+
243
+ */
206
244
  interface PluginContext {
207
245
  /** Working directory the CLI was launched from. */
208
246
  cwd: string;
@@ -211,17 +249,33 @@ interface PluginContext {
211
249
  /** Logger. */
212
250
  log: (msg: string) => void;
213
251
  }
252
+ /**
253
+ * Factory that creates an adapter from provider credentials and model settings.
254
+
255
+ */
214
256
  type ProviderFactory = (config: {
215
257
  apiKey?: string;
216
258
  model: string;
217
259
  baseUrl?: string;
218
260
  extra?: Record<string, unknown>;
219
261
  }) => unknown;
262
+ /**
263
+ * Lifecycle event names accepted by plugin hooks.
264
+
265
+ */
220
266
  type HookEvent = 'SessionStart' | 'SessionEnd' | 'UserPromptSubmit' | 'PreLLM' | 'PostLLM' | 'PreToolUse' | 'PostToolUse' | 'Stop' | 'Error';
267
+ /**
268
+ * Lifecycle-specific data passed to plugin hooks.
269
+
270
+ */
221
271
  interface HookPayload {
222
272
  event: HookEvent;
223
273
  [key: string]: unknown;
224
274
  }
275
+ /**
276
+ * Continue, modify, or block decision returned by a hook handler.
277
+
278
+ */
225
279
  type HookResult = {
226
280
  decision: 'continue';
227
281
  } | {
@@ -231,11 +285,19 @@ type HookResult = {
231
285
  decision: 'modify';
232
286
  payload: HookPayload;
233
287
  };
288
+ /**
289
+ * Handler that receives a lifecycle payload and returns a hook decision.
290
+
291
+ */
234
292
  interface HookHandler {
235
293
  event: HookEvent;
236
294
  matcher?: RegExp | ((payload: HookPayload) => boolean);
237
295
  run: (payload: HookPayload) => HookResult | Promise<HookResult>;
238
296
  }
297
+ /**
298
+ * Command, arguments, environment, and name for one MCP server process.
299
+
300
+ */
239
301
  interface McpServerSpec {
240
302
  name: string;
241
303
  command: string;
@@ -256,6 +318,10 @@ interface PluginBundle {
256
318
  mcpServers: McpServerSpec[];
257
319
  }
258
320
 
321
+ /**
322
+ * Plugin specifiers, discovery directories, and callbacks used while loading plugins.
323
+
324
+ */
259
325
  interface LoadPluginsOptions {
260
326
  /** Plugin specifiers: absolute paths, relative paths, or package names. */
261
327
  specs?: string[];
@@ -287,6 +353,10 @@ declare function loadPlugins(options?: LoadPluginsOptions): Promise<PluginBundle
287
353
  */
288
354
  declare function mergePluginsIntoBundle(plugins: Plugin[]): PluginBundle;
289
355
 
356
+ /**
357
+ * Provider, session, tool, memory, plugin, hook, and permission settings for the CLI chat app.
358
+
359
+ */
290
360
  interface ChatCommandOptions {
291
361
  provider: string;
292
362
  model?: string;
@@ -314,15 +384,33 @@ interface ChatCommandOptions {
314
384
  /** Permission policy for tool calls. */
315
385
  permissionPolicy?: PermissionPolicy;
316
386
  }
387
+ /**
388
+ * Interactive Ink chat component configured with provider, session, tools, and plugins.
389
+
390
+ */
317
391
  declare function ChatApp(options: ChatCommandOptions): React.JSX.Element;
392
+ /**
393
+ * Renders a compact provider, model, mode, tool, skill, and memory summary for chat.
394
+ * @param options Chat provider and feature settings.
395
+ * @returns A single-line chat header.
396
+ * @throws {Error} If the requested provider or its required configuration is unsupported.
397
+ */
318
398
  declare function renderChatHeader(options: ChatCommandOptions): string;
319
399
 
320
400
  type Provider = 'openai' | 'anthropic' | 'gemini' | 'ollama' | 'deepseek' | 'grok' | 'kimi' | 'groq' | 'openrouter' | 'demo';
321
401
 
402
+ /**
403
+ * Built-in project template identifier accepted by the init command.
404
+
405
+ */
322
406
  type StarterKind = 'react' | 'nextjs' | 'ink' | 'runtime' | 'multi-agent' | 'sveltekit' | 'nuxt' | 'vite-ink' | 'cloudflare-workers' | 'bun' | 'expo' | 'deno-deploy' | 'angular';
323
407
  type ToolKind = 'web_search' | 'filesystem' | 'shell';
324
408
  type MemoryKind = 'none' | 'file' | 'sqlite';
325
409
  type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'bun';
410
+ /**
411
+ * Destination, starter template, and optional provider, tools, memory, and package-manager settings.
412
+
413
+ */
326
414
  interface InitCommandOptions {
327
415
  targetDir: string;
328
416
  template: StarterKind;
@@ -333,14 +421,30 @@ interface InitCommandOptions {
333
421
  /** Refuse non-empty destinations unless explicitly enabled. */
334
422
  force?: boolean;
335
423
  }
424
+ /**
425
+ * Writes the selected starter template files into a destination directory.
426
+ * @param options Destination and starter-project settings.
427
+ * @returns Relative paths of existing files that were replaced.
428
+ * @throws {Error} If the destination is invalid or a protected path cannot be written.
429
+ * @example
430
+ * await writeStarterProject({ targetDir: './my-agent', template: 'react' })
431
+ */
336
432
  declare function writeStarterProject(options: InitCommandOptions): Promise<string[]>;
337
433
 
434
+ /**
435
+ * Provider identifier and optional model, credentials, or endpoint used to resolve a chat adapter.
436
+
437
+ */
338
438
  interface ChatProviderOptions {
339
439
  provider: string;
340
440
  model?: string;
341
441
  apiKey?: string;
342
442
  baseUrl?: string;
343
443
  }
444
+ /**
445
+ * Resolved adapter together with provider, model, mode, and display summary.
446
+
447
+ */
344
448
  interface ResolvedChatProvider {
345
449
  adapter: AdapterFactory;
346
450
  provider: string;
@@ -348,8 +452,20 @@ interface ResolvedChatProvider {
348
452
  mode: 'demo' | 'live';
349
453
  summary: string;
350
454
  }
455
+ /**
456
+ * Resolves a provider name and credentials to an AgentsKit chat adapter.
457
+ * @param options Provider, model, credential, and endpoint settings.
458
+ * @returns Adapter and resolved provider details.
459
+ * @throws {Error} If the provider is unsupported or required credentials or model are missing.
460
+ * @example
461
+ * const resolved = resolveChatProvider({ provider: 'demo' })
462
+ */
351
463
  declare function resolveChatProvider(options: ChatProviderOptions): ResolvedChatProvider;
352
464
 
465
+ /**
466
+ * Provider and agent runtime options accepted by the CLI run command.
467
+
468
+ */
353
469
  interface RunCommandOptions {
354
470
  provider: string;
355
471
  model?: string;
@@ -366,15 +482,36 @@ interface RunCommandOptions {
366
482
  verbose?: boolean;
367
483
  pretty?: boolean;
368
484
  }
485
+ /**
486
+ * Runs one agent task with the selected provider, tools, skills, and memory.
487
+ * @param task User task to run.
488
+ * @param options Provider and runtime settings.
489
+ * @returns A promise that resolves when the run completes.
490
+ * @throws {Error} If mutually exclusive skill options are both set or provider configuration is invalid.
491
+ * @example
492
+ * await runAgent('Say hello', { provider: 'demo' })
493
+ */
369
494
  declare function runAgent(task: string, options: RunCommandOptions): Promise<void>;
370
495
 
496
+ /**
497
+ * Outcome category returned by an AgentsKit doctor check.
498
+
499
+ */
371
500
  type CheckStatus = 'pass' | 'warn' | 'fail' | 'skip';
501
+ /**
502
+ * Status, description, and optional remediation for one doctor check.
503
+
504
+ */
372
505
  interface CheckResult {
373
506
  status: CheckStatus;
374
507
  name: string;
375
508
  detail?: string;
376
509
  fix?: string;
377
510
  }
511
+ /**
512
+ * Doctor check results and aggregate pass, warning, failure, and skip counts.
513
+
514
+ */
378
515
  interface DoctorReport {
379
516
  results: CheckResult[];
380
517
  pass: number;
@@ -382,6 +519,10 @@ interface DoctorReport {
382
519
  fail: number;
383
520
  skip: number;
384
521
  }
522
+ /**
523
+ * Provider selection and network settings for the environment doctor.
524
+
525
+ */
385
526
  interface DoctorOptions {
386
527
  /** Provider names to check. Defaults to all known providers. */
387
528
  providers?: string[];
@@ -390,11 +531,28 @@ interface DoctorOptions {
390
531
  /** Custom fetch (for tests). */
391
532
  fetchImpl?: typeof fetch;
392
533
  }
534
+ /**
535
+ * Checks the local Node environment, AgentsKit configuration, and selected providers.
536
+ * @param options Provider selection and network-check settings.
537
+ * @returns A report containing each check and aggregate status counts.
538
+ * @example
539
+ * const report = await runDoctor({ noNetwork: true })
540
+ */
393
541
  declare function runDoctor(options?: DoctorOptions): Promise<DoctorReport>;
542
+ /**
543
+ * Formats doctor check results as a terminal-friendly report.
544
+ * @param report Doctor results and aggregate counts.
545
+ * @param opts Optional rendering settings.
546
+ * @returns The formatted report text.
547
+ */
394
548
  declare function renderReport(report: DoctorReport, opts?: {
395
549
  color?: boolean;
396
550
  }): string;
397
551
 
552
+ /**
553
+ * Entry file, watch patterns, and process hooks for the CLI development runner.
554
+
555
+ */
398
556
  interface DevOptions {
399
557
  /** Entry file to run (relative or absolute). */
400
558
  entry: string;
@@ -420,6 +578,10 @@ interface DevOptions {
420
578
  /** Stderr sink for tests. */
421
579
  stderr?: NodeJS.WritableStream;
422
580
  }
581
+ /**
582
+ * File watcher interface consumed by the development runner.
583
+
584
+ */
423
585
  interface DevWatcher {
424
586
  on(event: 'change' | 'add' | 'unlink', listener: (path: string) => void): this;
425
587
  close(): Promise<void>;
@@ -439,8 +601,20 @@ interface DevController {
439
601
  /** Number of times the entry has been (re)started. */
440
602
  restarts: () => number;
441
603
  }
604
+ /**
605
+ * Runs a project entry file and restarts it when watched files change.
606
+ * @param options Entry, watch patterns, and process overrides.
607
+ * @returns A controller for observing and stopping the development session.
608
+ * @throws {Error} If the entry file is missing or the TypeScript runner is unavailable.
609
+ * @example
610
+ * const dev = startDev({ entry: './src/index.ts' })
611
+ */
442
612
  declare function startDev(options: DevOptions): DevController;
443
613
 
614
+ /**
615
+ * Local port and optional host, subdomain, callbacks, and tunnel provider override.
616
+
617
+ */
444
618
  interface TunnelOptions {
445
619
  /** Local port to expose. Required. */
446
620
  port: number;
@@ -459,11 +633,19 @@ interface TunnelOptions {
459
633
  /** Called once the tunnel URL is known. */
460
634
  onReady?: (url: string) => void;
461
635
  }
636
+ /**
637
+ * Tunnel provider handle with its public URL and lifecycle methods.
638
+
639
+ */
462
640
  interface TunnelLike {
463
641
  url: string;
464
642
  on(event: 'request' | 'error' | 'close', listener: (...args: unknown[]) => void): unknown;
465
643
  close(): void;
466
644
  }
645
+ /**
646
+ * Public tunnel URL, completion promise, stop action, and request count.
647
+
648
+ */
467
649
  interface TunnelController {
468
650
  /** The public URL once ready. */
469
651
  url: string;
@@ -484,6 +666,10 @@ interface TunnelController {
484
666
  */
485
667
  declare function startTunnel(options: TunnelOptions): Promise<TunnelController>;
486
668
 
669
+ /**
670
+ * Session identifiers, timestamps, preview, message count, and optional provider labels.
671
+
672
+ */
487
673
  interface SessionMetadata {
488
674
  id: string;
489
675
  cwd: string;
@@ -498,21 +684,53 @@ interface SessionMetadata {
498
684
  /** Session id this one was forked from, if any. */
499
685
  forkedFrom?: string;
500
686
  }
687
+ /**
688
+ * Session metadata paired with its message file path.
689
+
690
+ */
501
691
  interface SessionRecord {
502
692
  metadata: SessionMetadata;
503
693
  file: string;
504
694
  }
505
695
  /** Generate a new session id — ISO-ish timestamp + 6 random hex chars. */
506
696
  declare function generateSessionId(): string;
697
+ /**
698
+ * Returns the message file path for a session and ensures its storage directory exists.
699
+ * @param id Session identifier.
700
+ * @param cwd Working directory used to namespace session storage.
701
+ * @returns The absolute path to the session JSON file.
702
+ */
507
703
  declare function sessionFilePath(id: string, cwd?: string): string;
704
+ /**
705
+ * Writes session metadata to the CLI session store with private file permissions.
706
+ * @param meta Session metadata to persist.
707
+ * @param cwd Working directory used to namespace session storage.
708
+ * @returns Nothing.
709
+ */
508
710
  declare function writeSessionMeta(meta: SessionMetadata, cwd?: string): void;
509
711
  /** Derive a short preview (first user message, one line, max 80 chars). */
510
712
  declare function derivePreview(messages: Array<{
511
713
  role: string;
512
714
  content: string;
513
715
  }>): string;
716
+ /**
717
+ * Lists session records for a working directory, newest first.
718
+ * @param cwd Working directory used to locate sessions.
719
+ * @returns Session records with their metadata and file paths.
720
+ */
514
721
  declare function listSessions(cwd?: string): SessionRecord[];
722
+ /**
723
+ * Returns the most recently updated session for a working directory.
724
+ * @param cwd Working directory used to locate sessions.
725
+ * @returns The newest session record, or `null` when none exists.
726
+ */
515
727
  declare function findLatestSession(cwd?: string): SessionRecord | null;
728
+ /**
729
+ * Finds a session by id, label, or id prefix.
730
+ * @param id Session identifier, label, or unique prefix.
731
+ * @param cwd Working directory used to locate sessions.
732
+ * @returns The matching session record, or `null` when none matches.
733
+ */
516
734
  declare function findSession(id: string, cwd?: string): SessionRecord | null;
517
735
  /** Attach or update a human-readable label on an existing session. */
518
736
  declare function renameSession(id: string, label: string, cwd?: string): SessionMetadata;
@@ -521,12 +739,20 @@ declare function renameSession(id: string, label: string, cwd?: string): Session
521
739
  * can branch a conversation without disturbing the original.
522
740
  */
523
741
  declare function forkSession(id: string, cwd?: string): ResolvedSession;
742
+ /**
743
+ * Explicit file, resume, create-new, and working-directory settings for session resolution.
744
+
745
+ */
524
746
  interface ResolveSessionInput {
525
747
  explicitPath?: string;
526
748
  resumeId?: string | true;
527
749
  forceNew?: boolean;
528
750
  cwd?: string;
529
751
  }
752
+ /**
753
+ * Session identifier, message file path, and whether the session was newly created.
754
+
755
+ */
530
756
  interface ResolvedSession {
531
757
  id: string;
532
758
  file: string;
@@ -543,6 +769,10 @@ interface ResolvedSession {
543
769
  */
544
770
  declare function resolveSession(input: ResolveSessionInput): ResolvedSession;
545
771
 
772
+ /**
773
+ * Tool name and optional description and input schema reported by an MCP server.
774
+
775
+ */
546
776
  interface McpTool {
547
777
  name: string;
548
778
  description?: string;
@@ -573,6 +803,10 @@ declare class McpClient {
573
803
  private onStdout;
574
804
  }
575
805
 
806
+ /**
807
+ * Started MCP clients and the tool definitions bridged from their servers.
808
+
809
+ */
576
810
  interface McpBridgeResult {
577
811
  clients: McpClient[];
578
812
  tools: ToolDefinition[];
@@ -584,6 +818,11 @@ interface McpBridgeResult {
584
818
  * on session end.
585
819
  */
586
820
  declare function bridgeMcpServers(specs: McpServerSpec[]): Promise<McpBridgeResult>;
821
+ /**
822
+ * Disposes every MCP client opened for a CLI session.
823
+ * @param clients MCP clients to stop.
824
+ * @returns Nothing.
825
+ */
587
826
  declare function disposeMcpClients(clients: McpClient[]): void;
588
827
 
589
828
  /**
@@ -596,12 +835,31 @@ interface ModelPricing {
596
835
  inputPerM: number;
597
836
  outputPerM: number;
598
837
  }
838
+ /**
839
+ * Registers or replaces per-million-token prices for a model in this process.
840
+ * @param model Model identifier to register.
841
+ * @param pricing Input and output prices in USD per million tokens.
842
+ * @returns Nothing.
843
+ */
599
844
  declare function registerPricing(model: string, pricing: ModelPricing): void;
845
+ /**
846
+ * Looks up registered model pricing by exact id or provider-prefixed model id.
847
+ * @param model Model identifier to look up.
848
+ * @returns Pricing for the model, or `undefined` when it is unknown.
849
+ */
600
850
  declare function getPricing(model: string | undefined): ModelPricing | undefined;
851
+ /**
852
+ * Prompt and completion token counts used for cost calculation.
853
+
854
+ */
601
855
  interface TokenUsageLike {
602
856
  promptTokens: number;
603
857
  completionTokens: number;
604
858
  }
859
+ /**
860
+ * Estimated input, output, and total cost for one model response.
861
+
862
+ */
605
863
  interface ComputedCost {
606
864
  model: string;
607
865
  inputUsd: number;
@@ -611,6 +869,10 @@ interface ComputedCost {
611
869
  /** Returns computed cost, or `undefined` if no pricing is registered for the model. */
612
870
  declare function computeCost(model: string | undefined, usage: TokenUsageLike): ComputedCost | undefined;
613
871
 
872
+ /**
873
+ * API key and optional model and endpoint for the OpenAI-compatible embedder.
874
+
875
+ */
614
876
  interface OpenAiEmbedderConfig {
615
877
  apiKey: string;
616
878
  model?: string;
@@ -624,6 +886,10 @@ interface OpenAiEmbedderConfig {
624
886
  */
625
887
  declare function createOpenAiEmbedder(config: OpenAiEmbedderConfig): EmbedFn;
626
888
 
889
+ /**
890
+ * Sources, embedder, storage, chunking, and retrieval settings for CLI RAG.
891
+
892
+ */
627
893
  interface RagConfig {
628
894
  enabled?: boolean;
629
895
  backend?: 'memory' | 'file';
@@ -638,12 +904,20 @@ interface RagConfig {
638
904
  chunkSize?: number;
639
905
  topK?: number;
640
906
  }
907
+ /**
908
+ * Configuration and optional embedder used to create a file-backed RAG instance.
909
+
910
+ */
641
911
  interface BuildRagOptions {
642
912
  config: RagConfig;
643
913
  cwd?: string;
644
914
  /** Override the embedder resolution (useful for tests). */
645
915
  embedder?: EmbedFn;
646
916
  }
917
+ /**
918
+ * Count and absolute paths of the files ingested by a RAG index operation.
919
+
920
+ */
647
921
  interface IndexResult {
648
922
  /** Number of input documents ingested. */
649
923
  documentCount: number;
@@ -661,6 +935,10 @@ declare function buildRagFromConfig(options: BuildRagOptions): RAG;
661
935
  */
662
936
  declare function indexSources(rag: RAG, config: RagConfig, cwd?: string): Promise<IndexResult>;
663
937
 
938
+ /**
939
+ * Final hook payload and whether dispatch was blocked.
940
+
941
+ */
664
942
  interface HookDispatchResult {
665
943
  /** Final payload after any `modify` handlers. */
666
944
  payload: HookPayload;
@@ -686,6 +964,10 @@ declare class HookDispatcher {
686
964
  private matches;
687
965
  }
688
966
 
967
+ /**
968
+ * Shell command and optional matcher and timeout for a configured lifecycle hook.
969
+
970
+ */
689
971
  interface ConfigHookEntry {
690
972
  /**
691
973
  * Command to run through the platform shell (`sh -c` on POSIX, `cmd.exe /d /s /c`
@@ -697,6 +979,10 @@ interface ConfigHookEntry {
697
979
  /** Millisecond budget. Default 5000. */
698
980
  timeout?: number;
699
981
  }
982
+ /**
983
+ * Configured shell hooks keyed by lifecycle event.
984
+
985
+ */
700
986
  type ConfigHooksMap = Partial<Record<HookEvent, ConfigHookEntry[]>>;
701
987
  /**
702
988
  * Normalize `config.hooks` (shell entries) into `HookHandler[]`. The shell