redberry-cli 0.0.0__tar.gz → 0.2.0__tar.gz
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.
- redberry_cli-0.2.0/LICENSE +91 -0
- redberry_cli-0.2.0/NOTICE +5 -0
- redberry_cli-0.2.0/PKG-INFO +131 -0
- redberry_cli-0.2.0/README.md +104 -0
- redberry_cli-0.2.0/pyproject.toml +52 -0
- redberry_cli-0.2.0/setup.cfg +4 -0
- redberry_cli-0.2.0/src/redberry_cli/__init__.py +13 -0
- redberry_cli-0.2.0/src/redberry_cli/_channel.py +5 -0
- redberry_cli-0.2.0/src/redberry_cli/_cloud.py +63 -0
- redberry_cli-0.2.0/src/redberry_cli/_edits.py +325 -0
- redberry_cli-0.2.0/src/redberry_cli/_scan.py +481 -0
- redberry_cli-0.2.0/src/redberry_cli/_ts_tools.py +389 -0
- redberry_cli-0.2.0/src/redberry_cli/_version.py +1 -0
- redberry_cli-0.2.0/src/redberry_cli/aws_lambda.py +580 -0
- redberry_cli-0.2.0/src/redberry_cli/azure_functions.py +751 -0
- redberry_cli-0.2.0/src/redberry_cli/instrument.py +250 -0
- redberry_cli-0.2.0/src/redberry_cli/main.py +475 -0
- redberry_cli-0.2.0/src/redberry_cli/vercel.py +384 -0
- redberry_cli-0.2.0/src/redberry_cli.egg-info/PKG-INFO +131 -0
- redberry_cli-0.2.0/src/redberry_cli.egg-info/SOURCES.txt +28 -0
- redberry_cli-0.2.0/src/redberry_cli.egg-info/dependency_links.txt +1 -0
- redberry_cli-0.2.0/src/redberry_cli.egg-info/entry_points.txt +2 -0
- redberry_cli-0.2.0/src/redberry_cli.egg-info/requires.txt +5 -0
- redberry_cli-0.2.0/src/redberry_cli.egg-info/top_level.txt +1 -0
- redberry_cli-0.2.0/tests/test_cli.py +279 -0
- redberry_cli-0.2.0/tests/test_cli_aws.py +420 -0
- redberry_cli-0.2.0/tests/test_cli_azure.py +416 -0
- redberry_cli-0.2.0/tests/test_cli_extract.py +253 -0
- redberry_cli-0.2.0/tests/test_cli_vercel.py +407 -0
- redberry_cli-0.2.0/tests/test_scan.py +251 -0
- redberry_cli-0.0.0/PKG-INFO +0 -17
- redberry_cli-0.0.0/README.md +0 -5
- redberry_cli-0.0.0/pyproject.toml +0 -17
- redberry_cli-0.0.0/src/redberry_cli/__init__.py +0 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Required Notice: Copyright 2026 Redberry Labs Ltd (https://redberrylabs.com)
|
|
2
|
+
|
|
3
|
+
# PolyForm Shield License 1.0.0
|
|
4
|
+
|
|
5
|
+
<https://polyformproject.org/licenses/shield/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. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
|
|
14
|
+
|
|
15
|
+
## Distribution License
|
|
16
|
+
|
|
17
|
+
The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
|
|
18
|
+
|
|
19
|
+
## Notices
|
|
20
|
+
|
|
21
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
|
|
22
|
+
|
|
23
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
24
|
+
|
|
25
|
+
## Changes and New Works License
|
|
26
|
+
|
|
27
|
+
The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
|
|
28
|
+
|
|
29
|
+
## Patent License
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
## Noncompete
|
|
34
|
+
|
|
35
|
+
Any purpose is a permitted purpose, except for providing any product that competes with the software or any product the licensor or any of its affiliates provides using the software.
|
|
36
|
+
|
|
37
|
+
## Competition
|
|
38
|
+
|
|
39
|
+
Goods and services compete even when they provide functionality through different kinds of interfaces or for different technical platforms. Applications can compete with services, libraries with plugins, frameworks with development tools, and so on, even if they're written in different programming languages or for different computer architectures. Goods and services compete even when provided free of charge. If you market a product as a practical substitute for the software or another product, it definitely competes.
|
|
40
|
+
|
|
41
|
+
## New Products
|
|
42
|
+
|
|
43
|
+
If you are using the software to provide a product that does not compete, but the licensor or any of its affiliates brings your product into competition by providing a new version of the software or another product using the software, you may continue using versions of the software available under these terms beforehand to provide your competing product, but not any later versions.
|
|
44
|
+
|
|
45
|
+
## Discontinued Products
|
|
46
|
+
|
|
47
|
+
You may begin using the software to compete with a product or service that the licensor or any of its affiliates has stopped providing, unless the licensor includes a plain-text line beginning with `Licensor Line of Business:` with the software that mentions that line of business. For example:
|
|
48
|
+
|
|
49
|
+
> Licensor Line of Business: YoyodyneCMS Content Management System (http://example.com/cms)
|
|
50
|
+
|
|
51
|
+
## Sales of Business
|
|
52
|
+
|
|
53
|
+
If the licensor or any of its affiliates sells a line of business developing the software or using the software to provide a product, the buyer can also enforce [Noncompete](#noncompete) for that product.
|
|
54
|
+
|
|
55
|
+
## Fair Use
|
|
56
|
+
|
|
57
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
58
|
+
|
|
59
|
+
## No Other Rights
|
|
60
|
+
|
|
61
|
+
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.
|
|
62
|
+
|
|
63
|
+
## Patent Defense
|
|
64
|
+
|
|
65
|
+
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.
|
|
66
|
+
|
|
67
|
+
## Violations
|
|
68
|
+
|
|
69
|
+
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.
|
|
70
|
+
|
|
71
|
+
## No Liability
|
|
72
|
+
|
|
73
|
+
***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.***
|
|
74
|
+
|
|
75
|
+
## Definitions
|
|
76
|
+
|
|
77
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
78
|
+
|
|
79
|
+
A **product** can be a good or service, or a combination of them.
|
|
80
|
+
|
|
81
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
82
|
+
|
|
83
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all its affiliates.
|
|
84
|
+
|
|
85
|
+
**Affiliates** means the other organizations than an organization has control over, is under the control of, or is under common control with.
|
|
86
|
+
|
|
87
|
+
**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.
|
|
88
|
+
|
|
89
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
90
|
+
|
|
91
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: redberry-cli
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: The redberry command: sign in to Redberry and wire an agent's code to send its spans to your Redberry install.
|
|
5
|
+
Author: Redberry Labs
|
|
6
|
+
License-Expression: LicenseRef-PolyForm-Shield-1.0.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/RedberryLabs/redberry-python
|
|
8
|
+
Project-URL: Source, https://github.com/RedberryLabs/redberry-python/tree/main/cli
|
|
9
|
+
Project-URL: Changelog, https://github.com/RedberryLabs/redberry-python/blob/main/cli/CHANGELOG.md
|
|
10
|
+
Keywords: redberry,ai agents,cli,opentelemetry
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
License-File: NOTICE
|
|
22
|
+
Requires-Dist: redberry-sdk>=0.3.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
25
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# redberry-cli
|
|
29
|
+
|
|
30
|
+
The `redberry` command. It signs a machine in to Redberry for your company, and wires an agent's code on AWS
|
|
31
|
+
Lambda, Azure Functions or Vercel so the agent sends its spans to your Redberry install. The agent itself uses
|
|
32
|
+
[`redberry-sdk`](https://pypi.org/project/redberry-sdk/) (Python) or
|
|
33
|
+
[`@redberrylabs/otel`](https://www.npmjs.com/package/@redberrylabs/otel) (Node.js).
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
uv tool install redberry-cli
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
or `pipx install redberry-cli`. Python 3.11 or later.
|
|
42
|
+
|
|
43
|
+
## Commands
|
|
44
|
+
|
|
45
|
+
| Command | What it does |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `redberry login` | Signs this machine in for your company with a device code that anyone signed in to the Redberry portal for the company approves. The session is kept in `~/.config/redberry/credentials.json` (mode 0600) for 30 days. |
|
|
48
|
+
| `redberry whoami` | The company this machine is signed in for. |
|
|
49
|
+
| `redberry logout` | Revokes the session at Redberry and forgets it here. |
|
|
50
|
+
| `redberry connect` | Without `--platform`: agents on a cloud install are set up from the Redberry portal's install command. |
|
|
51
|
+
| `redberry connect --platform aws-lambda` | Wires a Node.js or Python Lambda function (below). |
|
|
52
|
+
| `redberry connect --platform azure-functions` | Wires a Node.js (v4) or Python (v2) Azure function app (below). |
|
|
53
|
+
| `redberry connect --platform vercel` | Wires a Next.js app on the Vercel AI SDK, and sets the project's `REDBERRY_*` variables (below). |
|
|
54
|
+
|
|
55
|
+
The API is `https://api.redberry.sbs`; `--api` or `REDBERRY_API_URL` selects another. `--json` prints a
|
|
56
|
+
command's result for scripts.
|
|
57
|
+
|
|
58
|
+
## What `connect --platform` does
|
|
59
|
+
|
|
60
|
+
For AWS Lambda and Azure Functions, `connect` reads the function on the cloud (`aws lambda get-function-configuration`, `az functionapp show`),
|
|
61
|
+
finds the handler and the model calls it reaches in the code in `--repo` (default: the current folder), shows
|
|
62
|
+
the changes as a diff and asks before writing them (`--yes` applies them without asking). It never deploys
|
|
63
|
+
and sets nothing on the cloud: there is no key or setting to add, because the SDK finds your install from
|
|
64
|
+
where it runs.
|
|
65
|
+
|
|
66
|
+
**AWS Lambda** (`--function NAME [--region R]`): one agent per function, named by `--name` (default: the
|
|
67
|
+
function's name).
|
|
68
|
+
|
|
69
|
+
- Python: adds `redberry-sdk[providers]` to `requirements.txt`, `redberry_sdk.init(agent="…")` at module load,
|
|
70
|
+
and `@redberry_sdk.flush_after` on the handler, so its spans are sent before Lambda freezes the process.
|
|
71
|
+
- Node.js: adds `@redberrylabs/otel` (^0.5.0) and its OpenTelemetry peers to `package.json`, and
|
|
72
|
+
`init({ agent })` from `@redberrylabs/otel/init` at the top of the handler's file, with a small wrapper that
|
|
73
|
+
flushes the spans before the handler returns.
|
|
74
|
+
- The function's own role needs no policy; your install grants it. It must run in the account and region of
|
|
75
|
+
your install.
|
|
76
|
+
|
|
77
|
+
**Azure Functions** (`--app NAME --resource-group RG [--subscription S]`): the app is one agent, named by
|
|
78
|
+
`--name` (default: the app's name). `--name agent=function,agent=function2` picks the functions.
|
|
79
|
+
|
|
80
|
+
- Python: `redberry-sdk[providers]`, `redberry_sdk.init(agent="…")` in `function_app.py`, and
|
|
81
|
+
`@redberry_sdk.flush_after` under the trigger decorators of each agent function (not on `async def`
|
|
82
|
+
functions, whose spans are sent in the background).
|
|
83
|
+
- Node.js: `@redberrylabs/otel` (^0.5.0) and its peers, and a set-up module (`src/redberry.ts` or `.js`) that
|
|
84
|
+
calls `init({ agent })` and registers the AI SDK's OpenTelemetry integration, imported first by each agent's
|
|
85
|
+
function file.
|
|
86
|
+
- The app needs a managed identity that was chosen as an agent when your install was set up.
|
|
87
|
+
|
|
88
|
+
On both platforms `connect` sets `temperature` to 1 on each model call it finds (pricing needs exactly 1), and
|
|
89
|
+
writes what it found to `.redberry/aws-lambda.json` or `.redberry/azure-functions.json` (no secrets). Code an
|
|
90
|
+
earlier version of `connect` wired with the in-process hasher (`redberry_sdk.hasher`, `withRedberry`) is moved
|
|
91
|
+
to the form above when you run `connect` again.
|
|
92
|
+
|
|
93
|
+
**Vercel** (a Next.js app using the Vercel AI SDK, run in the app's folder): the app is one agent, named by
|
|
94
|
+
`--name` (default: the Vercel project's name from `.vercel/project.json`, else the package's).
|
|
95
|
+
|
|
96
|
+
- Writes `instrumentation.ts` (`src/instrumentation.ts` in a `src/app` layout): `@vercel/otel`'s
|
|
97
|
+
`registerOTel` with `redberryExporter(exporterOptionsFrom({}))` from `@redberrylabs/otel` as the trace
|
|
98
|
+
exporter, the agent's name as the resource attribute `redberry.agent.name`, and the AI SDK's OpenTelemetry
|
|
99
|
+
integration. An `instrumentation.ts` of your own is left as it is, and the code to merge is printed.
|
|
100
|
+
- Adds `@redberrylabs/otel` (^0.6.0), `@vercel/otel`, `@ai-sdk/otel` and the OpenTelemetry peers to
|
|
101
|
+
`package.json`, and sets `temperature` to 1 on each model call the app's routes reach.
|
|
102
|
+
- The exporter reads `REDBERRY_*` variables: the install prints them when it is run with `--vercel-team`
|
|
103
|
+
(`REDBERRY_CLOUD`, `REDBERRY_INGEST_URL` and the cloud's federation names). Save that output to a file and
|
|
104
|
+
pass `--env-file FILE`, or export the variables before running `connect`. `connect` checks the set is complete
|
|
105
|
+
for the cloud and, when the app is linked (`vercel link`) and the Vercel CLI is installed, sets them on the
|
|
106
|
+
project's production environment with `vercel env add`. `--no-env` prints them instead. None of them is a
|
|
107
|
+
secret: the deployment's Vercel OIDC token is exchanged for a short-lived credential.
|
|
108
|
+
- Turn on the project's OIDC federation (Settings > Security > Secure backend access, team issuer).
|
|
109
|
+
|
|
110
|
+
An app connected by an earlier version with the in-process hasher gets the new `instrumentation.ts`; remove the
|
|
111
|
+
old variables it set (`REDBERRY_SIGNING_KEY`, `REDBERRY_PROJECT_TOKEN` and the others) from the project.
|
|
112
|
+
|
|
113
|
+
## `connect --extract`: the agent's manifest
|
|
114
|
+
|
|
115
|
+
`--extract` writes the agent's manifest (`.redberry/manifest.json`) with `redberry-extract` and the LLM key already
|
|
116
|
+
in your environment (`ANTHROPIC_API_KEY`, else `OPENAI_API_KEY`). The agent's code is sent only to that key's
|
|
117
|
+
provider. Without `--extract`, `connect` asks first.
|
|
118
|
+
|
|
119
|
+
A `redberry-extract` on PATH is used as it is. Otherwise `connect` installs it:
|
|
120
|
+
|
|
121
|
+
- It needs `redberry login` (the extractor is licensed to your company) and
|
|
122
|
+
[uv](https://docs.astral.sh/uv/) (`curl -LsSf https://astral.sh/uv/install.sh | sh` or `pipx install uv`).
|
|
123
|
+
- The Redberry Extractor Licence is shown and accepted once per company, and again when a new version is
|
|
124
|
+
published. `--yes` does not accept it; in a script or with `--json`, pass `--accept-extractor-licence`.
|
|
125
|
+
- It is installed with uv into its own environment in `~/.redberry/extractor/<version>/` (`$REDBERRY_HOME`
|
|
126
|
+
overrides `~/.redberry`), from Redberry's package index with a short-lived download token that is passed to uv
|
|
127
|
+
in its environment only. Later runs reuse that install.
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
See [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# redberry-cli
|
|
2
|
+
|
|
3
|
+
The `redberry` command. It signs a machine in to Redberry for your company, and wires an agent's code on AWS
|
|
4
|
+
Lambda, Azure Functions or Vercel so the agent sends its spans to your Redberry install. The agent itself uses
|
|
5
|
+
[`redberry-sdk`](https://pypi.org/project/redberry-sdk/) (Python) or
|
|
6
|
+
[`@redberrylabs/otel`](https://www.npmjs.com/package/@redberrylabs/otel) (Node.js).
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
uv tool install redberry-cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
or `pipx install redberry-cli`. Python 3.11 or later.
|
|
15
|
+
|
|
16
|
+
## Commands
|
|
17
|
+
|
|
18
|
+
| Command | What it does |
|
|
19
|
+
|---|---|
|
|
20
|
+
| `redberry login` | Signs this machine in for your company with a device code that anyone signed in to the Redberry portal for the company approves. The session is kept in `~/.config/redberry/credentials.json` (mode 0600) for 30 days. |
|
|
21
|
+
| `redberry whoami` | The company this machine is signed in for. |
|
|
22
|
+
| `redberry logout` | Revokes the session at Redberry and forgets it here. |
|
|
23
|
+
| `redberry connect` | Without `--platform`: agents on a cloud install are set up from the Redberry portal's install command. |
|
|
24
|
+
| `redberry connect --platform aws-lambda` | Wires a Node.js or Python Lambda function (below). |
|
|
25
|
+
| `redberry connect --platform azure-functions` | Wires a Node.js (v4) or Python (v2) Azure function app (below). |
|
|
26
|
+
| `redberry connect --platform vercel` | Wires a Next.js app on the Vercel AI SDK, and sets the project's `REDBERRY_*` variables (below). |
|
|
27
|
+
|
|
28
|
+
The API is `https://api.redberry.sbs`; `--api` or `REDBERRY_API_URL` selects another. `--json` prints a
|
|
29
|
+
command's result for scripts.
|
|
30
|
+
|
|
31
|
+
## What `connect --platform` does
|
|
32
|
+
|
|
33
|
+
For AWS Lambda and Azure Functions, `connect` reads the function on the cloud (`aws lambda get-function-configuration`, `az functionapp show`),
|
|
34
|
+
finds the handler and the model calls it reaches in the code in `--repo` (default: the current folder), shows
|
|
35
|
+
the changes as a diff and asks before writing them (`--yes` applies them without asking). It never deploys
|
|
36
|
+
and sets nothing on the cloud: there is no key or setting to add, because the SDK finds your install from
|
|
37
|
+
where it runs.
|
|
38
|
+
|
|
39
|
+
**AWS Lambda** (`--function NAME [--region R]`): one agent per function, named by `--name` (default: the
|
|
40
|
+
function's name).
|
|
41
|
+
|
|
42
|
+
- Python: adds `redberry-sdk[providers]` to `requirements.txt`, `redberry_sdk.init(agent="…")` at module load,
|
|
43
|
+
and `@redberry_sdk.flush_after` on the handler, so its spans are sent before Lambda freezes the process.
|
|
44
|
+
- Node.js: adds `@redberrylabs/otel` (^0.5.0) and its OpenTelemetry peers to `package.json`, and
|
|
45
|
+
`init({ agent })` from `@redberrylabs/otel/init` at the top of the handler's file, with a small wrapper that
|
|
46
|
+
flushes the spans before the handler returns.
|
|
47
|
+
- The function's own role needs no policy; your install grants it. It must run in the account and region of
|
|
48
|
+
your install.
|
|
49
|
+
|
|
50
|
+
**Azure Functions** (`--app NAME --resource-group RG [--subscription S]`): the app is one agent, named by
|
|
51
|
+
`--name` (default: the app's name). `--name agent=function,agent=function2` picks the functions.
|
|
52
|
+
|
|
53
|
+
- Python: `redberry-sdk[providers]`, `redberry_sdk.init(agent="…")` in `function_app.py`, and
|
|
54
|
+
`@redberry_sdk.flush_after` under the trigger decorators of each agent function (not on `async def`
|
|
55
|
+
functions, whose spans are sent in the background).
|
|
56
|
+
- Node.js: `@redberrylabs/otel` (^0.5.0) and its peers, and a set-up module (`src/redberry.ts` or `.js`) that
|
|
57
|
+
calls `init({ agent })` and registers the AI SDK's OpenTelemetry integration, imported first by each agent's
|
|
58
|
+
function file.
|
|
59
|
+
- The app needs a managed identity that was chosen as an agent when your install was set up.
|
|
60
|
+
|
|
61
|
+
On both platforms `connect` sets `temperature` to 1 on each model call it finds (pricing needs exactly 1), and
|
|
62
|
+
writes what it found to `.redberry/aws-lambda.json` or `.redberry/azure-functions.json` (no secrets). Code an
|
|
63
|
+
earlier version of `connect` wired with the in-process hasher (`redberry_sdk.hasher`, `withRedberry`) is moved
|
|
64
|
+
to the form above when you run `connect` again.
|
|
65
|
+
|
|
66
|
+
**Vercel** (a Next.js app using the Vercel AI SDK, run in the app's folder): the app is one agent, named by
|
|
67
|
+
`--name` (default: the Vercel project's name from `.vercel/project.json`, else the package's).
|
|
68
|
+
|
|
69
|
+
- Writes `instrumentation.ts` (`src/instrumentation.ts` in a `src/app` layout): `@vercel/otel`'s
|
|
70
|
+
`registerOTel` with `redberryExporter(exporterOptionsFrom({}))` from `@redberrylabs/otel` as the trace
|
|
71
|
+
exporter, the agent's name as the resource attribute `redberry.agent.name`, and the AI SDK's OpenTelemetry
|
|
72
|
+
integration. An `instrumentation.ts` of your own is left as it is, and the code to merge is printed.
|
|
73
|
+
- Adds `@redberrylabs/otel` (^0.6.0), `@vercel/otel`, `@ai-sdk/otel` and the OpenTelemetry peers to
|
|
74
|
+
`package.json`, and sets `temperature` to 1 on each model call the app's routes reach.
|
|
75
|
+
- The exporter reads `REDBERRY_*` variables: the install prints them when it is run with `--vercel-team`
|
|
76
|
+
(`REDBERRY_CLOUD`, `REDBERRY_INGEST_URL` and the cloud's federation names). Save that output to a file and
|
|
77
|
+
pass `--env-file FILE`, or export the variables before running `connect`. `connect` checks the set is complete
|
|
78
|
+
for the cloud and, when the app is linked (`vercel link`) and the Vercel CLI is installed, sets them on the
|
|
79
|
+
project's production environment with `vercel env add`. `--no-env` prints them instead. None of them is a
|
|
80
|
+
secret: the deployment's Vercel OIDC token is exchanged for a short-lived credential.
|
|
81
|
+
- Turn on the project's OIDC federation (Settings > Security > Secure backend access, team issuer).
|
|
82
|
+
|
|
83
|
+
An app connected by an earlier version with the in-process hasher gets the new `instrumentation.ts`; remove the
|
|
84
|
+
old variables it set (`REDBERRY_SIGNING_KEY`, `REDBERRY_PROJECT_TOKEN` and the others) from the project.
|
|
85
|
+
|
|
86
|
+
## `connect --extract`: the agent's manifest
|
|
87
|
+
|
|
88
|
+
`--extract` writes the agent's manifest (`.redberry/manifest.json`) with `redberry-extract` and the LLM key already
|
|
89
|
+
in your environment (`ANTHROPIC_API_KEY`, else `OPENAI_API_KEY`). The agent's code is sent only to that key's
|
|
90
|
+
provider. Without `--extract`, `connect` asks first.
|
|
91
|
+
|
|
92
|
+
A `redberry-extract` on PATH is used as it is. Otherwise `connect` installs it:
|
|
93
|
+
|
|
94
|
+
- It needs `redberry login` (the extractor is licensed to your company) and
|
|
95
|
+
[uv](https://docs.astral.sh/uv/) (`curl -LsSf https://astral.sh/uv/install.sh | sh` or `pipx install uv`).
|
|
96
|
+
- The Redberry Extractor Licence is shown and accepted once per company, and again when a new version is
|
|
97
|
+
published. `--yes` does not accept it; in a script or with `--json`, pass `--accept-extractor-licence`.
|
|
98
|
+
- It is installed with uv into its own environment in `~/.redberry/extractor/<version>/` (`$REDBERRY_HOME`
|
|
99
|
+
overrides `~/.redberry`), from Redberry's package index with a short-lived download token that is passed to uv
|
|
100
|
+
in its environment only. Later runs reuse that install.
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
See [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "redberry-cli"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "The redberry command: sign in to Redberry and wire an agent's code to send its spans to your Redberry install."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "LicenseRef-PolyForm-Shield-1.0.0"
|
|
11
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
12
|
+
authors = [{ name = "Redberry Labs" }]
|
|
13
|
+
requires-python = ">=3.11"
|
|
14
|
+
keywords = ["redberry", "ai agents", "cli", "opentelemetry"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
]
|
|
24
|
+
dependencies = ["redberry-sdk>=0.3.0"]
|
|
25
|
+
|
|
26
|
+
[project.optional-dependencies]
|
|
27
|
+
dev = ["pytest>=8.0", "ruff>=0.6"]
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
redberry = "redberry_cli.main:main"
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/RedberryLabs/redberry-python"
|
|
34
|
+
Source = "https://github.com/RedberryLabs/redberry-python/tree/main/cli"
|
|
35
|
+
Changelog = "https://github.com/RedberryLabs/redberry-python/blob/main/cli/CHANGELOG.md"
|
|
36
|
+
|
|
37
|
+
[tool.setuptools.dynamic]
|
|
38
|
+
version = { attr = "redberry_cli._version.__version__" }
|
|
39
|
+
|
|
40
|
+
[tool.setuptools.packages.find]
|
|
41
|
+
where = ["src"]
|
|
42
|
+
include = ["redberry_cli*"]
|
|
43
|
+
|
|
44
|
+
[tool.pytest.ini_options]
|
|
45
|
+
testpaths = ["tests"]
|
|
46
|
+
|
|
47
|
+
[tool.ruff]
|
|
48
|
+
line-length = 120
|
|
49
|
+
target-version = "py311"
|
|
50
|
+
|
|
51
|
+
[tool.ruff.lint]
|
|
52
|
+
select = ["E4", "E7", "E9", "F"]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""The ``redberry`` command: sign in, then wire an agent to send its spans to your Redberry install.
|
|
2
|
+
|
|
3
|
+
redberry login sign this machine in for your company (a device code you approve in the portal)
|
|
4
|
+
redberry whoami the company this machine is signed in for
|
|
5
|
+
redberry connect wire an agent's code (--platform aws-lambda | azure-functions)
|
|
6
|
+
redberry logout forget the session
|
|
7
|
+
|
|
8
|
+
See ``redberry_cli.main`` for what each command does.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from redberry_cli._version import __version__
|
|
12
|
+
|
|
13
|
+
__all__ = ["__version__"]
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""The ``aws`` and ``az`` command-line tools, as ``connect --platform aws-lambda | azure-functions`` runs them
|
|
2
|
+
to read a function: where each binary is, a runner that says how to install it when it is missing, and the
|
|
3
|
+
AWS region check."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import re
|
|
9
|
+
import shutil
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SetupError(Exception):
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
_REGION = re.compile(r"[a-z]{2}(-[a-z]+)+-\d")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def aws_binary() -> str:
|
|
21
|
+
"""``$AWS``, else ``aws`` on PATH, else the CLI in ``~/.aws-cli-venv`` (a pip install of awscli)."""
|
|
22
|
+
if os.environ.get("AWS"):
|
|
23
|
+
return os.environ["AWS"]
|
|
24
|
+
found = shutil.which("aws")
|
|
25
|
+
if found:
|
|
26
|
+
return found
|
|
27
|
+
venv = Path.home() / ".aws-cli-venv" / "bin" / "aws"
|
|
28
|
+
return str(venv) if venv.exists() else "aws"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def aws(run, cmd: list[str], **kw):
|
|
32
|
+
"""Run ``cmd`` (written as ``["aws", …]``) with the resolved aws binary."""
|
|
33
|
+
try:
|
|
34
|
+
return run([aws_binary(), *cmd[1:]], capture_output=True, text=True, **kw)
|
|
35
|
+
except OSError:
|
|
36
|
+
raise SetupError("the AWS CLI (aws) is not installed: https://docs.aws.amazon.com/cli/latest/userguide/"
|
|
37
|
+
"getting-started-install.html, then `aws configure` or `aws sso login`") from None
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def region(value: str | None, flag: str = "--region") -> str:
|
|
41
|
+
if not _REGION.fullmatch(value or ""):
|
|
42
|
+
raise SetupError(f"{flag}: an AWS region, e.g. eu-west-1 or us-east-1")
|
|
43
|
+
return value # type: ignore[return-value]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def az_binary() -> str:
|
|
47
|
+
"""``$AZ``, else ``az`` on PATH, else the CLI in ``~/.azure-cli-venv`` (a pip install of azure-cli)."""
|
|
48
|
+
if os.environ.get("AZ"):
|
|
49
|
+
return os.environ["AZ"]
|
|
50
|
+
found = shutil.which("az")
|
|
51
|
+
if found:
|
|
52
|
+
return found
|
|
53
|
+
venv = Path.home() / ".azure-cli-venv" / "bin" / "az"
|
|
54
|
+
return str(venv) if venv.exists() else "az"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def az(run, cmd: list[str], **kw):
|
|
58
|
+
"""Run ``cmd`` (written as ``["az", …]``) with the resolved az binary."""
|
|
59
|
+
try:
|
|
60
|
+
return run([az_binary(), *cmd[1:]], capture_output=True, text=True, **kw)
|
|
61
|
+
except OSError:
|
|
62
|
+
raise SetupError("the Azure CLI (az) is not installed: https://learn.microsoft.com/cli/azure/install-azure-cli,"
|
|
63
|
+
" then `az login`") from None
|