@agentvalet/client 0.1.1 → 0.1.2
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 +49 -0
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -46,6 +46,20 @@ const result = await av.call({
|
|
|
46
46
|
});
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
`call()` resolves to the broker's envelope — the upstream SaaS body under
|
|
50
|
+
`data`, with `_meta` describing the call itself:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
{
|
|
54
|
+
data: { ok: true, ts: "1723800000.000100" }, // exactly what Slack returned
|
|
55
|
+
_meta: { capability: "agent.action", timestamp: "…", next_actions: […], docs: "…" }
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
So it's `result.data.ok`, not `result.ok`. The split is deliberate: `data` is the
|
|
60
|
+
upstream payload byte-for-byte, so anything the broker adds about the call stays
|
|
61
|
+
outside it.
|
|
62
|
+
|
|
49
63
|
`fromEnv()` reads `AGENTVALET_AGENT_ID` / `AGENTVALET_OWNER_ID` (or the bare
|
|
50
64
|
`AGENT_ID` / `OWNER_ID` the CLI writes) and finds the key via
|
|
51
65
|
`AGENT_PRIVATE_KEY_B64`, `AGENT_PRIVATE_KEY_PATH`, `AGENT_PRIVATE_KEY`, or
|
|
@@ -135,6 +149,41 @@ await av.evaluate("stripe", "charge"); // dry-run the decision, no side effe
|
|
|
135
149
|
`evaluate()` is worth a call before anything destructive — it tells you whether
|
|
136
150
|
the action would be allowed without performing it.
|
|
137
151
|
|
|
152
|
+
## Which connection served the call
|
|
153
|
+
|
|
154
|
+
When a platform has several connections and you don't pin one, the broker uses
|
|
155
|
+
the default. That's the quiet failure behind a lot of confused agents: you ask
|
|
156
|
+
for a repo, the default GitHub account doesn't have it, you get a 404, and you
|
|
157
|
+
conclude the repo doesn't exist rather than that you're on the wrong account.
|
|
158
|
+
|
|
159
|
+
When there was more than one connection you could have used, the response says
|
|
160
|
+
so. On success it rides `_meta`, leaving `data` untouched:
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
res._meta.connection;
|
|
164
|
+
// {
|
|
165
|
+
// used: "o-github", label: "Acme", defaulted: true,
|
|
166
|
+
// others: [{ connection_id: "o-github-9f1c", label: "Personal" }],
|
|
167
|
+
// hint: "…the target may live on another connection — retry with connection_id…"
|
|
168
|
+
// }
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
On an upstream error there's no envelope — the body is exactly what the platform
|
|
172
|
+
sent — so the same information arrives as one namespaced key, carried on
|
|
173
|
+
`ProxyError.body`:
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"message": "Not Found",
|
|
178
|
+
"_agentvalet": { "connection": { "used": "o-github", "defaulted": true, "others": [], "hint": "…" } }
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
The upstream keys stay where they were, so existing error handling is unaffected.
|
|
183
|
+
It's absent when there's nothing to act on — a connection you pinned, a platform
|
|
184
|
+
with one connection, or a lookup that failed — so treat its absence as "no
|
|
185
|
+
alternatives", never as "this is definitely the right account".
|
|
186
|
+
|
|
138
187
|
## Self-hosting
|
|
139
188
|
|
|
140
189
|
Point `proxyUrl` at your own deployment. Everything else is identical.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentvalet/client",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "AgentValet client SDK
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "AgentValet client SDK \u2014 call approved SaaS platforms from any Node agent. Signs the agent JWT, brokers through the AgentValet proxy, and waits out owner approvals.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
"dist",
|
|
13
13
|
"README.md"
|
|
14
14
|
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"dev": "tsc --watch",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"prepublishOnly": "node ../../scripts/no-secrets.mjs && pnpm run build && node ../../scripts/no-workspace-protocol.mjs"
|
|
21
|
+
},
|
|
15
22
|
"dependencies": {
|
|
16
23
|
"jose": "^5.10.0"
|
|
17
24
|
},
|
|
@@ -37,11 +44,5 @@
|
|
|
37
44
|
"sdk"
|
|
38
45
|
],
|
|
39
46
|
"license": "MIT",
|
|
40
|
-
"homepage": "https://github.com/AgentValet/AgentValet#readme"
|
|
41
|
-
|
|
42
|
-
"build": "tsc",
|
|
43
|
-
"dev": "tsc --watch",
|
|
44
|
-
"typecheck": "tsc --noEmit",
|
|
45
|
-
"test": "vitest run"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
47
|
+
"homepage": "https://github.com/AgentValet/AgentValet#readme"
|
|
48
|
+
}
|