@pydantic/logfire-agent-sandboxes 0.1.1 → 0.2.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 +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Run Python that your AI agents write in isolated, remote [Pydantic Monty](https:
|
|
|
4
4
|
hosted by [Pydantic Logfire](https://pydantic.dev/logfire), from Node.js.
|
|
5
5
|
|
|
6
6
|
```bash
|
|
7
|
-
npm install @pydantic/logfire-agent-sandboxes @pydantic/monty@^1.
|
|
7
|
+
npm install @pydantic/logfire-agent-sandboxes @pydantic/monty@^1.5.0
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
Create a Logfire project API key with the **Run code in this project's agent sandboxes** permission
|
|
@@ -18,8 +18,8 @@ await using session = await pool.checkout()
|
|
|
18
18
|
console.log(await session.feedRun('sum([20, 21, 1])')) // 42
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
`agentSandboxes()` resolves to a `
|
|
22
|
-
and the trace context active at each checkout. It accepts every `
|
|
21
|
+
`agentSandboxes()` resolves to a `MontyRemote` pool from `@pydantic/monty`, set up with your API key, region URL,
|
|
22
|
+
and the trace context active at each checkout. It accepts every `MontyRemote` option, plus `apiKey` and `url`.
|
|
23
23
|
|
|
24
24
|
See the [Agent Sandboxes docs](https://github.com/pydantic/logfire-js/blob/main/docs/agent-sandboxes.md) for host
|
|
25
25
|
functions, sessions, snapshots, and options.
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@opentelemetry/api"),t=require("@pydantic/monty"),n=require("logfire");function r(e){
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@opentelemetry/api"),t=require("@pydantic/monty"),n=require("logfire");function r(e){return e.replace(/\/+$/u,``)}async function i(i={}){let{apiKey:o,connectHeaders:s,metadata:c,url:l,...u}=i,d=[o,process.env.LOGFIRE_API_KEY].find(e=>e!==void 0&&e!==``);if(d===void 0)throw Error("Agent sandboxes require a Logfire API key with the `project:execute_agent_sandboxes` scope. Set the LOGFIRE_API_KEY environment variable or pass `apiKey` to `agentSandboxes()`.");if(c!==void 0&&s!==void 0)throw TypeError(`pass metadata, not connectHeaders as well`);let f=c??s,p=l??r((0,n.resolveBaseUrl)(process.env,void 0,d)),m=async()=>{let t={};e.propagation.inject(e.context.active(),t),t.authorization=`Bearer ${d}`;let n=a(t);return f===void 0?n:{...n,...a(await f())}};return t.MontyRemote.create(p,{...u,metadata:m})}function a(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e.toLowerCase(),t]))}exports.agentSandboxes=i;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MontyRemote, MontyRemoteOptions } from "@pydantic/monty";
|
|
2
2
|
//#region src/index.d.ts
|
|
3
|
-
export interface AgentSandboxesOptions extends
|
|
3
|
+
export interface AgentSandboxesOptions extends MontyRemoteOptions {
|
|
4
4
|
/**
|
|
5
5
|
* A Logfire API key with the `project:execute_agent_sandboxes` scope.
|
|
6
6
|
* Defaults to the `LOGFIRE_API_KEY` environment variable.
|
|
7
7
|
*/
|
|
8
8
|
apiKey?: string;
|
|
9
9
|
/**
|
|
10
|
-
* The
|
|
10
|
+
* The `https://` or `http://` URL of the sandboxes server, with no path.
|
|
11
11
|
* Defaults to the Logfire region the API key belongs to, or `LOGFIRE_BASE_URL` when set.
|
|
12
12
|
*/
|
|
13
13
|
url?: string;
|
|
@@ -15,7 +15,7 @@ export interface AgentSandboxesOptions extends MontyWebsocketOptions {
|
|
|
15
15
|
/**
|
|
16
16
|
* Connects to Logfire Agent Sandboxes, remote Pydantic Monty workers hosted by Logfire.
|
|
17
17
|
*
|
|
18
|
-
* Resolves to a `
|
|
18
|
+
* Resolves to a `MontyRemote` pool from `@pydantic/monty`; check out sessions from it:
|
|
19
19
|
*
|
|
20
20
|
* ```ts
|
|
21
21
|
* await using pool = await agentSandboxes()
|
|
@@ -27,7 +27,8 @@ export interface AgentSandboxesOptions extends MontyWebsocketOptions {
|
|
|
27
27
|
* with each checkout, so the spans Logfire records for the session join the caller's trace.
|
|
28
28
|
*
|
|
29
29
|
* Omitted pool options use the defaults of the installed `@pydantic/monty` version.
|
|
30
|
-
* `
|
|
30
|
+
* `metadata` results (or those of `connectHeaders`, its deprecated former name) are merged over
|
|
31
|
+
* the Logfire `authorization` metadata and win on conflicts. Names match case-insensitively.
|
|
31
32
|
*/
|
|
32
|
-
export declare function agentSandboxes(options?: AgentSandboxesOptions): Promise<
|
|
33
|
+
export declare function agentSandboxes(options?: AgentSandboxesOptions): Promise<MontyRemote>;
|
|
33
34
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MontyRemote, MontyRemoteOptions } from "@pydantic/monty";
|
|
2
2
|
//#region src/index.d.ts
|
|
3
|
-
export interface AgentSandboxesOptions extends
|
|
3
|
+
export interface AgentSandboxesOptions extends MontyRemoteOptions {
|
|
4
4
|
/**
|
|
5
5
|
* A Logfire API key with the `project:execute_agent_sandboxes` scope.
|
|
6
6
|
* Defaults to the `LOGFIRE_API_KEY` environment variable.
|
|
7
7
|
*/
|
|
8
8
|
apiKey?: string;
|
|
9
9
|
/**
|
|
10
|
-
* The
|
|
10
|
+
* The `https://` or `http://` URL of the sandboxes server, with no path.
|
|
11
11
|
* Defaults to the Logfire region the API key belongs to, or `LOGFIRE_BASE_URL` when set.
|
|
12
12
|
*/
|
|
13
13
|
url?: string;
|
|
@@ -15,7 +15,7 @@ export interface AgentSandboxesOptions extends MontyWebsocketOptions {
|
|
|
15
15
|
/**
|
|
16
16
|
* Connects to Logfire Agent Sandboxes, remote Pydantic Monty workers hosted by Logfire.
|
|
17
17
|
*
|
|
18
|
-
* Resolves to a `
|
|
18
|
+
* Resolves to a `MontyRemote` pool from `@pydantic/monty`; check out sessions from it:
|
|
19
19
|
*
|
|
20
20
|
* ```ts
|
|
21
21
|
* await using pool = await agentSandboxes()
|
|
@@ -27,7 +27,8 @@ export interface AgentSandboxesOptions extends MontyWebsocketOptions {
|
|
|
27
27
|
* with each checkout, so the spans Logfire records for the session join the caller's trace.
|
|
28
28
|
*
|
|
29
29
|
* Omitted pool options use the defaults of the installed `@pydantic/monty` version.
|
|
30
|
-
* `
|
|
30
|
+
* `metadata` results (or those of `connectHeaders`, its deprecated former name) are merged over
|
|
31
|
+
* the Logfire `authorization` metadata and win on conflicts. Names match case-insensitively.
|
|
31
32
|
*/
|
|
32
|
-
export declare function agentSandboxes(options?: AgentSandboxesOptions): Promise<
|
|
33
|
+
export declare function agentSandboxes(options?: AgentSandboxesOptions): Promise<MontyRemote>;
|
|
33
34
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{context as e,propagation as t}from"@opentelemetry/api";import{
|
|
1
|
+
import{context as e,propagation as t}from"@opentelemetry/api";import{MontyRemote as n}from"@pydantic/monty";import{resolveBaseUrl as r}from"logfire";function i(e){return e.replace(/\/+$/u,``)}async function a(a={}){let{apiKey:s,connectHeaders:c,metadata:l,url:u,...d}=a,f=[s,process.env.LOGFIRE_API_KEY].find(e=>e!==void 0&&e!==``);if(f===void 0)throw Error("Agent sandboxes require a Logfire API key with the `project:execute_agent_sandboxes` scope. Set the LOGFIRE_API_KEY environment variable or pass `apiKey` to `agentSandboxes()`.");if(l!==void 0&&c!==void 0)throw TypeError(`pass metadata, not connectHeaders as well`);let p=l??c,m=u??i(r(process.env,void 0,f)),h=async()=>{let n={};t.inject(e.active(),n),n.authorization=`Bearer ${f}`;let r=o(n);return p===void 0?r:{...r,...o(await p())}};return n.create(m,{...d,metadata:h})}function o(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e.toLowerCase(),t]))}export{a as agentSandboxes};
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"agents",
|
|
24
24
|
"python"
|
|
25
25
|
],
|
|
26
|
-
"version": "0.
|
|
26
|
+
"version": "0.2.0",
|
|
27
27
|
"type": "module",
|
|
28
28
|
"main": "./dist/index.cjs",
|
|
29
29
|
"module": "./dist/index.js",
|
|
@@ -45,13 +45,14 @@
|
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@opentelemetry/api": ">=1.9.1 <1.10.0",
|
|
48
|
-
"@pydantic/monty": "^1.
|
|
48
|
+
"@pydantic/monty": "^1.5.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
+
"@grpc/grpc-js": "^1.14.5",
|
|
51
52
|
"@opentelemetry/api": ">=1.9.1 <1.10.0",
|
|
52
53
|
"@opentelemetry/context-async-hooks": "^2.8.0",
|
|
53
54
|
"@opentelemetry/core": "^2.8.0",
|
|
54
|
-
"@pydantic/monty": "^1.
|
|
55
|
+
"@pydantic/monty": "^1.5.0",
|
|
55
56
|
"@types/node": "^22.5.1",
|
|
56
57
|
"vitest": "5.0.1"
|
|
57
58
|
},
|