@opperai/agents 0.4.1 → 0.6.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.
- package/dist/index.cjs +19 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +281 -224
- package/dist/index.d.ts +281 -224
- package/dist/index.js +19 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1007,7 +1007,7 @@ var BaseAgent = class {
|
|
|
1007
1007
|
}
|
|
1008
1008
|
this.opperConfig = {
|
|
1009
1009
|
apiKey: config.opperConfig?.apiKey ?? process.env["OPPER_API_KEY"],
|
|
1010
|
-
baseUrl: config.opperConfig?.baseUrl,
|
|
1010
|
+
baseUrl: config.opperConfig?.baseUrl ?? process.env["OPPER_BASE_URL"],
|
|
1011
1011
|
...config.opperConfig
|
|
1012
1012
|
};
|
|
1013
1013
|
this.memory = this.initializeMemory(config);
|
|
@@ -1270,6 +1270,7 @@ var BaseAgent = class {
|
|
|
1270
1270
|
* @returns Tool execution result
|
|
1271
1271
|
*/
|
|
1272
1272
|
async executeTool(toolName, input, context, options) {
|
|
1273
|
+
const toolCallId = randomUUID();
|
|
1273
1274
|
const tool2 = this.tools.get(toolName);
|
|
1274
1275
|
if (!tool2) {
|
|
1275
1276
|
const failure = ToolResultFactory.failure(
|
|
@@ -1278,6 +1279,7 @@ var BaseAgent = class {
|
|
|
1278
1279
|
);
|
|
1279
1280
|
const timestamp = Date.now();
|
|
1280
1281
|
context.recordToolCall({
|
|
1282
|
+
id: toolCallId,
|
|
1281
1283
|
toolName,
|
|
1282
1284
|
input,
|
|
1283
1285
|
success: false,
|
|
@@ -1289,7 +1291,8 @@ var BaseAgent = class {
|
|
|
1289
1291
|
await this.triggerHook(HookEvents.ToolError, {
|
|
1290
1292
|
context,
|
|
1291
1293
|
toolName,
|
|
1292
|
-
error: failure.error
|
|
1294
|
+
error: failure.error,
|
|
1295
|
+
toolCallId
|
|
1293
1296
|
});
|
|
1294
1297
|
return failure;
|
|
1295
1298
|
}
|
|
@@ -1304,11 +1307,13 @@ var BaseAgent = class {
|
|
|
1304
1307
|
await this.triggerHook(HookEvents.BeforeTool, {
|
|
1305
1308
|
context,
|
|
1306
1309
|
tool: tool2,
|
|
1307
|
-
input
|
|
1310
|
+
input,
|
|
1311
|
+
toolCallId
|
|
1308
1312
|
});
|
|
1309
1313
|
const result = await tool2.execute(input, executionContext);
|
|
1310
1314
|
const finishedAt = Date.now();
|
|
1311
1315
|
const record = context.recordToolCall({
|
|
1316
|
+
id: toolCallId,
|
|
1312
1317
|
toolName: tool2.name,
|
|
1313
1318
|
input,
|
|
1314
1319
|
...result.success && { output: result.output },
|
|
@@ -1325,7 +1330,8 @@ var BaseAgent = class {
|
|
|
1325
1330
|
context,
|
|
1326
1331
|
tool: tool2,
|
|
1327
1332
|
toolName: tool2.name,
|
|
1328
|
-
error: result.error
|
|
1333
|
+
error: result.error,
|
|
1334
|
+
toolCallId
|
|
1329
1335
|
});
|
|
1330
1336
|
}
|
|
1331
1337
|
await this.triggerHook(HookEvents.AfterTool, {
|
|
@@ -1345,6 +1351,7 @@ var BaseAgent = class {
|
|
|
1345
1351
|
}
|
|
1346
1352
|
);
|
|
1347
1353
|
const record = context.recordToolCall({
|
|
1354
|
+
id: toolCallId,
|
|
1348
1355
|
toolName: tool2.name,
|
|
1349
1356
|
input,
|
|
1350
1357
|
success: false,
|
|
@@ -1357,7 +1364,8 @@ var BaseAgent = class {
|
|
|
1357
1364
|
context,
|
|
1358
1365
|
tool: tool2,
|
|
1359
1366
|
toolName: tool2.name,
|
|
1360
|
-
error
|
|
1367
|
+
error,
|
|
1368
|
+
toolCallId
|
|
1361
1369
|
});
|
|
1362
1370
|
await this.triggerHook(HookEvents.AfterTool, {
|
|
1363
1371
|
context,
|
|
@@ -1626,7 +1634,7 @@ var mergeSchemaDefaults = (schema, value) => {
|
|
|
1626
1634
|
|
|
1627
1635
|
// package.json
|
|
1628
1636
|
var package_default = {
|
|
1629
|
-
version: "0.
|
|
1637
|
+
version: "0.6.0"};
|
|
1630
1638
|
|
|
1631
1639
|
// src/utils/version.ts
|
|
1632
1640
|
var SDK_NAME = "@opperai/agents";
|
|
@@ -1674,7 +1682,8 @@ var OpperClient = class {
|
|
|
1674
1682
|
constructor(apiKey, options = {}) {
|
|
1675
1683
|
this.client = new Opper({
|
|
1676
1684
|
httpBearer: apiKey ?? process.env["OPPER_HTTP_BEARER"] ?? "",
|
|
1677
|
-
userAgent: getUserAgent()
|
|
1685
|
+
userAgent: getUserAgent(),
|
|
1686
|
+
...options.baseUrl && { serverURL: options.baseUrl }
|
|
1678
1687
|
});
|
|
1679
1688
|
this.logger = options.logger ?? getDefaultLogger();
|
|
1680
1689
|
this.retryConfig = {
|
|
@@ -2119,7 +2128,8 @@ var Agent = class extends BaseAgent {
|
|
|
2119
2128
|
}
|
|
2120
2129
|
}
|
|
2121
2130
|
this.opperClient = config.opperClient ?? new OpperClient(this.opperConfig.apiKey, {
|
|
2122
|
-
logger: this.logger
|
|
2131
|
+
logger: this.logger,
|
|
2132
|
+
...this.opperConfig.baseUrl && { baseUrl: this.opperConfig.baseUrl }
|
|
2123
2133
|
});
|
|
2124
2134
|
}
|
|
2125
2135
|
/**
|
|
@@ -2535,7 +2545,7 @@ The memory you write persists across all process() calls on this agent.`;
|
|
|
2535
2545
|
};
|
|
2536
2546
|
});
|
|
2537
2547
|
const executionHistory = context.getLastNCycles(3).map((cycle) => {
|
|
2538
|
-
const thought = typeof cycle.thought === "object" && cycle.thought !== null ? cycle.thought
|
|
2548
|
+
const thought = typeof cycle.thought === "object" && cycle.thought !== null ? cycle.thought.reasoning || "" : String(cycle.thought || "");
|
|
2539
2549
|
const results = Array.isArray(cycle.results) ? cycle.results.map((r) => {
|
|
2540
2550
|
const result = r;
|
|
2541
2551
|
let actualOutput = result.output;
|