agent-first-data 0.2.1 → 0.2.3
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 +37 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,43 @@ The field name is the schema. Agents read `latency_ms` and know milliseconds, `a
|
|
|
10
10
|
npm install agent-first-data
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
## Quick Example
|
|
14
|
+
|
|
15
|
+
A backup tool invoked from the CLI — flags, env vars, and config all use the same suffixes:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
API_KEY_SECRET=sk-1234 cloudback --timeout-s 30 --max-file-size-bytes 10737418240 /data/backup.tar.gz
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The tool reads env vars, flags, and config — all with AFD suffixes — and emits a startup message:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { buildJsonStartup, outputJson, outputYaml, outputPlain } from "agent-first-data";
|
|
25
|
+
|
|
26
|
+
const startup = buildJsonStartup(
|
|
27
|
+
{ timeout_s: 30, max_file_size_bytes: 10737418240 },
|
|
28
|
+
{ input_path: "/data/backup.tar.gz" },
|
|
29
|
+
{ API_KEY_SECRET: process.env.API_KEY_SECRET ?? null },
|
|
30
|
+
);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Three output formats, same data:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
JSON: {"code":"startup","args":{"input_path":"/data/backup.tar.gz"},"config":{"max_file_size_bytes":10737418240,"timeout_s":30},"env":{"API_KEY_SECRET":"***"}}
|
|
37
|
+
YAML: code: "startup"
|
|
38
|
+
args:
|
|
39
|
+
input_path: "/data/backup.tar.gz"
|
|
40
|
+
config:
|
|
41
|
+
max_file_size: "10.0GB"
|
|
42
|
+
timeout: "30s"
|
|
43
|
+
env:
|
|
44
|
+
API_KEY: "***"
|
|
45
|
+
Plain: args.input_path=/data/backup.tar.gz code=startup config.max_file_size=10.0GB config.timeout=30s env.API_KEY=***
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`--timeout-s` → `timeout_s` → `timeout: 30s`. `API_KEY_SECRET` → `API_KEY: "***"`. The suffix is the schema.
|
|
49
|
+
|
|
13
50
|
## API Reference
|
|
14
51
|
|
|
15
52
|
Total: **9 public APIs** + **AFD logging** (4 protocol builders + 3 output functions + 1 internal + 1 utility)
|