@naturali/cli 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/README.md +107 -0
- package/bin/naturali +4 -0
- package/dist/index.mjs +5328 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# @naturali/cli
|
|
2
|
+
|
|
3
|
+
The `naturali` command — one command per [naturali.ai](https://naturali.ai) API
|
|
4
|
+
operation, generated from the [OpenAPI specs](../../api/openapi/).
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pnpm add -g @naturali/cli
|
|
8
|
+
naturali configure
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
`naturali configure` saves a profile to `~/.naturali/config.json`: the API base
|
|
14
|
+
URL, a token (`nat_sk_…` or a session JWT), and an optional default project.
|
|
15
|
+
|
|
16
|
+
Environment variables take precedence, which is what CI should use:
|
|
17
|
+
|
|
18
|
+
| Variable | Purpose |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| `NATURALI_BASE_URL` | API origin (e.g. `https://api.naturali.ai`). Overrides a profile's stored URL. |
|
|
21
|
+
| `NATURALI_TOKEN` | Bearer credential. With `NATURALI_BASE_URL` set, no profile is needed. |
|
|
22
|
+
| `NATURALI_PROJECT` | Default `project_id`, so project-scoped commands can omit `--project-id`. |
|
|
23
|
+
| `NATURALI_PROFILE` | Profile to use when `--profile` is not passed. Defaults to `default`. |
|
|
24
|
+
|
|
25
|
+
Use `--profile <name>` to switch profiles per command.
|
|
26
|
+
|
|
27
|
+
## Commands
|
|
28
|
+
|
|
29
|
+
Every operation is a command named by kebab-casing its `operationId`:
|
|
30
|
+
`createAgent` → `create-agent`, `rotateApiKey` → `rotate-api-key`.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
naturali list-commands # every command, with its description
|
|
34
|
+
naturali create-agent --help # one command's flags, and its docs link
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Flags are the spec's parameter names. Kebab-case is the documented convention,
|
|
38
|
+
but snake_case and camelCase are accepted too — `--project-id`, `--project_id`
|
|
39
|
+
and `--projectId` are the same flag.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
naturali list-agents --project-id proj_V1StGXR8Z5jdHi6B --limit 10
|
|
43
|
+
|
|
44
|
+
naturali create-agent \
|
|
45
|
+
--project-id proj_V1StGXR8Z5jdHi6B \
|
|
46
|
+
--provider-id aip_V1StGXR8Z5jdHi6B \
|
|
47
|
+
--name support-triage \
|
|
48
|
+
--tool-ids tool_V1StGXR8Z5jdHi6B
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Where a flag's value goes — URL path, query string or request body — comes from
|
|
52
|
+
the spec, so you never have to know.
|
|
53
|
+
|
|
54
|
+
### Values
|
|
55
|
+
|
|
56
|
+
| Kind | How to pass it |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| String | `--name support-triage` |
|
|
59
|
+
| Number / boolean | `--temperature 0.7`, `--force` (a bare flag is `true`) |
|
|
60
|
+
| Object | `--tool-choice '{"type":"tool","name":"get_weather"}'` |
|
|
61
|
+
| Array | repeat the flag (`--tool-ids a --tool-ids b`) or pass a JSON array (`--tool-ids '["a","b"]'`) |
|
|
62
|
+
|
|
63
|
+
An array-typed field is always sent as a list, even with one value.
|
|
64
|
+
|
|
65
|
+
### Shorthands for path parameters
|
|
66
|
+
|
|
67
|
+
With a default project configured, `--project-id` can be omitted:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
export NATURALI_PROJECT=proj_V1StGXR8Z5jdHi6B
|
|
71
|
+
|
|
72
|
+
naturali list-agents
|
|
73
|
+
naturali get-agent agent_V1StGXR8Z5jdHi6B # positional fills the last path param
|
|
74
|
+
naturali get-agent --id agent_V1StGXR8Z5jdHi6B
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
A positional argument or `--id` fills the **one** path parameter still missing;
|
|
78
|
+
when more than one is unresolved the command fails and names them rather than
|
|
79
|
+
guessing.
|
|
80
|
+
|
|
81
|
+
## Output
|
|
82
|
+
|
|
83
|
+
The response body is printed to stdout as formatted JSON, so it pipes into `jq`:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
naturali list-agents | jq -r '.data[].id'
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
A non-2xx response prints the platform's error envelope to **stderr** and exits
|
|
90
|
+
`1`:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"status": 403,
|
|
95
|
+
"error": { "code": "access_denied", "message": "Not your project" }
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Generation
|
|
100
|
+
|
|
101
|
+
`src/generated/routes.ts` is build output — never edit it, and never commit it.
|
|
102
|
+
It is rebuilt from `api/openapi/v1/*.yaml` by `pnpm generate`, which `typecheck`,
|
|
103
|
+
`test` and `build` all run first. See [`../README.md`](../README.md) for the
|
|
104
|
+
pipeline.
|
|
105
|
+
|
|
106
|
+
Hand-written source is limited to dispatch, flag parsing, credentials and help;
|
|
107
|
+
there is no per-endpoint code.
|
package/bin/naturali
ADDED