@opperai/agents 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -8,54 +8,30 @@ Type‑safe, composable agents for Opper AI in TypeScript using: generics, Zod s
8
8
  - Hooks for observability and custom behavior
9
9
  - Tools: function, decorator, MCP provider, or other agents via `.asTool()`
10
10
 
11
- ## Install
12
-
13
- Prerequisites: Node.js 20+ and pnpm (recommended).
14
-
15
- ```bash
16
- pnpm add @opperai/agents zod
17
- ```
18
-
19
- Set your Opper key:
11
+ ## Installation
20
12
 
21
13
  ```bash
22
- export OPPER_API_KEY="<your-key>"
14
+ npm install @opperai/agents
15
+ # or
16
+ yarn add @opperai/agents
17
+ # or
18
+ pnpm add @opperai/agents
23
19
  ```
24
20
 
25
- ## Use Locally
21
+ **Prerequisites:** Node.js 20+
26
22
 
27
- Two quick ways to consume this package from a local checkout:
28
-
29
- 1. Live symlink (best for active development)
23
+ **Set your Opper API key:**
30
24
 
31
25
  ```bash
32
- # In the app that will consume the SDK
33
- pnpm link ../opperai-agent-sdk-node
26
+ export OPPER_API_KEY="your-api-key"
34
27
  ```
35
28
 
36
- ```ts
37
- // Then import normally
38
- import { Agent } from "@opperai/agents";
39
- ```
40
-
41
- 2. Local file dependency (copied on install)
42
-
43
- ```json
44
- // app/package.json
45
- {
46
- "dependencies": {
47
- "@opperai/agents": "file:../opperai-agent-sdk-node"
48
- }
49
- }
50
- ```
51
-
52
- Notes:
53
-
54
- - Build the SDK first (and optionally watch) so `dist/` is up to date: `pnpm build` or `pnpm dev`.
55
- - With `link`, changes in this repo are reflected in your app after rebuild.
29
+ Get your API key from the [Opper Dashboard](https://platform.opper.ai).
56
30
 
57
31
  ## Quick Start
58
32
 
33
+ To get started we recommend navigating to the [examples/01_getting_started](./examples/01_getting_started/). They are designed to walk you through the different features of this SDK.
34
+
59
35
  Minimal agent that returns structured JSON:
60
36
 
61
37
  ```ts
@@ -81,11 +57,7 @@ const result = await agent.process("Say hi to Ada");
81
57
  Define tools with Zod schemas. Results are discriminated unions that never throw.
82
58
 
83
59
  ```ts
84
- import {
85
- createFunctionTool,
86
- ToolResultFactory,
87
- Agent,
88
- } from "@opperai/agents";
60
+ import { createFunctionTool, ToolResultFactory, Agent } from "@opperai/agents";
89
61
  import { z } from "zod";
90
62
 
91
63
  const add = createFunctionTool(
package/dist/index.cjs CHANGED
@@ -1087,6 +1087,20 @@ var ToolExecutionSummarySchema = zod.z.object({
1087
1087
  */
1088
1088
  error: zod.z.string().optional()
1089
1089
  });
1090
+
1091
+ // package.json
1092
+ var package_default = {
1093
+ version: "0.1.1"};
1094
+
1095
+ // src/utils/version.ts
1096
+ var SDK_NAME = "@opperai/agents";
1097
+ var SDK_VERSION = package_default.version;
1098
+ var SDK_PLATFORM = "ts";
1099
+ function getUserAgent() {
1100
+ return `${SDK_NAME}-${SDK_PLATFORM}/${SDK_VERSION}`;
1101
+ }
1102
+
1103
+ // src/opper/client.ts
1090
1104
  var isPlainRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1091
1105
  var isZodSchema = (value) => typeof value === "object" && value !== null && "_def" in value && typeof value.parse === "function";
1092
1106
  var readTokenCount = (usage, key) => {
@@ -1123,7 +1137,8 @@ var OpperClient = class {
1123
1137
  retryConfig;
1124
1138
  constructor(apiKey, options = {}) {
1125
1139
  this.client = new opperai.Opper({
1126
- httpBearer: apiKey ?? process.env["OPPER_HTTP_BEARER"] ?? ""
1140
+ httpBearer: apiKey ?? process.env["OPPER_HTTP_BEARER"] ?? "",
1141
+ userAgent: getUserAgent()
1127
1142
  });
1128
1143
  this.logger = options.logger ?? getDefaultLogger();
1129
1144
  this.retryConfig = {