@agentier/core 0.1.0

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.
@@ -0,0 +1,27 @@
1
+ import type { Agent, AgentConfig } from './types';
2
+ /**
3
+ * Creates a new agent instance with the given configuration.
4
+ *
5
+ * The returned agent exposes a `run()` method for executing prompts through
6
+ * the configured model and tools, and a `getConfig()` method for inspecting
7
+ * the (frozen) configuration.
8
+ *
9
+ * @param config - The agent configuration including model, provider, tools, and limits.
10
+ * @returns An {@link Agent} instance.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { createAgent, defineTool } from '@agenti/core'
15
+ *
16
+ * const agent = createAgent({
17
+ * model: 'gpt-4o',
18
+ * provider: myProvider,
19
+ * systemPrompt: 'You are a helpful assistant.',
20
+ * tools: [searchTool],
21
+ * })
22
+ *
23
+ * const result = await agent.run('Find the latest news about AI.')
24
+ * console.log(result.output)
25
+ * ```
26
+ */
27
+ export declare function createAgent(config: AgentConfig): Agent;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Discriminated error codes used by {@link AgentError} to identify the cause of failure.
3
+ *
4
+ * - `'MAX_ITERATIONS_EXCEEDED'` - The agent loop hit the maximum iteration count.
5
+ * - `'MAX_TOKENS_EXCEEDED'` - The total token budget was exhausted.
6
+ * - `'TIMEOUT'` - The run exceeded the configured wall-clock timeout.
7
+ * - `'ABORTED'` - The run was cancelled via an external abort signal.
8
+ * - `'MODEL_ERROR'` - The model provider returned an error.
9
+ * - `'TOOL_VALIDATION_ERROR'` - Tool arguments failed schema validation.
10
+ * - `'TOOL_EXECUTION_ERROR'` - A tool threw an error during execution.
11
+ * - `'OUTPUT_PARSE_ERROR'` - The model's output could not be parsed as structured data.
12
+ * - `'PROVIDER_ERROR'` - A generic provider-level error (e.g. stream ended unexpectedly).
13
+ */
14
+ export type AgentErrorCode = 'MAX_ITERATIONS_EXCEEDED' | 'MAX_TOKENS_EXCEEDED' | 'TIMEOUT' | 'ABORTED' | 'MODEL_ERROR' | 'TOOL_VALIDATION_ERROR' | 'TOOL_EXECUTION_ERROR' | 'OUTPUT_PARSE_ERROR' | 'PROVIDER_ERROR';
15
+ /**
16
+ * Custom error class for all agent-related failures.
17
+ * Extends the built-in `Error` with a machine-readable {@link code},
18
+ * an optional {@link cause} error, and optional {@link context} metadata.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * try {
23
+ * await agent.run('...')
24
+ * } catch (err) {
25
+ * if (err instanceof AgentError && err.code === 'TIMEOUT') {
26
+ * console.log('Agent timed out')
27
+ * }
28
+ * }
29
+ * ```
30
+ */
31
+ export declare class AgentError extends Error {
32
+ readonly code: AgentErrorCode;
33
+ readonly cause?: Error | undefined;
34
+ readonly context?: Record<string, unknown> | undefined;
35
+ /**
36
+ * Creates a new AgentError.
37
+ *
38
+ * @param message - A human-readable description of the error.
39
+ * @param code - A machine-readable error code identifying the failure type.
40
+ * @param cause - The underlying error that caused this failure, if any.
41
+ * @param context - Additional metadata about the error context (e.g. tool name, iteration count).
42
+ */
43
+ constructor(message: string, code: AgentErrorCode, cause?: Error | undefined, context?: Record<string, unknown> | undefined);
44
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `@agenti/core` - The core agent framework for building LLM-powered agents with tool use.
3
+ *
4
+ * This package provides the foundational primitives for creating agents that
5
+ * can reason, invoke tools, and maintain conversation state:
6
+ *
7
+ * - {@link createAgent} - Factory function for creating agent instances.
8
+ * - {@link defineTool} - Helper for defining type-safe tools with Zod or JSON Schema.
9
+ * - {@link AgentError} - Structured error class for agent failures.
10
+ *
11
+ * @module @agenti/core
12
+ */
13
+ export { createAgent } from './agent';
14
+ export { defineTool } from './tool';
15
+ export { AgentError } from './errors';
16
+ export type { AgentErrorCode } from './errors';
17
+ export type { Role, ToolCall, Message, ToolContext, JsonSchema, ToolJsonSchema, Tool, ChatParams, ModelResponse, StreamEvent, ModelProvider, AgentActionType, ActionPayloadMap, AgentAction, Middleware, MemoryProvider, AgentConfig, ExecutedToolCall, UsageStats, AgentResult, RunOptions, Agent, } from './types';