@usenaive-sdk/managed-agents 0.0.0-stage → 0.12.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/README.md CHANGED
@@ -1,3 +1,80 @@
1
- # Temporary Holding Version
1
+ # @usenaive-sdk/managed-agents
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Typed TypeScript client for the Naive Managed Agents API — agents, sessions, identities, connections, vaults,
4
+ comms, deployments, webhooks, the model proxy, and a resumable event stream. One method per route,
5
+ parsed with the same schemas the server does.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm i @usenaive-sdk/managed-agents
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { createClient } from "@usenaive-sdk/managed-agents";
17
+
18
+ // `fetch` (default: the global one) and `idempotencyKey` (default: a random UUID per write) are optional.
19
+ const client = createClient({ baseUrl: "https://api.vetta.sh", apiKey: process.env.NAIVE_API_KEY! });
20
+
21
+ // `budget` is required: an agent with no spending ceiling is refused, not defaulted.
22
+ const agent = await client.agents.create({
23
+ name: "Refunder",
24
+ model: "zai-org/GLM-5.2-FP8",
25
+ window: "immediate",
26
+ budget: { cap_micro_usd: 50_000_000, max_task_micro_usd: 5_000_000, period: "month" },
27
+ });
28
+ ```
29
+
30
+ ## ESM only
31
+
32
+ The package is **ESM-only** (no `require`). The examples use top-level `await`, which needs an
33
+ ES module: set `"type": "module"` in `package.json`, or name the file `.mts` / `.mjs`. In a
34
+ CommonJS project, load it with a dynamic import inside an async function:
35
+
36
+ ```ts
37
+ async function main() {
38
+ const { createClient } = await import("@usenaive-sdk/managed-agents");
39
+ const client = createClient({ baseUrl: "https://api.vetta.sh", apiKey: process.env.NAIVE_API_KEY! });
40
+ }
41
+ main();
42
+ ```
43
+
44
+ If `tsc` compiles your project, set `"module"` and `"moduleResolution"` to `"node16"` or `"nodenext"`
45
+ in `tsconfig.json`. With `"module": "commonjs"`, tsc rewrites `import()` to `require()`, which fails
46
+ with `ERR_PACKAGE_PATH_NOT_EXPORTED`. Running the file with `tsx` keeps the `import()` as written.
47
+
48
+ ## Configuring an agent's tools
49
+
50
+ `configs` is replaced wholesale on the wire, so changing one tool by hand means resending every
51
+ other one unchanged. `withTool` does that, and types the config the built-ins read —
52
+ `WebToolConfig` (`web_search`, `web_fetch`) and `MediaToolConfig` (`generate_image`,
53
+ `generate_video`). Omitted fields keep their current value and `config` merges key by key.
54
+
55
+ ```ts
56
+ import { withTool } from "@usenaive-sdk/managed-agents";
57
+
58
+ await client.agents.update(agent.id, {
59
+ tools: withTool(agent.tools, "web_fetch", {
60
+ permission: "ask",
61
+ config: { allowed_domains: ["docs.example.com"], max_content_tokens: 2000 },
62
+ }),
63
+ });
64
+ ```
65
+
66
+ ## One model call, no session
67
+
68
+ `client.proxy.messages` is the Messages-format endpoint: one org-level call with no agent, no
69
+ tools and no state between calls. The completion window is the second argument, because the format
70
+ has no field for one. Streaming is deliberately absent — point the Messages-format client you
71
+ already have at `<baseUrl>/v1/proxy/anthropic`, which is what the endpoint exists for.
72
+
73
+ ```ts
74
+ const reply = await client.proxy.messages(
75
+ { model: "openai/gpt-oss-120b", max_tokens: 1024, messages: [{ role: "user", content: "hi" }] },
76
+ "immediate",
77
+ );
78
+ ```
79
+
80
+ See the [TypeScript SDK reference](https://usenaive.ai/docs/sdk/typescript) for the full method index.