@eng-ai/sdk 2.0.2 → 2.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.
- package/CHANGELOG.md +9 -0
- package/README.md +8 -3
- package/package.json +1 -1
- package/src/client.js +11 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@eng-ai/sdk` will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 2.1.0 - 2026-04-05
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `invokeAgent` now supports autonomous fallback when `agent_id` is omitted:
|
|
10
|
+
- `client.invokeAgent({ message: "..." })` -> `POST /api/v2/sdk/invoke`
|
|
11
|
+
- Explicit specialist invocation remains supported:
|
|
12
|
+
- `client.invokeAgent("general", { ... })` -> `POST /api/v2/sdk/agents/{agent_id}/invoke`
|
|
13
|
+
|
|
5
14
|
## 2.0.2 - 2026-04-05
|
|
6
15
|
|
|
7
16
|
### Changed
|
package/README.md
CHANGED
|
@@ -15,14 +15,19 @@ import { EngAIClient } from "@eng-ai/sdk";
|
|
|
15
15
|
|
|
16
16
|
const client = new EngAIClient(process.env.ENG_AI_API_KEY, "https://your-domain/api/v2");
|
|
17
17
|
|
|
18
|
-
const response = await client.invokeAgent(
|
|
18
|
+
const response = await client.invokeAgent({
|
|
19
|
+
message: "Explique o conceito de talude"
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Optional explicit specialist
|
|
23
|
+
const responseWithAgent = await client.invokeAgent("general", {
|
|
19
24
|
message: "Explique o conceito de talude",
|
|
20
25
|
normativeMode: true,
|
|
21
26
|
normId: "auto"
|
|
22
27
|
});
|
|
23
28
|
|
|
24
|
-
console.log(
|
|
25
|
-
console.log(
|
|
29
|
+
console.log(responseWithAgent.result.content);
|
|
30
|
+
console.log(responseWithAgent.normative?.citations ?? []);
|
|
26
31
|
```
|
|
27
32
|
|
|
28
33
|
Default base URL: `https://api.eng-ai.com/api/v2`.
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -8,7 +8,11 @@ export class EngAIClient {
|
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
async invokeAgent(
|
|
11
|
+
async invokeAgent(agentIdOrPayload, maybePayload) {
|
|
12
|
+
const implicitAutonomous = arguments.length === 1;
|
|
13
|
+
const agentId = implicitAutonomous ? null : agentIdOrPayload;
|
|
14
|
+
const payload = implicitAutonomous ? agentIdOrPayload : maybePayload;
|
|
15
|
+
|
|
12
16
|
const body =
|
|
13
17
|
typeof payload === "string"
|
|
14
18
|
? { message: payload }
|
|
@@ -31,7 +35,12 @@ export class EngAIClient {
|
|
|
31
35
|
headers["Idempotency-Key"] = idempotencyKey;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
const
|
|
38
|
+
const normalizedAgentId = String(agentId || "").trim();
|
|
39
|
+
const endpoint = normalizedAgentId
|
|
40
|
+
? `${this.baseUrl}/sdk/agents/${encodeURIComponent(normalizedAgentId)}/invoke`
|
|
41
|
+
: `${this.baseUrl}/sdk/invoke`;
|
|
42
|
+
|
|
43
|
+
const response = await fetch(endpoint, {
|
|
35
44
|
method: "POST",
|
|
36
45
|
headers,
|
|
37
46
|
body: JSON.stringify(body),
|