@aexhq/env 0.0.0 → 0.1.1
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 +25 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/packages/env/src/index.d.ts +13 -0
- package/dist/packages/env/src/index.js +34 -0
- package/package.json +47 -11
- package/index.js +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# env
|
|
2
|
+
|
|
3
|
+
Give a Brain model controlled access to its environments. This is an ordinary Tool over
|
|
4
|
+
`ctx.environments`, with the same interface available to any third-party Tool.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { env } from "@aexhq/env";
|
|
8
|
+
|
|
9
|
+
const debug = env({
|
|
10
|
+
environments: [{ environment: "workspace", permissions: ["read", "call"], methods: ["inspect"] }],
|
|
11
|
+
});
|
|
12
|
+
// Include debug in your session's tools; lifecycle defaults to automatic.
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
It defaults to your application's host. Place it in a prepared Node Environment to run it
|
|
16
|
+
remotely. Keep that placement independent of any environment it may delete or replace.
|
|
17
|
+
|
|
18
|
+
The input operations are `list`, `get`, `create`, `update`, `setup`, `delete` and `call`.
|
|
19
|
+
Use the current `{ name, sequence }` reference returned by `list` or `get`. `get` reads
|
|
20
|
+
recorded state; `call` invokes a method declared by the Env. There is no universal inspect
|
|
21
|
+
or restart method. Resources such as tabs and jobs use the Env's own methods and schemas.
|
|
22
|
+
|
|
23
|
+
Creation requires an application-authorized template and a `create` grant. Setup defaults to
|
|
24
|
+
automatic; override it with `environment.lifecycle`. Adding this Tool never changes it. See Brain's
|
|
25
|
+
[environment control guide](https://aex.dev/brain/docs/guides/environment-control).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const env: typeof import("./packages/env/src/index.js")["env"];
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { bindTool } from "@aexhq/brain";
|
|
2
|
+
export const env = bindTool({"definition":{"name":"env","description":"Read or manage authorized Environments. List first for current references, recorded state and supported methods. Get reads cached state; call invokes an Environment-defined method such as inspect or restart. Never assume an uncertain operation did not run.","inputSchema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"operation":{"type":"string","enum":["list","get","create","update","setup","delete","call"]},"environment":{"type":"object","properties":{"name":{"type":"string","minLength":1},"sequence":{"type":"integer","exclusiveMinimum":0,"maximum":9007199254740991}},"required":["name","sequence"],"additionalProperties":false},"template":{"type":"string","minLength":1},"name":{"type":"string","minLength":1},"configuration":{"$ref":"#/$defs/__schema0"},"method":{"type":"string","minLength":1},"input":{"$ref":"#/$defs/__schema1"}},"required":["operation"],"additionalProperties":false,"$defs":{"__schema0":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"},{"type":"null"},{"type":"array","items":{"$ref":"#/$defs/__schema0"}},{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"$ref":"#/$defs/__schema0"}}]},"__schema1":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"},{"type":"null"},{"type":"array","items":{"$ref":"#/$defs/__schema1"}},{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"$ref":"#/$defs/__schema1"}}]}}}}}, {"type":"node_package","package":"@aexhq/env","version":"0.1.1","entry":"./runtime","export":"env"}, { url: new URL("./packages/env/src/index.js", import.meta.url), export: "env" });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const env: import("@aexhq/brain").ToolFactory<undefined, {
|
|
3
|
+
operation: "update" | "create" | "setup" | "delete" | "call" | "list" | "get";
|
|
4
|
+
environment?: {
|
|
5
|
+
name: string;
|
|
6
|
+
sequence: number;
|
|
7
|
+
} | undefined;
|
|
8
|
+
template?: string | undefined;
|
|
9
|
+
name?: string | undefined;
|
|
10
|
+
configuration?: z.core.util.JSONType | undefined;
|
|
11
|
+
method?: string | undefined;
|
|
12
|
+
input?: z.core.util.JSONType | undefined;
|
|
13
|
+
}, unknown>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { tool } from "@aexhq/brain";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const reference = z.strictObject({ name: z.string().min(1), sequence: z.number().int().positive().safe() });
|
|
4
|
+
const request = z.discriminatedUnion("operation", [
|
|
5
|
+
z.strictObject({ operation: z.literal("list") }),
|
|
6
|
+
z.strictObject({ operation: z.literal("get"), environment: reference }),
|
|
7
|
+
z.strictObject({ operation: z.literal("create"), template: z.string().min(1), name: z.string().min(1), configuration: z.json() }),
|
|
8
|
+
z.strictObject({ operation: z.literal("update"), environment: reference, configuration: z.json() }),
|
|
9
|
+
z.strictObject({ operation: z.literal("setup"), environment: reference }),
|
|
10
|
+
z.strictObject({ operation: z.literal("delete"), environment: reference }),
|
|
11
|
+
z.strictObject({ operation: z.literal("call"), environment: reference, method: z.string().min(1), input: z.json() }),
|
|
12
|
+
]);
|
|
13
|
+
const input = z.strictObject({
|
|
14
|
+
operation: z.enum(["list", "get", "create", "update", "setup", "delete", "call"]),
|
|
15
|
+
environment: reference.optional(), template: z.string().min(1).optional(), name: z.string().min(1).optional(),
|
|
16
|
+
configuration: z.json().optional(), method: z.string().min(1).optional(), input: z.json().optional(),
|
|
17
|
+
}).pipe(request);
|
|
18
|
+
export const env = tool({
|
|
19
|
+
name: "env",
|
|
20
|
+
description: "Read or manage authorized Environments. List first for current references, recorded state and supported methods. Get reads cached state; call invokes an Environment-defined method such as inspect or restart. Never assume an uncertain operation did not run.",
|
|
21
|
+
input,
|
|
22
|
+
async run(request, context) {
|
|
23
|
+
const environments = context.environments;
|
|
24
|
+
switch (request.operation) {
|
|
25
|
+
case "list": return context.finish(await environments.list());
|
|
26
|
+
case "get": return context.finish(await environments.get(request.environment));
|
|
27
|
+
case "create": return context.finish(await environments.create(request.template, request.name, request.configuration));
|
|
28
|
+
case "update": return context.finish(await environments.update(request.environment, request.configuration));
|
|
29
|
+
case "setup": return context.finish(await environments.setup(request.environment));
|
|
30
|
+
case "delete": return context.finish(await environments.delete(request.environment));
|
|
31
|
+
case "call": return context.finish(await environments.call(request.environment, request.method, request.input));
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
});
|
package/package.json
CHANGED
|
@@ -1,19 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aexhq/env",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"license": "
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "An ordinary Brain Tool for scoped Environment control.",
|
|
5
|
+
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22.0.0"
|
|
10
|
+
},
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/aexhq/extensions.git"
|
|
13
|
+
"url": "git+https://github.com/aexhq/extensions.git",
|
|
14
|
+
"directory": "packages/env"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public",
|
|
18
|
+
"provenance": true,
|
|
19
|
+
"tag": "next"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./runtime": {
|
|
27
|
+
"types": "./dist/packages/env/src/index.d.ts",
|
|
28
|
+
"import": "./dist/packages/env/src/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"README.md"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "node ../../tools/clean-dist.mjs && tsc -p tsconfig.json && brain-tools",
|
|
38
|
+
"test": "npm run build && node --test test/*.test.mjs",
|
|
39
|
+
"prepack": "npm run build"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@aexhq/brain": "0.33.0",
|
|
43
|
+
"zod": "4.4.3"
|
|
14
44
|
},
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
45
|
+
"brain": {
|
|
46
|
+
"tools": {
|
|
47
|
+
".": {
|
|
48
|
+
"runtime": "./runtime",
|
|
49
|
+
"exports": [
|
|
50
|
+
"env"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
18
54
|
}
|
|
19
55
|
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
throw new Error("@aexhq/env has no stable release; install @aexhq/env@next or an exact version");
|