@coalex-ai/sdk 2.2.0 → 2.2.1-beta.669
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 +31 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ await autoInstrumentAsync();
|
|
|
28
28
|
|
|
29
29
|
// 3. Wrap agent invocations for tracing
|
|
30
30
|
// `version` is the build this agent is running. It is optional today and omitting it logs a
|
|
31
|
-
// warning
|
|
31
|
+
// warning once per agent: a trace with no version cannot be attributed to a build, and the
|
|
32
32
|
// dashboard records it as `unknown`. It will become required in a future major release.
|
|
33
33
|
const result = await coalexContext({ agentId: "support-agent", version: "1.4.0" }, async () => {
|
|
34
34
|
// Your AI agent logic here
|
|
@@ -52,6 +52,28 @@ register({
|
|
|
52
52
|
});
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
To have the agent appear in the Console without anyone registering it by hand, pass `declare`. The
|
|
56
|
+
declaration is best-effort: a failure is logged and the agent still starts and traces. Without
|
|
57
|
+
`declare`, `register()` makes no network call.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
register({
|
|
61
|
+
apiKey: "your-api-key",
|
|
62
|
+
serviceName: "my-agent",
|
|
63
|
+
declare: {
|
|
64
|
+
endpoint: "https://my-agent.example.com/turn", // where the Console POSTs a turn
|
|
65
|
+
tools: ["wire_funds"], // tool names only
|
|
66
|
+
resumeUrl: "https://my-agent.example.com/resume", // if the agent supports being paused
|
|
67
|
+
displayName: "Payments agent", // title of a new chat in the Console
|
|
68
|
+
description: "Ask me about wire transfers.", // shown as the agent's first message
|
|
69
|
+
suggestedPrompts: ["Show pending wires"], // shown as buttons that send that text
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
An agent that declares no `displayName`, `description` or `suggestedPrompts` is shown by its name
|
|
75
|
+
alone. Whether a tool is governed and who may approve it are set in the dashboard, not here.
|
|
76
|
+
|
|
55
77
|
### `autoInstrumentAsync(options?)`
|
|
56
78
|
|
|
57
79
|
Instrument AI libraries using dynamic `import()`. Use this in ESM projects.
|
|
@@ -131,14 +153,20 @@ Submit an AI output for evaluation. Returns the governance decision.
|
|
|
131
153
|
|
|
132
154
|
```typescript
|
|
133
155
|
const decision = await evaluate({
|
|
134
|
-
|
|
156
|
+
requestId: "abc-123",
|
|
135
157
|
input: { question: "What is the policy?" },
|
|
136
158
|
output: { answer: "The policy states..." },
|
|
137
159
|
metrics: { answer: ["f1", "rouge_l"] },
|
|
160
|
+
toolName: "wire_funds", // optional: the tool this call is about
|
|
138
161
|
});
|
|
139
|
-
// { status: "auto_approved" | "escalated"
|
|
162
|
+
// { status: "auto_approved" | "escalated", riskScore: 0.12, escalationId?: "..." }
|
|
140
163
|
```
|
|
141
164
|
|
|
165
|
+
`toolName` is stored on the escalation and in the decision's audit-chain entry, so an auditor reads
|
|
166
|
+
which action a person approved, declined or let expire. Only the name is sent there; the tool's
|
|
167
|
+
arguments stay in `input` and `output`. Omitted, the platform reads a `tool` key from `output`,
|
|
168
|
+
`input` or `metadata`. `traceId` is a deprecated alias of `requestId`.
|
|
169
|
+
|
|
142
170
|
Available metrics: `f1`, `word_overlap`, `bleu`, `rouge_l`, `exact_match`, `levenshtein`, `contains`.
|
|
143
171
|
|
|
144
172
|
### `resolve(options)`
|