@agentproto/sandbox 0.1.0-alpha.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 +21 -0
- package/README.md +23 -0
- package/dist/chunk-VSYQ4BUI.mjs +47 -0
- package/dist/chunk-VSYQ4BUI.mjs.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.mjs +14 -0
- package/dist/index.mjs.map +1 -0
- package/dist/manifest/index.d.ts +69 -0
- package/dist/manifest/index.mjs +28 -0
- package/dist/manifest/index.mjs.map +1 -0
- package/dist/types-CCVWFnWl.d.ts +300 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 agentproto contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @agentproto/sandbox
|
|
2
|
+
|
|
3
|
+
AIP-36 `SANDBOX.md` reference implementation. A composable schema block defining the `sandbox` field — provider, config, command env, network egress, resource limits — for any manifest that names a compute environment for agent-issued shell commands. Sibling primitive to STORAGE.md (AIP-35); inline or ref, mirroring AIP-17 RUNNER and AIP-19 SECRETS.
|
|
4
|
+
|
|
5
|
+
> **Status: 0.1.0-alpha.** Generated by `scripts/scaffold-aip.mjs` — `build()` and `validate()` bodies are TODOs.
|
|
6
|
+
|
|
7
|
+
Spec: <https://agentproto.sh/docs/aip-36>
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { defineSandbox } from "@agentproto/sandbox"
|
|
13
|
+
|
|
14
|
+
const x = defineSandbox({
|
|
15
|
+
id: "my-sandbox",
|
|
16
|
+
description: "Short purpose.",
|
|
17
|
+
// ...
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
MIT — see [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createDoctype } from '@agentproto/define-doctype';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @agentproto/sandbox v0.1.0-alpha
|
|
6
|
+
* AIP-36 SANDBOX.md `defineSandbox` reference implementation.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var sandboxFrontmatterSchema = z.object({ "schema": z.literal("sandbox/v1").describe("Standalone-only. Identifies the doctype + version. Absent when the block is inlined.").optional(), "id": z.string().regex(new RegExp("^@[a-z0-9][a-z0-9-]*/[a-z0-9][a-z0-9-]*$")).describe("Standalone-only. Globally addressable id `@<owner-slug>/<sandbox-slug>`.").optional(), "version": z.string().regex(new RegExp("^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.\\-]+)?$")).describe("Standalone-only. Spec version of THIS file.").optional(), "provider": z.string().min(1).describe("Backend kind. Day-1 enumerated set: local | mastra-e2b | mastra-modal | mastra-daytona | mastra-blaxel | node-permission. Hosts MAY register additional ids."), "config": z.record(z.string(), z.any()).describe("Provider-specific connection fields. Shape varies per provider (see AIP-36 \xA7Provider config shapes)."), "limits": z.object({ "timeout_ms": z.number().int().gte(1).optional(), "memory_mb": z.number().int().gte(1).optional(), "cpu_ms": z.number().int().gte(1).optional() }).strict().describe("Resource caps per command.").optional(), "env": z.object({ "auth": z.any().optional(), "passthrough": z.array(z.string()).describe("Static host env-var names to forward into the sandbox.").default([]) }).strict().optional(), "network": z.object({ "egress": z.array(z.string()).describe("Hostnames the sandbox MAY reach. Empty / missing = no egress.").default([]) }).strict().optional(), "mounts": z.array(z.any()).describe("Filesystems mounted inside the sandbox at declared paths. Maps to Mastra Workspace.mounts.").default([]), "identity": z.any().describe("AIP-23 identity-ref \u2014 owner of the sandbox processes.").optional(), "lifecycle": z.object({ "pause_after_idle": z.string().min(1).describe("AIP-37 event name (e.g. `idle-600` for 10 min). Provider-supported only (modal, daytona).").optional(), "destroy_on": z.string().min(1).describe("AIP-37 event name (e.g. `workspace-close`).").optional() }).strict().optional(), "read_only": z.boolean().describe("Reject command execution at the sandbox layer. Read-only sandbox calls fail with `sandbox_read_only`.").default(false), "metadata": z.record(z.string(), z.any()).describe("Free-form, namespaced. Adapter hints under `metadata.<adapter>.*`.").optional() }).strict().describe("Validates the YAML frontmatter portion of an AIP-36 SANDBOX.md manifest, OR the inline form embedded in any other manifest's `sandbox:` block. Compute-only \u2014 durable filesystem backings live in AIP-35 STORAGE.md.");
|
|
10
|
+
var defineSandboxInner = createDoctype({
|
|
11
|
+
aip: 36,
|
|
12
|
+
name: "sandbox",
|
|
13
|
+
readDescription: false,
|
|
14
|
+
// AIP-36 makes `id` standalone-only — inline sandbox blocks fall
|
|
15
|
+
// back to `provider` for the cross-AIP id-pattern check (mirrors
|
|
16
|
+
// AIP-43 § Identity).
|
|
17
|
+
readIdentity: (def) => {
|
|
18
|
+
if (typeof def.id === "string" && def.id.length > 0) return def.id;
|
|
19
|
+
return def.provider;
|
|
20
|
+
},
|
|
21
|
+
validate(def) {
|
|
22
|
+
const { factory: _factory, capabilities: _capabilities, ...manifest } = def;
|
|
23
|
+
const result = sandboxFrontmatterSchema.safeParse(manifest);
|
|
24
|
+
if (!result.success) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`defineSandbox (AIP-36): ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
build(def) {
|
|
31
|
+
const { factory, capabilities, ...manifest } = def;
|
|
32
|
+
return {
|
|
33
|
+
...manifest,
|
|
34
|
+
...factory !== void 0 ? { factory } : {},
|
|
35
|
+
...capabilities !== void 0 ? { capabilities: Object.freeze({ ...capabilities }) } : {}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
function defineSandbox(definition) {
|
|
40
|
+
return defineSandboxInner(
|
|
41
|
+
definition
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { defineSandbox, sandboxFrontmatterSchema };
|
|
46
|
+
//# sourceMappingURL=chunk-VSYQ4BUI.mjs.map
|
|
47
|
+
//# sourceMappingURL=chunk-VSYQ4BUI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema.ts","../src/define-sandbox.ts"],"names":[],"mappings":";;;;;;;;AAeO,IAAM,wBAAA,GAA2B,CAAA,CAAE,MAAA,CAAO,EAAE,QAAA,EAAU,CAAA,CAAE,OAAA,CAAQ,YAAY,CAAA,CAAE,QAAA,CAAS,sFAAsF,CAAA,CAAE,QAAA,EAAS,EAAG,IAAA,EAAM,CAAA,CA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P-36 SANDBOX.md frontmatter zod schema.\n *\n * Generated from `resources/aip-36/draft/SANDBOX.schema.json` via\n * json-schema-to-zod. Imported by both `define-sandbox.ts` (TS path\n * validation) and `manifest/index.ts` (.md path validation) so every\n * field-level constraint runs in both authoring paths from a single\n * source of truth — re-run scaffold-aip to refresh after spec changes.\n *\n * Cross-field rules (if/then/allOf in JSON Schema) don't translate\n * cleanly and live in `define-sandbox.ts`'s `validate(def)` instead.\n */\n\nimport { z } from \"zod\"\n\nexport const sandboxFrontmatterSchema = z.object({ \"schema\": z.literal(\"sandbox/v1\").describe(\"Standalone-only. Identifies the doctype + version. Absent when the block is inlined.\").optional(), \"id\": z.string().regex(new RegExp(\"^@[a-z0-9][a-z0-9-]*/[a-z0-9][a-z0-9-]*$\")).describe(\"Standalone-only. Globally addressable id `@<owner-slug>/<sandbox-slug>`.\").optional(), \"version\": z.string().regex(new RegExp(\"^\\\\d+\\\\.\\\\d+\\\\.\\\\d+(?:[-+][\\\\w.\\\\-]+)?$\")).describe(\"Standalone-only. Spec version of THIS file.\").optional(), \"provider\": z.string().min(1).describe(\"Backend kind. Day-1 enumerated set: local | mastra-e2b | mastra-modal | mastra-daytona | mastra-blaxel | node-permission. Hosts MAY register additional ids.\"), \"config\": z.record(z.string(), z.any()).describe(\"Provider-specific connection fields. Shape varies per provider (see AIP-36 §Provider config shapes).\"), \"limits\": z.object({ \"timeout_ms\": z.number().int().gte(1).optional(), \"memory_mb\": z.number().int().gte(1).optional(), \"cpu_ms\": z.number().int().gte(1).optional() }).strict().describe(\"Resource caps per command.\").optional(), \"env\": z.object({ \"auth\": z.any().optional(), \"passthrough\": z.array(z.string()).describe(\"Static host env-var names to forward into the sandbox.\").default([] as never) }).strict().optional(), \"network\": z.object({ \"egress\": z.array(z.string()).describe(\"Hostnames the sandbox MAY reach. Empty / missing = no egress.\").default([] as never) }).strict().optional(), \"mounts\": z.array(z.any()).describe(\"Filesystems mounted inside the sandbox at declared paths. Maps to Mastra Workspace.mounts.\").default([] as never), \"identity\": z.any().describe(\"AIP-23 identity-ref — owner of the sandbox processes.\").optional(), \"lifecycle\": z.object({ \"pause_after_idle\": z.string().min(1).describe(\"AIP-37 event name (e.g. `idle-600` for 10 min). Provider-supported only (modal, daytona).\").optional(), \"destroy_on\": z.string().min(1).describe(\"AIP-37 event name (e.g. `workspace-close`).\").optional() }).strict().optional(), \"read_only\": z.boolean().describe(\"Reject command execution at the sandbox layer. Read-only sandbox calls fail with `sandbox_read_only`.\").default(false), \"metadata\": z.record(z.string(), z.any()).describe(\"Free-form, namespaced. Adapter hints under `metadata.<adapter>.*`.\").optional() }).strict().describe(\"Validates the YAML frontmatter portion of an AIP-36 SANDBOX.md manifest, OR the inline form embedded in any other manifest's `sandbox:` block. Compute-only — durable filesystem backings live in AIP-35 STORAGE.md.\")\n\nexport type SandboxFrontmatter = z.infer<typeof sandboxFrontmatterSchema>\n","import { createDoctype } from \"@agentproto/define-doctype\"\nimport { sandboxFrontmatterSchema } from \"./schema.js\"\nimport type {\n SandboxRuntimeHandle,\n SandboxRuntimeInput,\n} from \"./types.js\"\n\n/**\n * AIP-36 reference implementation of `defineSandbox`.\n *\n * Built on `createDoctype` so the cross-AIP invariants (id pattern,\n * description length, top-level freeze, \"defineSandbox (AIP-36): …\"\n * error prefix) run uniformly with every other AIP defineX.\n *\n * Field-level validation runs the schema-derived zod from\n * `./schema.ts` against the manifest portion of the input. The\n * AIP-43 runtime slots (`factory`, `capabilities`) are HOST-OPAQUE\n * TS-runtime metadata stripped before validation and re-attached in\n * `build` — same pattern as `@agentproto/storage`'s `defineStorage`.\n *\n * Generic params:\n * TFactory — host-typed factory (e.g. `(input) => WorkspaceSandbox`\n * for the Guilde host). Defaults to `unknown`.\n * TCapabilities — opaque metadata the registry queries on. Per\n * AIP-43 § Capability metadata namespace.\n */\nconst defineSandboxInner = createDoctype<\n SandboxRuntimeInput,\n SandboxRuntimeHandle\n>({\n aip: 36,\n name: \"sandbox\",\n readDescription: false,\n // AIP-36 makes `id` standalone-only — inline sandbox blocks fall\n // back to `provider` for the cross-AIP id-pattern check (mirrors\n // AIP-43 § Identity).\n readIdentity: def => {\n if (typeof def.id === \"string\" && def.id.length > 0) return def.id\n return def.provider\n },\n validate(def) {\n const { factory: _factory, capabilities: _capabilities, ...manifest } = def\n const result = sandboxFrontmatterSchema.safeParse(manifest)\n if (!result.success) {\n throw new Error(\n `defineSandbox (AIP-36): ${result.error.issues\n .map(i => `${i.path.join(\".\")}: ${i.message}`)\n .join(\"; \")}`,\n )\n }\n // TODO: spec-36-specific cross-field rules (if/then/allOf in\n // the JSON Schema) — those don't translate to zod cleanly and\n // belong here. See @agentproto/operator's autonomy=gated rule.\n },\n build(def) {\n const { factory, capabilities, ...manifest } = def\n return {\n ...manifest,\n ...(factory !== undefined ? { factory } : {}),\n ...(capabilities !== undefined\n ? { capabilities: Object.freeze({ ...capabilities }) }\n : {}),\n } as SandboxRuntimeHandle\n },\n})\n\n/**\n * Type-aware wrapper preserving `TFactory` / `TCapabilities` generics\n * across the call.\n */\nexport function defineSandbox<\n TFactory = unknown,\n TCapabilities extends Record<string, unknown> = Record<string, unknown>,\n>(\n definition: SandboxRuntimeInput<TFactory, TCapabilities>,\n): SandboxRuntimeHandle<TFactory, TCapabilities> {\n return defineSandboxInner(\n definition as SandboxRuntimeInput,\n ) as SandboxRuntimeHandle<TFactory, TCapabilities>\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { S as SandboxRuntimeInput, a as SandboxRuntimeHandle } from './types-CCVWFnWl.js';
|
|
2
|
+
export { b as SandboxDefinition, c as SandboxHandle } from './types-CCVWFnWl.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Type-aware wrapper preserving `TFactory` / `TCapabilities` generics
|
|
6
|
+
* across the call.
|
|
7
|
+
*/
|
|
8
|
+
declare function defineSandbox<TFactory = unknown, TCapabilities extends Record<string, unknown> = Record<string, unknown>>(definition: SandboxRuntimeInput<TFactory, TCapabilities>): SandboxRuntimeHandle<TFactory, TCapabilities>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @agentproto/sandbox — AIP-36 SANDBOX.md `defineSandbox` reference impl.
|
|
12
|
+
*
|
|
13
|
+
* A composable schema block defining the `sandbox` field — provider, config, command env, network egress, resource limits — for any manifest that names a compute environment for agent-issued shell commands. Sibling primitive to STORAGE.md (AIP-35); inline or ref, mirroring AIP-17 RUNNER and AIP-19 SECRETS.
|
|
14
|
+
*
|
|
15
|
+
* Spec: https://agentproto.sh/docs/aip-36
|
|
16
|
+
*
|
|
17
|
+
* Authoring paths:
|
|
18
|
+
* - TS: `defineSandbox({...})` → `SandboxHandle`
|
|
19
|
+
* - MD: `parseSandboxManifest(src) → sandboxFromManifest({...})` → `SandboxHandle`
|
|
20
|
+
*/
|
|
21
|
+
declare const SPEC_NAME: "agentsandbox/v1";
|
|
22
|
+
declare const SPEC_VERSION: "1.0.0-alpha";
|
|
23
|
+
|
|
24
|
+
export { SPEC_NAME, SPEC_VERSION, SandboxRuntimeHandle, SandboxRuntimeInput, defineSandbox };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { defineSandbox } from './chunk-VSYQ4BUI.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @agentproto/sandbox v0.1.0-alpha
|
|
5
|
+
* AIP-36 SANDBOX.md `defineSandbox` reference implementation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// src/index.ts
|
|
9
|
+
var SPEC_NAME = "agentsandbox/v1";
|
|
10
|
+
var SPEC_VERSION = "1.0.0-alpha";
|
|
11
|
+
|
|
12
|
+
export { SPEC_NAME, SPEC_VERSION };
|
|
13
|
+
//# sourceMappingURL=index.mjs.map
|
|
14
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;AAYO,IAAM,SAAA,GAAY;AAClB,IAAM,YAAA,GAAe","file":"index.mjs","sourcesContent":["/**\n * @agentproto/sandbox — AIP-36 SANDBOX.md `defineSandbox` reference impl.\n *\n * A composable schema block defining the `sandbox` field — provider, config, command env, network egress, resource limits — for any manifest that names a compute environment for agent-issued shell commands. Sibling primitive to STORAGE.md (AIP-35); inline or ref, mirroring AIP-17 RUNNER and AIP-19 SECRETS.\n *\n * Spec: https://agentproto.sh/docs/aip-36\n *\n * Authoring paths:\n * - TS: `defineSandbox({...})` → `SandboxHandle`\n * - MD: `parseSandboxManifest(src) → sandboxFromManifest({...})` → `SandboxHandle`\n */\n\nexport const SPEC_NAME = \"agentsandbox/v1\" as const\nexport const SPEC_VERSION = \"1.0.0-alpha\" as const\n\nexport { defineSandbox } from \"./define-sandbox.js\"\nexport type {\n SandboxDefinition,\n SandboxHandle,\n SandboxRuntimeInput,\n SandboxRuntimeHandle,\n} from \"./types.js\"\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { c as SandboxHandle } from '../types-CCVWFnWl.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AIP-36 SANDBOX.md frontmatter zod schema.
|
|
6
|
+
*
|
|
7
|
+
* Generated from `resources/aip-36/draft/SANDBOX.schema.json` via
|
|
8
|
+
* json-schema-to-zod. Imported by both `define-sandbox.ts` (TS path
|
|
9
|
+
* validation) and `manifest/index.ts` (.md path validation) so every
|
|
10
|
+
* field-level constraint runs in both authoring paths from a single
|
|
11
|
+
* source of truth — re-run scaffold-aip to refresh after spec changes.
|
|
12
|
+
*
|
|
13
|
+
* Cross-field rules (if/then/allOf in JSON Schema) don't translate
|
|
14
|
+
* cleanly and live in `define-sandbox.ts`'s `validate(def)` instead.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
declare const sandboxFrontmatterSchema: z.ZodObject<{
|
|
18
|
+
schema: z.ZodOptional<z.ZodLiteral<"sandbox/v1">>;
|
|
19
|
+
id: z.ZodOptional<z.ZodString>;
|
|
20
|
+
version: z.ZodOptional<z.ZodString>;
|
|
21
|
+
provider: z.ZodString;
|
|
22
|
+
config: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
23
|
+
limits: z.ZodOptional<z.ZodObject<{
|
|
24
|
+
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
memory_mb: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
cpu_ms: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
}, z.core.$strict>>;
|
|
28
|
+
env: z.ZodOptional<z.ZodObject<{
|
|
29
|
+
auth: z.ZodOptional<z.ZodAny>;
|
|
30
|
+
passthrough: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
31
|
+
}, z.core.$strict>>;
|
|
32
|
+
network: z.ZodOptional<z.ZodObject<{
|
|
33
|
+
egress: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
34
|
+
}, z.core.$strict>>;
|
|
35
|
+
mounts: z.ZodDefault<z.ZodArray<z.ZodAny>>;
|
|
36
|
+
identity: z.ZodOptional<z.ZodAny>;
|
|
37
|
+
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
pause_after_idle: z.ZodOptional<z.ZodString>;
|
|
39
|
+
destroy_on: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$strict>>;
|
|
41
|
+
read_only: z.ZodDefault<z.ZodBoolean>;
|
|
42
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
43
|
+
}, z.core.$strict>;
|
|
44
|
+
type SandboxFrontmatter = z.infer<typeof sandboxFrontmatterSchema>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* AIP-36 SANDBOX.md sidecar parser + manifest-to-handle constructor.
|
|
48
|
+
*
|
|
49
|
+
* Mirror of `@agentproto/tool/manifest` and `@agentproto/driver/manifest`:
|
|
50
|
+
* the .md provides metadata; the TS module supplies any spec-specific
|
|
51
|
+
* runtime bits (schemas, execute bodies, …) that can't live in
|
|
52
|
+
* frontmatter. Both inputs end up in `defineSandbox` so the cross-AIP
|
|
53
|
+
* invariants run uniformly.
|
|
54
|
+
*
|
|
55
|
+
*
|
|
56
|
+
* The frontmatter zod schema below was generated from
|
|
57
|
+
* `resources/aip-36/draft/SANDBOX.schema.json` via json-schema-to-zod.
|
|
58
|
+
* Re-run scaffold-aip to refresh after spec changes (or hand-tune
|
|
59
|
+
* any constraint the converter doesn't capture cleanly).
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
interface SandboxManifest {
|
|
63
|
+
frontmatter: SandboxFrontmatter;
|
|
64
|
+
body: string;
|
|
65
|
+
}
|
|
66
|
+
declare function parseSandboxManifest(source: string): SandboxManifest;
|
|
67
|
+
declare function sandboxFromManifest(manifest: SandboxManifest): SandboxHandle;
|
|
68
|
+
|
|
69
|
+
export { type SandboxFrontmatter, type SandboxManifest, parseSandboxManifest, sandboxFromManifest, sandboxFrontmatterSchema };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { sandboxFrontmatterSchema, defineSandbox } from '../chunk-VSYQ4BUI.mjs';
|
|
2
|
+
export { sandboxFrontmatterSchema } from '../chunk-VSYQ4BUI.mjs';
|
|
3
|
+
import matter from 'gray-matter';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @agentproto/sandbox v0.1.0-alpha
|
|
7
|
+
* AIP-36 SANDBOX.md `defineSandbox` reference implementation.
|
|
8
|
+
*/
|
|
9
|
+
function parseSandboxManifest(source) {
|
|
10
|
+
const parsed = matter(source);
|
|
11
|
+
if (Object.keys(parsed.data).length === 0) {
|
|
12
|
+
throw new Error("parseSandboxManifest: missing or empty frontmatter");
|
|
13
|
+
}
|
|
14
|
+
const result = sandboxFrontmatterSchema.safeParse(parsed.data);
|
|
15
|
+
if (!result.success) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
`parseSandboxManifest: invalid frontmatter \u2014 ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
return { frontmatter: result.data, body: parsed.content };
|
|
21
|
+
}
|
|
22
|
+
function sandboxFromManifest(manifest) {
|
|
23
|
+
return defineSandbox(manifest.frontmatter);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { parseSandboxManifest, sandboxFromManifest };
|
|
27
|
+
//# sourceMappingURL=index.mjs.map
|
|
28
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/manifest/index.ts"],"names":[],"mappings":";;;;;;;;AA8BO,SAAS,qBAAqB,MAAA,EAAiC;AACpE,EAAA,MAAM,MAAA,GAAS,OAAO,MAAM,CAAA;AAC5B,EAAA,IAAI,OAAO,IAAA,CAAK,MAAA,CAAO,IAAI,CAAA,CAAE,WAAW,CAAA,EAAG;AACzC,IAAA,MAAM,IAAI,MAAM,oDAAoD,CAAA;AAAA,EACtE;AACA,EAAA,MAAM,MAAA,GAAS,wBAAA,CAAyB,SAAA,CAAU,MAAA,CAAO,IAAI,CAAA;AAC7D,EAAA,IAAI,CAAC,OAAO,OAAA,EAAS;AACnB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,iDAAA,EAA+C,OAAO,KAAA,CAAM,MAAA,CACzD,IAAI,CAAC,CAAA,KAAM,GAAG,CAAA,CAAE,IAAA,CAAK,KAAK,GAAG,CAAC,KAAK,CAAA,CAAE,OAAO,EAAE,CAAA,CAC9C,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,KACf;AAAA,EACF;AACA,EAAA,OAAO,EAAE,WAAA,EAAa,MAAA,CAAO,IAAA,EAAM,IAAA,EAAM,OAAO,OAAA,EAAQ;AAC1D;AAEO,SAAS,oBAAoB,QAAA,EAA0C;AAK5E,EAAA,OAAO,aAAA,CAAc,SAAS,WAA2C,CAAA;AAC3E","file":"index.mjs","sourcesContent":["/**\n * AIP-36 SANDBOX.md sidecar parser + manifest-to-handle constructor.\n *\n * Mirror of `@agentproto/tool/manifest` and `@agentproto/driver/manifest`:\n * the .md provides metadata; the TS module supplies any spec-specific\n * runtime bits (schemas, execute bodies, …) that can't live in\n * frontmatter. Both inputs end up in `defineSandbox` so the cross-AIP\n * invariants run uniformly.\n *\n *\n * The frontmatter zod schema below was generated from\n * `resources/aip-36/draft/SANDBOX.schema.json` via json-schema-to-zod.\n * Re-run scaffold-aip to refresh after spec changes (or hand-tune\n * any constraint the converter doesn't capture cleanly).\n */\n\nimport matter from \"gray-matter\"\nimport { sandboxFrontmatterSchema, type SandboxFrontmatter } from \"../schema.js\"\nimport { defineSandbox } from \"../define-sandbox.js\"\nimport type { SandboxDefinition, SandboxHandle } from \"../types.js\"\n\n// Re-export so consumers can import the schema + inferred type either\n// from \"@@agentproto/sandbox/manifest\" or directly from \"@@agentproto/sandbox/schema\".\nexport { sandboxFrontmatterSchema, type SandboxFrontmatter }\n\nexport interface SandboxManifest {\n frontmatter: SandboxFrontmatter\n body: string\n}\n\nexport function parseSandboxManifest(source: string): SandboxManifest {\n const parsed = matter(source)\n if (Object.keys(parsed.data).length === 0) {\n throw new Error(\"parseSandboxManifest: missing or empty frontmatter\")\n }\n const result = sandboxFrontmatterSchema.safeParse(parsed.data)\n if (!result.success) {\n throw new Error(\n `parseSandboxManifest: invalid frontmatter — ${result.error.issues\n .map((i) => `${i.path.join(\".\")}: ${i.message}`)\n .join(\"; \")}`,\n )\n }\n return { frontmatter: result.data, body: parsed.content }\n}\n\nexport function sandboxFromManifest(manifest: SandboxManifest): SandboxHandle {\n // The zod-validated frontmatter is structurally compatible with\n // SandboxDefinition; the cast pins the typing once the manifest\n // schema and the TS interface diverge (e.g. handle has frozen fields\n // a literal config doesn't carry yet).\n return defineSandbox(manifest.frontmatter as unknown as SandboxDefinition)\n}\n"]}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AIP-36 SandboxDefinition + SandboxHandle.
|
|
3
|
+
*
|
|
4
|
+
* `SandboxDefinition` was generated from
|
|
5
|
+
* `resources/aip-36/draft/SANDBOX.schema.json` via json-schema-to-typescript.
|
|
6
|
+
* `SandboxHandle` is the readonly view of the same shape; tighten it
|
|
7
|
+
* by hand for fields that get defaults applied in build().
|
|
8
|
+
*/
|
|
9
|
+
type IdentityRefEntry = {
|
|
10
|
+
name: string;
|
|
11
|
+
email: string;
|
|
12
|
+
avatar?: string;
|
|
13
|
+
gpg_key?: string;
|
|
14
|
+
role?: string;
|
|
15
|
+
metadata?: {};
|
|
16
|
+
[k: string]: unknown;
|
|
17
|
+
} | {
|
|
18
|
+
ref: string;
|
|
19
|
+
role?: string;
|
|
20
|
+
[k: string]: unknown;
|
|
21
|
+
} | {
|
|
22
|
+
file: string;
|
|
23
|
+
role?: string;
|
|
24
|
+
[k: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Validates the YAML frontmatter portion of an AIP-36 SANDBOX.md manifest, OR the inline form embedded in any other manifest's `sandbox:` block. Compute-only — durable filesystem backings live in AIP-35 STORAGE.md.
|
|
28
|
+
*/
|
|
29
|
+
interface SandboxDefinition {
|
|
30
|
+
/**
|
|
31
|
+
* Standalone-only. Identifies the doctype + version. Absent when the block is inlined.
|
|
32
|
+
*/
|
|
33
|
+
schema?: "sandbox/v1";
|
|
34
|
+
/**
|
|
35
|
+
* Standalone-only. Globally addressable id `@<owner-slug>/<sandbox-slug>`.
|
|
36
|
+
*/
|
|
37
|
+
id?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Standalone-only. Spec version of THIS file.
|
|
40
|
+
*/
|
|
41
|
+
version?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Backend kind. Day-1 enumerated set: local | mastra-e2b | mastra-modal | mastra-daytona | mastra-blaxel | node-permission. Hosts MAY register additional ids.
|
|
44
|
+
*/
|
|
45
|
+
provider: string;
|
|
46
|
+
/**
|
|
47
|
+
* Provider-specific connection fields. Shape varies per provider (see AIP-36 §Provider config shapes).
|
|
48
|
+
*/
|
|
49
|
+
config: {};
|
|
50
|
+
/**
|
|
51
|
+
* Resource caps per command.
|
|
52
|
+
*/
|
|
53
|
+
limits?: {
|
|
54
|
+
timeout_ms?: number;
|
|
55
|
+
memory_mb?: number;
|
|
56
|
+
cpu_ms?: number;
|
|
57
|
+
};
|
|
58
|
+
env?: {
|
|
59
|
+
auth?: AuthBlock;
|
|
60
|
+
/**
|
|
61
|
+
* Static host env-var names to forward into the sandbox.
|
|
62
|
+
*/
|
|
63
|
+
passthrough?: string[];
|
|
64
|
+
};
|
|
65
|
+
network?: {
|
|
66
|
+
/**
|
|
67
|
+
* Hostnames the sandbox MAY reach. Empty / missing = no egress.
|
|
68
|
+
*/
|
|
69
|
+
egress?: string[];
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Filesystems mounted inside the sandbox at declared paths. Maps to Mastra Workspace.mounts.
|
|
73
|
+
*/
|
|
74
|
+
mounts?: MountEntry[];
|
|
75
|
+
/**
|
|
76
|
+
* AIP-23 identity-ref — owner of the sandbox processes.
|
|
77
|
+
*/
|
|
78
|
+
identity?: IdentityRefEntry | [IdentityRefEntry, ...IdentityRefEntry[]];
|
|
79
|
+
lifecycle?: {
|
|
80
|
+
/**
|
|
81
|
+
* AIP-37 event name (e.g. `idle-600` for 10 min). Provider-supported only (modal, daytona).
|
|
82
|
+
*/
|
|
83
|
+
pause_after_idle?: string;
|
|
84
|
+
/**
|
|
85
|
+
* AIP-37 event name (e.g. `workspace-close`).
|
|
86
|
+
*/
|
|
87
|
+
destroy_on?: string;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Reject command execution at the sandbox layer. Read-only sandbox calls fail with `sandbox_read_only`.
|
|
91
|
+
*/
|
|
92
|
+
read_only?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Free-form, namespaced. Adapter hints under `metadata.<adapter>.*`.
|
|
95
|
+
*/
|
|
96
|
+
metadata?: {
|
|
97
|
+
[k: string]: unknown;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
interface AuthBlock {
|
|
101
|
+
ref?: string;
|
|
102
|
+
state?: {
|
|
103
|
+
env?: string[];
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
interface MountEntry {
|
|
107
|
+
/**
|
|
108
|
+
* What to mount. `"workspace"` shortcut for the parent workspace storage.
|
|
109
|
+
*/
|
|
110
|
+
source: "workspace" | {
|
|
111
|
+
ref: string;
|
|
112
|
+
} | {
|
|
113
|
+
inline: STORAGEMdFrontmatterAgentstorageV1FilesystemPolicyBlock;
|
|
114
|
+
} | {
|
|
115
|
+
file: string;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Absolute path inside the sandbox where the mount appears.
|
|
119
|
+
*/
|
|
120
|
+
at: string;
|
|
121
|
+
mode?: "read-write" | "read-only";
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Validates the YAML frontmatter portion of an AIP-35 STORAGE.md manifest, OR the inline form embedded in any other manifest's `storage:` block. Filesystem-only — sandbox-shaped backends (e2b/modal/...) live in AIP-36 SANDBOX.md.
|
|
125
|
+
*/
|
|
126
|
+
interface STORAGEMdFrontmatterAgentstorageV1FilesystemPolicyBlock {
|
|
127
|
+
/**
|
|
128
|
+
* Standalone-only. Identifies the doctype + version. Absent when the block is inlined in another manifest.
|
|
129
|
+
*/
|
|
130
|
+
schema?: "storage/v1";
|
|
131
|
+
/**
|
|
132
|
+
* Standalone-only. Globally addressable id `@<owner-slug>/<storage-slug>`.
|
|
133
|
+
*/
|
|
134
|
+
id?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Standalone-only. Spec version of THIS file. Bump on breaking shape change.
|
|
137
|
+
*/
|
|
138
|
+
version?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Backend kind. Day-1 enumerated set: cloud-bucket | self-bucket | github | local-fs | dev-local | mastra-s3 | mastra-azure. Hosts MAY register additional ids; the schema accepts any non-empty string and host-side validation narrows.
|
|
141
|
+
*/
|
|
142
|
+
provider: string;
|
|
143
|
+
/**
|
|
144
|
+
* Provider-specific connection fields. Shape varies per provider (see AIP-35 §Provider config shapes).
|
|
145
|
+
*/
|
|
146
|
+
config: {};
|
|
147
|
+
sync?: SyncBlock;
|
|
148
|
+
auth?: AuthBlock1;
|
|
149
|
+
/**
|
|
150
|
+
* AIP-23 identity-ref block — commit author(s) for syncing providers (github). Supports multi-attribution (primary + co-authors).
|
|
151
|
+
*/
|
|
152
|
+
identity?: ({
|
|
153
|
+
name: string;
|
|
154
|
+
email: string;
|
|
155
|
+
avatar?: string;
|
|
156
|
+
gpg_key?: string;
|
|
157
|
+
role?: string;
|
|
158
|
+
metadata?: {};
|
|
159
|
+
[k: string]: unknown;
|
|
160
|
+
} | {
|
|
161
|
+
ref: string;
|
|
162
|
+
role?: string;
|
|
163
|
+
[k: string]: unknown;
|
|
164
|
+
} | {
|
|
165
|
+
file: string;
|
|
166
|
+
role?: string;
|
|
167
|
+
[k: string]: unknown;
|
|
168
|
+
}) | [
|
|
169
|
+
({
|
|
170
|
+
name: string;
|
|
171
|
+
email: string;
|
|
172
|
+
avatar?: string;
|
|
173
|
+
gpg_key?: string;
|
|
174
|
+
role?: string;
|
|
175
|
+
metadata?: {};
|
|
176
|
+
[k: string]: unknown;
|
|
177
|
+
} | {
|
|
178
|
+
ref: string;
|
|
179
|
+
role?: string;
|
|
180
|
+
[k: string]: unknown;
|
|
181
|
+
} | {
|
|
182
|
+
file: string;
|
|
183
|
+
role?: string;
|
|
184
|
+
[k: string]: unknown;
|
|
185
|
+
}),
|
|
186
|
+
...({
|
|
187
|
+
name: string;
|
|
188
|
+
email: string;
|
|
189
|
+
avatar?: string;
|
|
190
|
+
gpg_key?: string;
|
|
191
|
+
role?: string;
|
|
192
|
+
metadata?: {};
|
|
193
|
+
[k: string]: unknown;
|
|
194
|
+
} | {
|
|
195
|
+
ref: string;
|
|
196
|
+
role?: string;
|
|
197
|
+
[k: string]: unknown;
|
|
198
|
+
} | {
|
|
199
|
+
file: string;
|
|
200
|
+
role?: string;
|
|
201
|
+
[k: string]: unknown;
|
|
202
|
+
})[]
|
|
203
|
+
];
|
|
204
|
+
/**
|
|
205
|
+
* Paths NOT mirrored to the backing store. Glob-ish, prefix-matched.
|
|
206
|
+
*/
|
|
207
|
+
exclude?: string[];
|
|
208
|
+
/**
|
|
209
|
+
* Reject writes at the storage layer.
|
|
210
|
+
*/
|
|
211
|
+
read_only?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Free-form, namespaced. Authors MAY stash adapter-specific hints under namespaced keys.
|
|
214
|
+
*/
|
|
215
|
+
metadata?: {
|
|
216
|
+
[k: string]: unknown;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Sync semantics. Lifecycle triggers reference AIP-37 event names.
|
|
221
|
+
*/
|
|
222
|
+
interface SyncBlock {
|
|
223
|
+
mode?: "canonical" | "pull-push" | "watch";
|
|
224
|
+
pull?: {
|
|
225
|
+
/**
|
|
226
|
+
* AIP-37 lifecycle event name. Standard: workspace-open | turn-start | manual. Aliases (per-turn, each-write) resolve via AIP-37.
|
|
227
|
+
*/
|
|
228
|
+
on?: string;
|
|
229
|
+
/**
|
|
230
|
+
* Cache validity for pull-push providers (e.g. github clone).
|
|
231
|
+
*/
|
|
232
|
+
ttl_seconds?: number;
|
|
233
|
+
};
|
|
234
|
+
commit?: {
|
|
235
|
+
/**
|
|
236
|
+
* AIP-37 event name. Common: each-write | per-turn | per-conversation | manual.
|
|
237
|
+
*/
|
|
238
|
+
on?: string;
|
|
239
|
+
/**
|
|
240
|
+
* Debounce window for each-write commit mode.
|
|
241
|
+
*/
|
|
242
|
+
batch_window_ms?: number;
|
|
243
|
+
/**
|
|
244
|
+
* Template for commit message. Provider-specific tokens (e.g. {{operator}}, {{summary}}).
|
|
245
|
+
*/
|
|
246
|
+
message_template?: string;
|
|
247
|
+
};
|
|
248
|
+
push?: {
|
|
249
|
+
/**
|
|
250
|
+
* AIP-37 event name. Common: per-commit | per-turn | per-conversation | manual.
|
|
251
|
+
*/
|
|
252
|
+
on?: string;
|
|
253
|
+
/**
|
|
254
|
+
* Github only. Where commits land.
|
|
255
|
+
*/
|
|
256
|
+
branch_policy?: "main" | "per-conversation" | "per-turn";
|
|
257
|
+
/**
|
|
258
|
+
* Github only. Whether to open PRs automatically.
|
|
259
|
+
*/
|
|
260
|
+
pr_policy?: "none" | "auto" | "manual";
|
|
261
|
+
};
|
|
262
|
+
conflict?: {
|
|
263
|
+
policy?: "rebase" | "merge" | "abort" | "manual" | "last-writer-wins" | "split-conflicts";
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Reference to AIP-19 SECRETS.md (or future ENV.md) for credentials.
|
|
268
|
+
*/
|
|
269
|
+
interface AuthBlock1 {
|
|
270
|
+
/**
|
|
271
|
+
* Path or registry slug pointing to a SECRETS.md (or future ENV.md) inventory.
|
|
272
|
+
*/
|
|
273
|
+
ref?: string;
|
|
274
|
+
state?: {
|
|
275
|
+
/**
|
|
276
|
+
* Env-var names this consumer expects to be revealed from the referenced inventory.
|
|
277
|
+
*/
|
|
278
|
+
env?: string[];
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
type SandboxHandle = Readonly<SandboxDefinition>;
|
|
282
|
+
/**
|
|
283
|
+
* In-TS authoring shape — what callers pass to `defineSandbox(...)`
|
|
284
|
+
* when constructing a handle programmatically. Extends
|
|
285
|
+
* `SandboxDefinition` with two optional host-runtime slots.
|
|
286
|
+
*/
|
|
287
|
+
interface SandboxRuntimeInput<TFactory = unknown, TCapabilities extends Record<string, unknown> = Record<string, unknown>> extends SandboxDefinition {
|
|
288
|
+
factory?: TFactory;
|
|
289
|
+
capabilities?: TCapabilities;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* What `defineSandbox(...)` returns. Carries `factory` + `capabilities`
|
|
293
|
+
* through unchanged so registry consumers can read them off the handle.
|
|
294
|
+
*/
|
|
295
|
+
type SandboxRuntimeHandle<TFactory = unknown, TCapabilities extends Record<string, unknown> = Record<string, unknown>> = Readonly<SandboxDefinition> & {
|
|
296
|
+
readonly factory?: TFactory;
|
|
297
|
+
readonly capabilities?: Readonly<TCapabilities>;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export type { SandboxRuntimeInput as S, SandboxRuntimeHandle as a, SandboxDefinition as b, SandboxHandle as c };
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentproto/sandbox",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "@agentproto/sandbox — AIP-36 SANDBOX.md reference implementation. A composable schema block defining the `sandbox` field — provider, config, command env, network egress, resource limits — for any manifest that names a compute environment for agent-issued shell commands. Sibling primitive to STORAGE.md (AIP-35); inline or ref, mirroring AIP-17 RUNNER and AIP-19 SECRETS.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agentproto",
|
|
7
|
+
"aip-36",
|
|
8
|
+
"sandbox",
|
|
9
|
+
"defineSandbox",
|
|
10
|
+
"open-standard",
|
|
11
|
+
"agentic"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://agentproto.sh/docs/aip-36",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/agentproto/ts",
|
|
17
|
+
"directory": "packages/sandbox"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/agentproto/ts/issues"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "dist/index.mjs",
|
|
25
|
+
"module": "dist/index.mjs",
|
|
26
|
+
"types": "dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.mjs",
|
|
31
|
+
"default": "./dist/index.mjs"
|
|
32
|
+
},
|
|
33
|
+
"./manifest": {
|
|
34
|
+
"types": "./dist/manifest/index.d.ts",
|
|
35
|
+
"import": "./dist/manifest/index.mjs",
|
|
36
|
+
"default": "./dist/manifest/index.mjs"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
],
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"gray-matter": "^4.0.3",
|
|
50
|
+
"zod": "^4.4.3",
|
|
51
|
+
"@agentproto/define-doctype": "0.1.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^25.6.2",
|
|
55
|
+
"tsup": "^8.5.1",
|
|
56
|
+
"typescript": "^5.9.3",
|
|
57
|
+
"vitest": "^3.2.4",
|
|
58
|
+
"@agentproto/tooling": "0.1.0-alpha.0"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"dev": "tsup --watch",
|
|
62
|
+
"build": "tsup",
|
|
63
|
+
"clean": "rm -rf dist",
|
|
64
|
+
"check-types": "tsc --noEmit",
|
|
65
|
+
"test": "vitest run --passWithNoTests",
|
|
66
|
+
"test:watch": "vitest"
|
|
67
|
+
}
|
|
68
|
+
}
|