@flowshape/agent 0.0.0-stage → 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 ADDED
@@ -0,0 +1,61 @@
1
+ Required Notice: Copyright 2026 FlowShape (https://flowshape.io)
2
+
3
+ # PolyForm Strict License 1.0.0
4
+
5
+ <https://polyformproject.org/licenses/strict/1.0.0>
6
+
7
+ ## Acceptance
8
+
9
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose, other than distributing the software or making changes or new works based on the software.
14
+
15
+ ## Patent License
16
+
17
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
18
+
19
+ ## Noncommercial Purposes
20
+
21
+ Any noncommercial purpose is a permitted purpose.
22
+
23
+ ## Personal Uses
24
+
25
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
26
+
27
+ ## Noncommercial Organizations
28
+
29
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
30
+
31
+ ## Fair Use
32
+
33
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
34
+
35
+ ## No Other Rights
36
+
37
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
38
+
39
+ ## Patent Defense
40
+
41
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
42
+
43
+ ## Violations
44
+
45
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
46
+
47
+ ## No Liability
48
+
49
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
50
+
51
+ ## Definitions
52
+
53
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
54
+
55
+ **You** refers to the individual or entity agreeing to these terms.
56
+
57
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
58
+
59
+ **Your licenses** are all the licenses granted to you for the software under these terms.
60
+
61
+ **Use** means anything you do with the software requiring one of your licenses.
package/README.md CHANGED
@@ -1,3 +1,211 @@
1
- # Temporary Holding Version
1
+ # FlowShape agent
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
+ The FlowShape agent runs read-only collectors inside your network: Kubernetes, Azure,
4
+ Terraform and network scans for **Discovery**, and your Grafana for **Live status**. It hands
5
+ the results to [FlowShape](https://flowshape.io) in your browser, which turns them into a
6
+ diagram, or adds live health, logs and traces to one.
7
+
8
+ It never contacts FlowShape or any third party. The only outgoing connections are the tools
9
+ you enable (`kubectl`, `az`, `terraform`, `nmap`, which talk to your own cluster, cloud and
10
+ network) and, with `--grafana`, your own Grafana. It answers requests on this computer only,
11
+ from FlowShape's own page, and only with its key. What it collects goes from the agent to your
12
+ browser, never through FlowShape's servers.
13
+
14
+ The source is published so you can read exactly what runs in your network. It is
15
+ source-available, not open source: see [License](#license).
16
+
17
+ Full documentation: **[docs.flowshape.io/agent](https://docs.flowshape.io/agent/)**
18
+
19
+ ## Quick start
20
+
21
+ You need [Node.js](https://nodejs.org) 20 or newer, on macOS, Linux or Windows. Nothing else to
22
+ install. The agent is useful only with FlowShape; it comes with FlowShape Pro.
23
+
24
+ 1. In FlowShape, open **Integrations** and pick a source (Kubernetes, Azure, Terraform, a
25
+ network scan or Grafana). FlowShape writes the command for it, for example:
26
+
27
+ ```sh
28
+ npx -y @flowshape/agent@0.1.0 --key <key> --kubernetes
29
+ ```
30
+
31
+ 2. Run it in a terminal.
32
+ 3. Back in FlowShape, press **Look for the agent**. FlowShape finds it by itself, and the
33
+ agent's window says `FlowShape connected`.
34
+
35
+ To try it without any tools or access, use the built-in sample environments:
36
+
37
+ ```sh
38
+ npx @flowshape/agent --demo
39
+ ```
40
+
41
+ To keep it installed: `npm install -g @flowshape/agent`, then `flowshape-agent --help`. On a
42
+ machine without npm access, FlowShape also hands out the same agent as one file,
43
+ `flowshape-agent.mjs` (run it with `node flowshape-agent.mjs`).
44
+
45
+ ### Your browser will ask first
46
+
47
+ Chrome and Edge ask before a website may talk to apps on your computer. When FlowShape looks
48
+ for the agent the first time, choose **Allow** ("connect to devices on your local network" or
49
+ "apps on this device"). If you blocked it by mistake: click the icon at the left of the
50
+ address bar, open **Site settings**, set **Local network access** (or **Loopback network**;
51
+ in Brave, **Localhost access**) to **Allow**, and reload the page.
52
+
53
+ ## Sources
54
+
55
+ Each source runs the vendor's own tool, without a shell, with your access. Read access is
56
+ enough everywhere.
57
+
58
+ | Option | Runs | Needs |
59
+ | --------------------------------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- |
60
+ | `--kubernetes [--context <name>]` | `kubectl get deploy,sts,ds,svc,ing,cm,pvc,cronjob,job,pod -A -o json`, then `kubectl get secrets -A -o json` | a kubeconfig with the built-in `view` role; listing Secrets is optional (see below) |
61
+ | `--azure [--subscription <id>]` | `az graph query` (Azure Resource Graph, first 1,000 resources) | `az login`, the **Reader** role |
62
+ | `--terraform <dir>` | `terraform show -json` in that folder (repeatable) | `terraform init` has run there; Terraform 0.15 or newer |
63
+ | `--nmap <range>` | `nmap -sV --traceroute -oX - <range>` (repeatable) | `nmap`; root for the traceroute; only networks you own or may test |
64
+ | `--file <path>` | reads a file you collected yourself (repeatable) | |
65
+ | `--demo` | the sample environments built into the agent | nothing |
66
+ | `--grafana <url>` | Grafana's data source API: Prometheus, Loki and Tempo | a **Viewer** service-account token |
67
+
68
+ Add `--every 15m` (or `1h`, `90s`) to collect again on a schedule. Without it, the agent
69
+ collects once at start, then whenever FlowShape asks.
70
+
71
+ - **Kubernetes Secrets** show which workloads use which Secret. Reading them needs `list` on
72
+ `secrets` cluster-wide, which the `view` role doesn't give. Without it, the agent skips them
73
+ and the diagram shows the workloads only. With it, each Secret's values are dropped as soon
74
+ as kubectl returns them, before anything leaves the agent.
75
+ - **Terraform** reads state through the backend configured in that folder, with your
76
+ credentials for it. Terraform 0.15 and newer mark sensitive values, which the agent drops.
77
+ - **Azure on Windows:** `az` is a batch file there, which the agent can't run without a
78
+ shell. Run the query yourself and give the agent the file:
79
+
80
+ ```powershell
81
+ az graph query -q "Resources | project id, name, type, resourceGroup, subscriptionId, location, sku, kind, properties" --first 1000 -o json > azure.json
82
+ npx @flowshape/agent --key <key> --file azure.json
83
+ ```
84
+
85
+ ### Live status from Grafana
86
+
87
+ ```sh
88
+ FLOWSHAPE_GRAFANA_TOKEN=<token> npx @flowshape/agent --key <key> --grafana https://grafana.example.com
89
+ ```
90
+
91
+ - **The token** comes from `FLOWSHAPE_GRAFANA_TOKEN` or `--grafana-token-file <path>`. It
92
+ stays on this machine; FlowShape only gets the answers, and Grafana's address without any
93
+ user name or password in it.
94
+ - **Matching:** an item on a diagram is matched by name to the series whose `service` label
95
+ has that name. Use `--grafana-label <label>` for another label.
96
+ - **Queries:** the defaults read `up` (or `service_up`), `http_requests_total` and
97
+ `http_request_duration_seconds_bucket`. Replace any of them with
98
+ `--grafana-queries <file.json>`, a JSON object with any of the keys `status`, `errors`,
99
+ `latency`, `rate`, `logs` and `traceTag`. `$label`, `$names` and `$name` are filled in.
100
+
101
+ ## Options
102
+
103
+ ```
104
+ --kubernetes [--context <name>] --azure [--subscription <id>] --terraform <dir>
105
+ --nmap <range> --file <path> --demo
106
+ --grafana <url> --grafana-token-file <path> --grafana-label <label> --grafana-queries <file>
107
+ --key <key> the key FlowShape uses, 16 characters or more; or FLOWSHAPE_AGENT_KEY,
108
+ --key-file <path> or a file. A random one is made when none is given
109
+ --port <7777> the port to listen on
110
+ --host <127.0.0.1> the address to listen on (see "Another machine")
111
+ --origin <url> another FlowShape address that may use the agent (repeatable)
112
+ --every <15m> collect again on a schedule
113
+ --help all options
114
+ ```
115
+
116
+ `--key` on the command line ends up in your shell history and in the process list, visible to
117
+ other users of the machine. On a shared machine, use `FLOWSHAPE_AGENT_KEY` or `--key-file`.
118
+
119
+ ## Another machine
120
+
121
+ FlowShape reaches an agent on your own computer only. Browsers don't let a secure page call
122
+ plain HTTP elsewhere, and the agent is safest bound to 127.0.0.1. To read a network from
123
+ another machine, run the agent there as usual, and forward its port to your computer over SSH:
124
+
125
+ ```sh
126
+ ssh -N -L 7777:127.0.0.1:7777 you@that-machine
127
+ ```
128
+
129
+ FlowShape writes this command for you when you tick **It runs on another machine**.
130
+
131
+ ## Security and data
132
+
133
+ **Who can reach it.** The agent listens on 127.0.0.1, so only programs on this computer can
134
+ connect; it warns when started with another `--host`. Every request needs the key
135
+ (`Authorization: Bearer <key>`, compared in constant time); without it, nothing is answered.
136
+ Browser pages from other websites are refused by their origin. While it listens on
137
+ 127.0.0.1, requests addressed to any name but this computer's own (`127.0.0.1`, `localhost`,
138
+ `[::1]`) are refused too, so a website can't reach it through DNS rebinding. What remains: anyone who has the key and can
139
+ connect to this computer, which is why it belongs out of shared shell history.
140
+
141
+ **What it runs.** Only the tools above, without a shell, with fixed arguments, with the rights
142
+ of whoever runs the agent. Give it a read-only identity: Azure Reader, the Kubernetes `view`
143
+ role, a Grafana Viewer token.
144
+
145
+ **What it hands out.** Each source's output as its tool printed it, with secrets dropped:
146
+
147
+ - Kubernetes Secrets keep their name, type, labels and annotations; their values, and the
148
+ `last-applied-configuration` annotation (which repeats them), are removed.
149
+ - Values Terraform marks sensitive are removed, in state and in plans, and so are sensitive
150
+ outputs and sensitive input variables.
151
+ - Files given with `--file` get the same treatment when they are kubectl or Terraform JSON.
152
+ - Anything a tool prints that isn't marked secret is passed on as printed: ConfigMaps, an
153
+ environment variable written straight into a pod spec or a task definition, tags. Keep
154
+ secrets in Secrets and sensitive variables.
155
+
156
+ **What it keeps.** Nothing on disk. The last results stay in memory until the agent stops.
157
+
158
+ See [Security](https://docs.flowshape.io/agent/security/) to report a vulnerability.
159
+
160
+ ## Audit it yourself
161
+
162
+ Everything the agent does is in one file, `agent.mjs`, with no dependencies. To
163
+ see what it hands out, run it with the samples and ask it yourself:
164
+
165
+ ```sh
166
+ node agent.mjs --demo --key my-own-key-1234567890
167
+ curl -H "Authorization: Bearer my-own-key-1234567890" http://127.0.0.1:7777/v1/info
168
+ curl -H "Authorization: Bearer my-own-key-1234567890" http://127.0.0.1:7777/v1/sources/demo-kubernetes
169
+ ```
170
+
171
+ The npm package is this folder's `agent.mjs`, samples and documents, nothing else: read it with
172
+ `npm pack @flowshape/agent` before you run it. The single file FlowShape hands out for machines
173
+ without npm is `node build.mjs` output from the same source. The build is reproducible, so you
174
+ can check a download against your own:
175
+
176
+ ```sh
177
+ node build.mjs && sha256sum dist/flowshape-agent.mjs ~/Downloads/flowshape-agent.mjs
178
+ ```
179
+
180
+ ## HTTP API
181
+
182
+ All routes need `Authorization: Bearer <key>`.
183
+
184
+ | Route | Answers |
185
+ | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
186
+ | `GET /v1/info` | the agent's version, machine name and sources, with when each was collected; with `--grafana`, Grafana's address and label |
187
+ | `POST /v1/collect` | collects every source again, then answers like `/v1/info` |
188
+ | `GET /v1/sources/<id>` | one source's output, secrets dropped (kubectl and Terraform JSON is re-serialised) |
189
+ | `GET /v1/monitoring` | Grafana's data sources: metrics, logs, traces |
190
+ | `GET /v1/monitoring/status?names=a,b` | per name: up, the 5xx share, p95 latency, requests a minute |
191
+ | `GET /v1/monitoring/logs?name=a` | the latest log lines of one item |
192
+ | `GET /v1/monitoring/traces?name=a` | recent traces through one item, with links into Grafana |
193
+
194
+ ## Running the tests
195
+
196
+ ```sh
197
+ npm install
198
+ npm test # vitest
199
+ node build.mjs # dist/flowshape-agent.mjs: one file with the samples inside
200
+ ```
201
+
202
+ The licence doesn't allow modified versions, so this repository doesn't take pull requests.
203
+ Report problems and ideas to hello@flowshape.io.
204
+
205
+ ## License
206
+
207
+ [PolyForm Strict 1.0.0](https://polyformproject.org/licenses/strict/1.0.0) (the LICENSE file). You may use the FlowShape agent for noncommercial purposes
208
+ (personal use, research, education, noncommercial organizations). You may not distribute it
209
+ or make changes or new works based on it. Using it with FlowShape, commercially included, is
210
+ covered by [FlowShape's Terms](https://flowshape.io/terms/). For other commercial use or other
211
+ terms, contact hello@flowshape.io.
package/SECURITY.md ADDED
@@ -0,0 +1,34 @@
1
+ # Security
2
+
3
+ The agent runs inside your network with whatever access you give it, so we take reports
4
+ about it seriously.
5
+
6
+ **Reporting a vulnerability:** write to hello@flowshape.io with "Security" in the subject.
7
+ Please don't open a public issue for it. We reply as soon as we can, and tell you when it's
8
+ fixed.
9
+
10
+ ## What the agent does and doesn't do
11
+
12
+ - **It never contacts FlowShape or any third party.** It only answers requests. The only
13
+ outgoing connections are the tools you enable (`az`, `kubectl`, `terraform`, `nmap`) and,
14
+ with `--grafana`, your own Grafana.
15
+ - **It listens on 127.0.0.1** by default, so only this computer can reach it, and it warns
16
+ when started with another `--host`. While on 127.0.0.1, it refuses requests addressed to
17
+ any other name, so a website can't reach it through DNS rebinding.
18
+ - **It needs its key.** Every request must carry it (`Authorization: Bearer <key>`); it is
19
+ compared in constant time, and keys shorter than 16 characters are refused. Without a key,
20
+ a new random one is made at each start. `FLOWSHAPE_AGENT_KEY` or `--key-file` keep it out
21
+ of shell history and the process list.
22
+ - **It answers FlowShape's page only.** Browsers send the page's origin; the agent refuses
23
+ any origin but app.flowshape.io (and any `--origin` you add).
24
+ - **It runs tools without a shell**, with fixed arguments, and with the rights of whoever
25
+ runs it. Give it a read-only identity: Azure Reader, the Kubernetes `view` role, a Grafana
26
+ Viewer token.
27
+ - **It drops secrets before they leave it:** Kubernetes Secrets keep their names but lose
28
+ their values; values Terraform marks sensitive are removed, in state and plans; files given
29
+ with `--file` get the same treatment. Anything a tool prints that isn't marked secret (a
30
+ ConfigMap, an environment variable written straight into a pod spec) is passed on as
31
+ printed.
32
+ - **The Grafana token stays on this machine.** FlowShape gets only the answers, and Grafana's
33
+ address without any user name or password in it.
34
+ - **It keeps nothing on disk.** The last results stay in memory until it stops.