canary-agent 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.
- package/LICENSE +21 -0
- package/README.md +139 -0
- package/dist/index.cjs +959 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +250 -0
- package/dist/index.d.ts +250 -0
- package/dist/index.js +906 -0
- package/dist/index.js.map +1 -0
- package/dist/journal/server.cjs +418 -0
- package/dist/journal/server.cjs.map +1 -0
- package/dist/journal/server.d.cts +1 -0
- package/dist/journal/server.d.ts +1 -0
- package/dist/journal/server.js +426 -0
- package/dist/journal/server.js.map +1 -0
- package/dist/openclaw.cjs +843 -0
- package/dist/openclaw.cjs.map +1 -0
- package/dist/openclaw.d.cts +2 -0
- package/dist/openclaw.d.ts +2 -0
- package/dist/openclaw.js +804 -0
- package/dist/openclaw.js.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Canary
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# canary-agent
|
|
2
|
+
|
|
3
|
+
API observability SDK for AI agents. Zero-dependency Node.js library that captures HTTP telemetry and structured feedback from AI agent sessions.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install canary-agent
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### As MCP Server (recommended for Claude Code / Cursor)
|
|
14
|
+
|
|
15
|
+
Add to your project's `.mcp.json`:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"canary-journal": {
|
|
21
|
+
"command": "npx",
|
|
22
|
+
"args": ["-y", "canary-agent"],
|
|
23
|
+
"env": {
|
|
24
|
+
"CANARY_API_KEY": "your_api_key",
|
|
25
|
+
"CANARY_ENDPOINT": "https://api.canary.dev"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The MCP server provides two tools:
|
|
33
|
+
|
|
34
|
+
- **`canary_annotate`** — Record API observations during your work
|
|
35
|
+
- **`canary_report`** — Submit structured feedback when your task is complete
|
|
36
|
+
|
|
37
|
+
### As SDK (programmatic)
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { init, shutdown, survey } from 'canary-agent';
|
|
41
|
+
|
|
42
|
+
// Initialize — patches http/https and fetch automatically
|
|
43
|
+
init({
|
|
44
|
+
apiKey: process.env.CANARY_API_KEY,
|
|
45
|
+
endpoint: 'https://api.canary.dev',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// All HTTP calls to tracked APIs are now captured automatically
|
|
49
|
+
const res = await fetch('https://api.stripe.com/v1/charges');
|
|
50
|
+
|
|
51
|
+
// Optional: submit manual feedback
|
|
52
|
+
survey({
|
|
53
|
+
worked: true,
|
|
54
|
+
context: 'Payment processed successfully',
|
|
55
|
+
provider: 'stripe',
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// At shutdown, auto-reports are generated
|
|
59
|
+
await shutdown();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
| Option | Env Var | Description |
|
|
65
|
+
|--------|---------|-------------|
|
|
66
|
+
| `apiKey` | `CANARY_API_KEY` | Your Canary API key (required, starts with `cnry_sk_`) |
|
|
67
|
+
| `endpoint` | `CANARY_ENDPOINT` | Backend URL (default: `https://api.canary.dev`) |
|
|
68
|
+
| `sessionId` | `CANARY_SESSION_ID` | Link to a specific session |
|
|
69
|
+
| `agentName` | `CANARY_AGENT_NAME` | Identify this agent in multi-agent setups |
|
|
70
|
+
| `autoReport` | — | Auto-generate feedback at shutdown (default: `true`) |
|
|
71
|
+
| `autoFlush` | — | Start periodic flush timer (default: `true`) |
|
|
72
|
+
|
|
73
|
+
## Session Correlation
|
|
74
|
+
|
|
75
|
+
Use `runWithSession()` to scope API calls to a session:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { runWithSession } from 'canary-agent';
|
|
79
|
+
|
|
80
|
+
await runWithSession('skill-execution-42', async () => {
|
|
81
|
+
// All API calls here are grouped under one session
|
|
82
|
+
await fetch('https://api.stripe.com/v1/charges', { ... });
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## MCP Server CLI
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npx canary-agent --api-key=YOUR_KEY --endpoint=https://api.canary.dev
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Or with environment variables:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
CANARY_API_KEY=your_key npx canary-agent
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Multi-Agent Setup
|
|
99
|
+
|
|
100
|
+
Set `CANARY_AGENT_NAME` to identify each agent under a shared API key:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"mcpServers": {
|
|
105
|
+
"canary-journal": {
|
|
106
|
+
"command": "npx",
|
|
107
|
+
"args": ["-y", "canary-agent"],
|
|
108
|
+
"env": {
|
|
109
|
+
"CANARY_API_KEY": "shared_team_key",
|
|
110
|
+
"CANARY_AGENT_NAME": "checkout-agent"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## OpenClaw Integration
|
|
118
|
+
|
|
119
|
+
For OpenClaw skills, import the auto-init module:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import 'canary-agent/openclaw';
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
This automatically initializes Canary when `OPENCLAW_SESSION_ID` and `CANARY_API_KEY` are set.
|
|
126
|
+
|
|
127
|
+
## Tracked Providers
|
|
128
|
+
|
|
129
|
+
**AI/ML:** OpenAI, Anthropic, Cohere, Google AI, Replicate, Hugging Face, Mistral
|
|
130
|
+
**Payments:** Stripe, Square, PayPal, Braintree
|
|
131
|
+
**Communication:** Twilio, SendGrid, Mailgun, Postmark, Resend
|
|
132
|
+
**Developer:** GitHub, GitLab, Slack, Discord, Linear
|
|
133
|
+
**Cloud:** Cloudflare, Vercel, Heroku, Netlify
|
|
134
|
+
**Data:** Segment, Mixpanel, Amplitude
|
|
135
|
+
**SaaS:** Notion, Airtable, HubSpot, Salesforce, and more
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
MIT
|