ppio-sandbox-cli-global 0.0.0-stage → 0.0.1-a2

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.
@@ -0,0 +1,21 @@
1
+ import asyncio
2
+ from ppio_sandbox_global import AsyncTemplate, default_build_logger
3
+ from .template import template
4
+
5
+
6
+ async def main():
7
+ await AsyncTemplate.build(
8
+ template,
9
+ "{{name}}",
10
+ {{#if cpuCount}}
11
+ cpu_count={{cpuCount}},
12
+ {{/if}}
13
+ {{#if memoryMB}}
14
+ memory_mb={{memoryMB}},
15
+ {{/if}}
16
+ on_build_logs=default_build_logger(),
17
+ )
18
+
19
+
20
+ if __name__ == "__main__":
21
+ asyncio.run(main())
@@ -0,0 +1,16 @@
1
+ from ppio_sandbox_global import Template, default_build_logger
2
+ from .template import template
3
+
4
+
5
+ if __name__ == "__main__":
6
+ Template.build(
7
+ template,
8
+ "{{name}}",
9
+ {{#if cpuCount}}
10
+ cpu_count={{cpuCount}},
11
+ {{/if}}
12
+ {{#if memoryMB}}
13
+ memory_mb={{memoryMB}},
14
+ {{/if}}
15
+ on_build_logs=default_build_logger(),
16
+ )
@@ -0,0 +1,36 @@
1
+ from ppio_sandbox_global import {{#if isAsync}}AsyncTemplate{{else}}Template{{/if}}
2
+
3
+ template = (
4
+ {{#if isAsync}}AsyncTemplate{{else}}Template{{/if}}()
5
+ {{#if fromImage}}
6
+ .from_image("{{{fromImage}}}")
7
+ {{/if}}
8
+ {{#each steps}}
9
+ {{#eq type "WORKDIR"}}
10
+ .set_workdir("{{{args.[0]}}}")
11
+ {{/eq}}
12
+ {{#eq type "USER"}}
13
+ .set_user("{{{args.[0]}}}")
14
+ {{/eq}}
15
+ {{#eq type "ENV"}}
16
+ .set_envs({
17
+ {{#each envVars}}
18
+ "{{{@key}}}": "{{{this}}}",
19
+ {{/each}}
20
+ })
21
+ {{/eq}}
22
+ {{#eq type "RUN"}}
23
+ .run_cmd("{{{args.[0]}}}")
24
+ {{/eq}}
25
+ {{#eq type "COPY"}}
26
+ .copy("{{{src}}}", "{{{dest}}}")
27
+ {{/eq}}
28
+ {{/each}}
29
+ {{#if startCmd}}
30
+ {{#if readyCmd}}
31
+ .set_start_cmd("sudo {{{escapeDoubleQuotes startCmd}}}", "{{{escapeDoubleQuotes readyCmd}}}")
32
+ {{/if}}
33
+ {{else if readyCmd}}
34
+ .set_ready_cmd("sudo {{{escapeDoubleQuotes readyCmd}}}")
35
+ {{/if}}
36
+ )
@@ -0,0 +1,99 @@
1
+ # {{name}} - PPIO sandbox Template
2
+
3
+ This is an PPIO sandbox template that allows you to run code in a controlled environment.
4
+
5
+ ## Prerequisites
6
+
7
+ Before you begin, make sure you have:
8
+ - A PPIO sandbox account (sign up at [ppio.ai](https://ppio.ai))
9
+ - Your PPIO sandbox API key (get it from your [PPIO sandbox dashboard](https://ppio.ai/settings/key-management))
10
+ {{#if isTypeScript}}- Node.js and npm/yarn (or similar) installed{{else if isPython}}- Python installed{{/if}}
11
+
12
+ ## Configuration
13
+
14
+ 1. Create a `.env` file in your project root or set the environment variable:
15
+ ```
16
+ PPIO_API_KEY=your_api_key_here
17
+ ```
18
+
19
+ ## Installing Dependencies
20
+
21
+ ```bash
22
+ {{#if isTypeScript}}
23
+ npm install ppio-sandbox-global@0.0.1-a2
24
+ {{else if isPython}}
25
+ pip install ppio-sandbox-global==0.0.1a2
26
+ {{/if}}
27
+ ```
28
+
29
+ ## Building the Template
30
+
31
+ ```bash
32
+ {{#if isTypeScript}}
33
+ # For development
34
+ npm run ppio:build:dev
35
+
36
+ # For production
37
+ npm run ppio:build:prod
38
+ {{else if isPython}}
39
+ # For development
40
+ make ppio:build:dev
41
+
42
+ # For production
43
+ make ppio:build:prod
44
+ {{/if}}
45
+ ```
46
+
47
+ ## Using the Template in a Sandbox
48
+
49
+ Once your template is built, you can use it in your PPIO sandbox:
50
+
51
+ {{#if isTypeScript}}
52
+ ```typescript
53
+ import { Sandbox } from 'ppio-sandbox-global'
54
+
55
+ // Create a new sandbox instance
56
+ const sandbox = await Sandbox.create('{{name}}')
57
+
58
+ // Your sandbox is ready to use!
59
+ console.log('Sandbox created successfully')
60
+ ```
61
+ {{else if isPythonSync}}
62
+ ```python
63
+ from ppio_sandbox_global import Sandbox
64
+
65
+ # Create a new sandbox instance
66
+ sandbox = Sandbox.create('{{name}}')
67
+
68
+ # Your sandbox is ready to use!
69
+ print('Sandbox created successfully')
70
+ ```
71
+ {{else if isPythonAsync}}
72
+ ```python
73
+ from ppio_sandbox_global import AsyncSandbox
74
+ import asyncio
75
+
76
+ async def main():
77
+ # Create a new sandbox instance
78
+ sandbox = await AsyncSandbox.create('{{name}}')
79
+
80
+ # Your sandbox is ready to use!
81
+ print('Sandbox created successfully')
82
+
83
+ # Run the async function
84
+ asyncio.run(main())
85
+ ```
86
+ {{/if}}
87
+
88
+ ## Template Structure
89
+
90
+ - `{{templateFile}}` - Defines the sandbox template configuration
91
+ - `{{buildDevFile}}` - Builds the template for development
92
+ - `{{buildProdFile}}` - Builds the template for production
93
+
94
+ ## Next Steps
95
+
96
+ 1. Customize the template in `{{templateFile}}` to fit your needs
97
+ 2. Build the template using one of the methods above
98
+ 3. Use the template in your PPIO sandbox code
99
+ 4. Check out the [PPIO sandbox documentation](https://ppio.ai/docs/sandbox/overview) for more advanced usage
@@ -0,0 +1,16 @@
1
+ import { Template, defaultBuildLogger } from 'ppio-sandbox-global'
2
+ import { template } from './template'
3
+
4
+ async function main() {
5
+ await Template.build(template, '{{name}}', {
6
+ {{#if cpuCount}}
7
+ cpuCount: {{cpuCount}},
8
+ {{/if}}
9
+ {{#if memoryMB}}
10
+ memoryMB: {{memoryMB}},
11
+ {{/if}}
12
+ onBuildLogs: defaultBuildLogger(),
13
+ });
14
+ }
15
+
16
+ main().catch(console.error);
@@ -0,0 +1,34 @@
1
+ import { Template } from 'ppio-sandbox-global'
2
+
3
+ export const template = Template()
4
+ {{#if fromImage}}
5
+ .fromImage('{{{fromImage}}}')
6
+ {{/if}}
7
+ {{#each steps}}
8
+ {{#eq type "WORKDIR"}}
9
+ .setWorkdir('{{{args.[0]}}}')
10
+ {{/eq}}
11
+ {{#eq type "USER"}}
12
+ .setUser('{{{args.[0]}}}')
13
+ {{/eq}}
14
+ {{#eq type "ENV"}}
15
+ .setEnvs({
16
+ {{#each envVars}}
17
+ '{{{@key}}}': '{{{this}}}',
18
+ {{/each}}
19
+ })
20
+ {{/eq}}
21
+ {{#eq type "RUN"}}
22
+ .runCmd('{{{args.[0]}}}')
23
+ {{/eq}}
24
+ {{#eq type "COPY"}}
25
+ .copy('{{{src}}}', '{{{dest}}}')
26
+ {{/eq}}
27
+ {{/each}}
28
+ {{#if startCmd}}
29
+ {{#if readyCmd}}
30
+ .setStartCmd('sudo {{{escapeQuotes startCmd}}}', '{{{escapeQuotes readyCmd}}}')
31
+ {{/if}}
32
+ {{else if readyCmd}}
33
+ .setReadyCmd('sudo {{{escapeQuotes readyCmd}}}')
34
+ {{/if}}
package/package.json CHANGED
@@ -1,6 +1,99 @@
1
1
  {
2
2
  "name": "ppio-sandbox-cli-global",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.1-a2",
4
+ "description": "CLI for managing PPIO global sandbox templates and sandboxes",
5
+ "homepage": "https://ppio.ai/ai-computing/sandbox",
6
+ "license": "MIT",
7
+ "author": {
8
+ "name": "PPIO",
9
+ "url": "https://ppio.ai"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "keywords": [
15
+ "PPIO",
16
+ "ai-agents",
17
+ "agents",
18
+ "ai",
19
+ "code-interpreter",
20
+ "sandbox",
21
+ "code",
22
+ "cli",
23
+ "runtime",
24
+ "vm",
25
+ "nodejs",
26
+ "javascript",
27
+ "typescript"
28
+ ],
29
+ "sideEffects": false,
30
+ "devDependencies": {
31
+ "@types/command-exists": "^1.2.3",
32
+ "@types/inquirer": "^9.0.7",
33
+ "@types/jest": "^30.0.0",
34
+ "@types/json2md": "^1.5.4",
35
+ "@types/node": "^18.18.6",
36
+ "@types/npmcli__package-json": "^4.0.4",
37
+ "@types/platform": "^1.3.6",
38
+ "@types/statuses": "^2.0.5",
39
+ "@types/update-notifier": "6.0.5",
40
+ "json2md": "^2.0.1",
41
+ "knip": "^5.43.6",
42
+ "npm-check-updates": "^16.14.6",
43
+ "tsup": "^8.4.0",
44
+ "typescript": "^5.2.2"
45
+ },
46
+ "files": [
47
+ "dist",
48
+ "LICENSE",
49
+ "README",
50
+ "package.json"
51
+ ],
52
+ "bin": {
53
+ "ppio-sandbox-cli-global": "dist/index.js",
54
+ "ppio-global": "dist/index.js"
55
+ },
56
+ "dependencies": {
57
+ "@iarna/toml": "^2.2.5",
58
+ "@inquirer/prompts": "^7.9.0",
59
+ "@npmcli/package-json": "^5.2.1",
60
+ "@types/fs-extra": "^11.0.4",
61
+ "async-listen": "^3.0.1",
62
+ "boxen": "^7.1.1",
63
+ "chalk": "^5.3.0",
64
+ "cli-highlight": "^2.1.11",
65
+ "command-exists": "^1.2.9",
66
+ "commander": "^11.1.0",
67
+ "console-table-printer": "^2.11.2",
68
+ "dockerfile-ast": "^0.7.1",
69
+ "fs-extra": "^11.3.2",
70
+ "handlebars": "^4.7.8",
71
+ "inquirer": "^9.2.12",
72
+ "open": "^9.1.0",
73
+ "ppio-sandbox-global": "0.0.1-a2",
74
+ "simple-update-notifier": "^2.0.0",
75
+ "statuses": "^2.0.1",
76
+ "strip-ansi": "^7.1.0",
77
+ "update-notifier": "^6.0.2",
78
+ "winston": "^3.17.0",
79
+ "winston-transport": "^4.9.0",
80
+ "yaml": "^2.8.1",
81
+ "yup": "^1.3.2"
82
+ },
83
+ "engines": {
84
+ "node": ">=20"
85
+ },
86
+ "scripts": {
87
+ "build": "tsc --noEmit --skipLibCheck && tsup --minify && rm -rf dist/templates && cp -R src/templates dist/templates",
88
+ "dev": "tsup --watch",
89
+ "lint": "eslint src",
90
+ "test": "pnpm build && cd testground/demo-basic && ../../dist/index.js template build",
91
+ "test:resources": "pnpm build && node --test test/resource-contract.test.mjs",
92
+ "test:registry": "pnpm build && node --test test/image-registry.test.cjs",
93
+ "check-deps": "knip",
94
+ "update-deps": "ncu -u && pnpm i",
95
+ "generate-ref": "./scripts/generate_sdk_ref.sh",
96
+ "test:security": "pnpm build && node scripts/test-security-options.mjs && node scripts/test-security-flow.mjs",
97
+ "test:global": "pnpm build && node --test test/global-package.test.mjs"
98
+ }
6
99
  }