@yaks/sandbox 0.0.0-stage → 0.2.36

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.
Files changed (74) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +400 -2
  3. package/_dist/bubblewrap.d.ts +38 -0
  4. package/_dist/bubblewrap.d.ts.map +1 -0
  5. package/_dist/cloudflare.d.ts +136 -0
  6. package/_dist/cloudflare.d.ts.map +1 -0
  7. package/_dist/configuration.d.ts +13 -0
  8. package/_dist/configuration.d.ts.map +1 -0
  9. package/_dist/docker.d.ts +15 -0
  10. package/_dist/docker.d.ts.map +1 -0
  11. package/_dist/effects.d.ts +6 -0
  12. package/_dist/effects.d.ts.map +1 -0
  13. package/_dist/lifecycle.d.ts +38 -0
  14. package/_dist/lifecycle.d.ts.map +1 -0
  15. package/_dist/mod.d.ts +4 -0
  16. package/_dist/mod.d.ts.map +1 -0
  17. package/_dist/provider.d.ts +33 -0
  18. package/_dist/provider.d.ts.map +1 -0
  19. package/_dist/pve.d.ts +17 -0
  20. package/_dist/pve.d.ts.map +1 -0
  21. package/_dist/recovery.d.ts +71 -0
  22. package/_dist/recovery.d.ts.map +1 -0
  23. package/_dist/tools.d.ts +4 -0
  24. package/_dist/tools.d.ts.map +1 -0
  25. package/_dist/vocab.d.ts +5 -0
  26. package/_dist/vocab.d.ts.map +1 -0
  27. package/archive.js +60 -0
  28. package/archive.js.map +1 -0
  29. package/archive.ts +49 -0
  30. package/bubblewrap.js +495 -0
  31. package/bubblewrap.js.map +1 -0
  32. package/bubblewrap.ts +555 -0
  33. package/cloudflare.js +434 -0
  34. package/cloudflare.js.map +1 -0
  35. package/cloudflare.ts +592 -0
  36. package/configuration.js +84 -0
  37. package/configuration.js.map +1 -0
  38. package/configuration.ts +120 -0
  39. package/deno.json +1 -0
  40. package/docker.js +149 -0
  41. package/docker.js.map +1 -0
  42. package/docker.ts +206 -0
  43. package/effects.js +86 -0
  44. package/effects.js.map +1 -0
  45. package/effects.ts +78 -0
  46. package/lifecycle.js +153 -0
  47. package/lifecycle.js.map +1 -0
  48. package/lifecycle.ts +207 -0
  49. package/mod.js +6 -0
  50. package/mod.js.map +1 -0
  51. package/mod.ts +7 -0
  52. package/package.json +64 -4
  53. package/provider.js +11 -0
  54. package/provider.js.map +1 -0
  55. package/provider.ts +44 -0
  56. package/pve.js +197 -0
  57. package/pve.js.map +1 -0
  58. package/pve.ts +259 -0
  59. package/recovery-script.js +187 -0
  60. package/recovery-script.js.map +1 -0
  61. package/recovery-script.ts +186 -0
  62. package/recovery.js +231 -0
  63. package/recovery.js.map +1 -0
  64. package/recovery.ts +317 -0
  65. package/sandbox-runner.js +218 -0
  66. package/sandbox-runner.js.map +1 -0
  67. package/sandbox-runner.ts +217 -0
  68. package/tools.js +42 -0
  69. package/tools.js.map +1 -0
  70. package/tools.ts +45 -0
  71. package/vocab.js +13 -0
  72. package/vocab.js.map +1 -0
  73. package/vocab.json +180 -0
  74. package/vocab.ts +11 -0
@@ -0,0 +1,217 @@
1
+ // The sandbox's detached supervisor. Its socket, receipts and output live on
2
+ // the host, outside the bind mount commands see. Every child remains in this
3
+ // supervisor's limited scope; it cannot reach the user manager to escape it.
4
+ export let sandboxRunner = String.raw`
5
+ import base64, json, os, signal, socketserver, subprocess, sys, threading, time
6
+
7
+ root = sys.argv[1]
8
+ with open(root + '/config.json') as f:
9
+ config = json.load(f)
10
+ commands = root + '/commands'
11
+ os.makedirs(commands, mode=0o700, exist_ok=True)
12
+ lock = threading.RLock()
13
+ live = {}
14
+
15
+ def save(path, data):
16
+ temp = path + '.tmp'
17
+ with open(temp, 'w') as f:
18
+ json.dump(data, f)
19
+ os.replace(temp, path)
20
+
21
+ def path_for(id):
22
+ if not id or any(c not in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-' for c in id):
23
+ raise ValueError('invalid command id')
24
+ return commands + '/' + id
25
+
26
+ def state(id):
27
+ try:
28
+ with open(path_for(id) + '.json') as f:
29
+ return json.load(f)
30
+ except FileNotFoundError:
31
+ return None
32
+
33
+ # A supervisor that died cannot safely signal a recorded PID: it may have
34
+ # been reused. A scope is stopped before replacement, and old receipts end
35
+ # with unknown status, never a second launch of the same durable call.
36
+ for name in os.listdir(commands):
37
+ if name.endswith('.json'):
38
+ path = commands + '/' + name
39
+ with open(path) as f:
40
+ old = json.load(f)
41
+ if 'exit' not in old:
42
+ old['exit'] = {'code': None}
43
+ save(path, old)
44
+
45
+ with open('/proc/self/cgroup') as f:
46
+ group = next(line.strip()[3:] for line in f if line.startswith('0::'))
47
+ cgroup = '/sys/fs/cgroup' + group
48
+ with open(cgroup + '/cpu.max') as f:
49
+ quota, period = f.read().split()
50
+ with open(cgroup + '/memory.max') as f:
51
+ memory = f.read().strip()
52
+ with open(cgroup + '/pids.max') as f:
53
+ tasks = f.read().strip()
54
+ limits = config['limits']
55
+ if (quota == 'max' or int(quota) / int(period) > limits['cpuQuota'] / 100 + 0.00001
56
+ or memory == 'max' or int(memory) > limits['memoryMax']
57
+ or tasks == 'max' or int(tasks) > limits['tasksMax']):
58
+ raise RuntimeError('sandbox scope did not apply its CPU, memory and task limits')
59
+
60
+ def argv(args, cwd='/workspace', env=None):
61
+ result = list(config['bwrap'])
62
+ for key, value in (env or {}).items():
63
+ result += ['--setenv', key, value]
64
+ return result + ['--chdir', cwd, '--'] + args
65
+
66
+ # Fail before lending a machine if namespaces or the read-only system cannot
67
+ # actually execute. Never fall back to an unrestricted host command.
68
+ subprocess.run(argv(['/bin/bash', '-c', 'true']), check=True)
69
+
70
+ # One pre-existing reaper and one sequential control server keep look/kill
71
+ # available even when guest forks fill TasksMax. No per-request thread is
72
+ # needed to recover from task pressure.
73
+ def reap():
74
+ while True:
75
+ with lock:
76
+ for id, child in list(live.items()):
77
+ code = child.poll()
78
+ if code is not None:
79
+ value = state(id)
80
+ value['exit'] = {'code': code if code >= 0 else 128 - code}
81
+ save(path_for(id) + '.json', value)
82
+ live.pop(id, None)
83
+ time.sleep(0.025)
84
+
85
+ threading.Thread(target=reap, daemon=True).start()
86
+
87
+ # A path that holds no file the guest may read or write: the caller's mistake.
88
+ class PathFault(Exception):
89
+ pass
90
+
91
+ # A file operation, run in the guest on its path p. Python starts bare
92
+ # (-I -S) and a failure says the last line of its traceback alone: printing
93
+ # the whole one loads more of Python than the operation does. A path fault
94
+ # exits 3, so the host can tell it from a failure of ours.
95
+ def run_file(code, path, data=None):
96
+ script = ('import errno, os, sys\np = sys.argv[1]\ntry:\n ' + code.replace('\n', '\n ') +
97
+ '\nexcept Exception as e:\n print(f"{type(e).__name__}: {e}", file=sys.stderr)'
98
+ '\n sys.exit(3 if getattr(e, "errno", None) in (errno.ENOENT, errno.EACCES,'
99
+ ' errno.ENOTDIR, errno.EISDIR, errno.EROFS) else 1)')
100
+ result = subprocess.run(argv(['/usr/bin/python3', '-I', '-S', '-c', script, path]),
101
+ input=data, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
102
+ said = result.stderr.decode(errors='replace').strip()
103
+ if result.returncode == 3:
104
+ raise PathFault(said)
105
+ if result.returncode:
106
+ raise RuntimeError(said)
107
+ return result.stdout
108
+
109
+ # What each path in the JSON list p names, its links followed: the kind and,
110
+ # where it names something, its canonical path. An unreachable path is
111
+ # missing, as a shell's test -e says.
112
+ STAT = '''import json, stat
113
+ said = []
114
+ for q in json.loads(p):
115
+ try:
116
+ mode = os.stat(q).st_mode
117
+ except OSError:
118
+ said.append({'kind': 'dangling' if os.path.islink(q) else 'missing'})
119
+ continue
120
+ kind = 'file' if stat.S_ISREG(mode) else 'directory' if stat.S_ISDIR(mode) else 'other'
121
+ said.append({'kind': kind, 'canonical': os.path.realpath(q)})
122
+ sys.stdout.write(json.dumps(said))'''
123
+
124
+ def handle(request):
125
+ op = request['op']
126
+ if op == 'hello':
127
+ return {'cgroup': cgroup, 'cpu': [quota, period], 'memory': memory, 'tasks': tasks}
128
+ if op == 'start':
129
+ id = request['id']
130
+ with lock:
131
+ prior = state(id)
132
+ if prior is not None:
133
+ return prior
134
+ # The receipt precedes the external act; an ambiguous receipt is
135
+ # inspectable, but must never cause a durable call to run twice.
136
+ value = {}
137
+ save(path_for(id) + '.json', value)
138
+ try:
139
+ with open(path_for(id) + '.out', 'ab') as output:
140
+ child = subprocess.Popen(argv(['/bin/bash', '-c', request['command']],
141
+ request['cwd'], request['env']), stdin=subprocess.DEVNULL,
142
+ stdout=output, stderr=subprocess.STDOUT, start_new_session=True)
143
+ value['pid'] = child.pid
144
+ save(path_for(id) + '.json', value)
145
+ live[id] = child
146
+ except Exception:
147
+ value['exit'] = {'code': None}
148
+ save(path_for(id) + '.json', value)
149
+ raise
150
+ return value
151
+ if op == 'look':
152
+ with lock:
153
+ return state(request['id'])
154
+ if op == 'tail':
155
+ try:
156
+ with open(path_for(request['id']) + '.out', 'rb') as f:
157
+ # Scan backwards: a long-running agent's whole log is not a
158
+ # request's memory footprint. Keep arbitrarily wide lines.
159
+ blocks = []
160
+ end = f.seek(0, 2)
161
+ lines = 0
162
+ while end and lines <= request['n']:
163
+ size = min(end, 65536)
164
+ end -= size
165
+ f.seek(end)
166
+ block = f.read(size)
167
+ blocks.append(block)
168
+ lines += block.count(b'\n')
169
+ return b''.join(reversed(blocks)).decode(errors='replace').splitlines()[-request['n']:]
170
+ except FileNotFoundError:
171
+ return []
172
+ if op == 'kill':
173
+ with lock:
174
+ child = live.get(request['id'])
175
+ if child is not None and child.poll() is None:
176
+ try:
177
+ os.killpg(child.pid, getattr(signal, request['signal']))
178
+ except ProcessLookupError:
179
+ pass
180
+ return None
181
+ if op in ('read', 'export'):
182
+ code = 'sys.stdout.buffer.write(open(p, "rb").read())'
183
+ if op == 'export':
184
+ code = ('p = os.path.realpath(p); '
185
+ 'assert p.startswith("/workspace/"), "export escapes workspace"; ' + code)
186
+ return base64.b64encode(run_file(code, request['path'])).decode()
187
+ if op == 'stat':
188
+ return json.loads(run_file(STAT, json.dumps(request['paths'])))
189
+ if op == 'write':
190
+ run_file('os.makedirs(os.path.dirname(p), exist_ok=True); '
191
+ 'open(p, "wb").write(sys.stdin.buffer.read())',
192
+ request['path'], base64.b64decode(request['bytes']))
193
+ return None
194
+ raise ValueError('unknown sandbox operation')
195
+
196
+ class Handler(socketserver.StreamRequestHandler):
197
+ def handle(self):
198
+ try:
199
+ response = {'value': handle(json.loads(self.rfile.readline()))}
200
+ except PathFault as e:
201
+ response = {'error': str(e), 'refused': 'path'}
202
+ except Exception as e:
203
+ response = {'error': str(e)}
204
+ self.wfile.write((json.dumps(response) + '\n').encode())
205
+
206
+ class Server(socketserver.UnixStreamServer):
207
+ pass
208
+
209
+ sock = root + '/control.sock'
210
+ try:
211
+ os.unlink(sock)
212
+ except FileNotFoundError:
213
+ pass
214
+ with Server(sock, Handler) as server:
215
+ os.chmod(sock, 0o600)
216
+ server.serve_forever()
217
+ `
package/tools.js ADDED
@@ -0,0 +1,42 @@
1
+ // Persisted tool calls are the explicit creation and disposal doors.
2
+ import { argsOf, identityEid } from "@yaks/graph";
3
+ import { sandboxDispose, sandboxNew, sandboxRestore } from "./lifecycle.js";
4
+ import { resolveOptions } from "./configuration.js";
5
+ /** Resolve implementation bindings at invocation, after the graph is open. */ export let runs = (host, configuration = {})=>({
6
+ sandbox_new: async (call, graph)=>{
7
+ let options = await resolveOptions(host, configuration);
8
+ let args = argsOf(call);
9
+ let row = await sandboxNew(graph, options.providers, {
10
+ id: identityEid('sandbox', [
11
+ call.entity.eid
12
+ ]),
13
+ provider: String(args.provider),
14
+ ...args.machine ? {
15
+ machine: String(args.machine)
16
+ } : {},
17
+ ...args.from ? {
18
+ from: String(args.from)
19
+ } : {},
20
+ ...args.image ? {
21
+ image: String(args.image)
22
+ } : {}
23
+ });
24
+ return [
25
+ row
26
+ ];
27
+ },
28
+ sandbox_restore: async (call, graph)=>{
29
+ let options = await resolveOptions(host, configuration);
30
+ return [
31
+ await sandboxRestore(graph, options.providers, String(argsOf(call).sandbox))
32
+ ];
33
+ },
34
+ sandbox_dispose: async (call, graph)=>{
35
+ let options = await resolveOptions(host, configuration);
36
+ let args = argsOf(call);
37
+ return [
38
+ await sandboxDispose(graph, options.providers, String(args.sandbox))
39
+ ];
40
+ }
41
+ });
42
+ //# sourceMappingURL=tools.js.map
package/tools.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sources":["./tools.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,SAAS,MAAM,EAAE,WAAW,2BAAgC;AAE5D,SAAS,cAAc,EAAE,UAAU,EAAE,cAAc,yBAAwB;AAC3E,SAGE,cAAc,6BACW;AAE3B,4EAA4E,GAC5E,OAAO,IAAI,OAAO,CAChB,MACA,gBAA+B,CAAC,CAAC,GACxB,CAAC;IACV,aAAa,OAAO,MAAM;MACxB,IAAI,UAAU,MAAM,eAAe,MAAM;MACzC,IAAI,OAAO,OAAO;MAClB,IAAI,MAAM,MAAM,WAAW,OAAO,QAAQ,SAAS,EAAE;QACnD,IAAI,YAAY,WAAW;UAAC,KAAK,MAAM,CAAC,GAAG;SAAC;QAC5C,UAAU,OAAO,KAAK,QAAQ;QAC9B,GAAI,KAAK,OAAO,GAAG;UAAE,SAAS,OAAO,KAAK,OAAO;QAAE,IAAI,CAAC,CAAC;QACzD,GAAI,KAAK,IAAI,GAAG;UAAE,MAAM,OAAO,KAAK,IAAI;QAAE,IAAI,CAAC,CAAC;QAChD,GAAI,KAAK,KAAK,GAAG;UAAE,OAAO,OAAO,KAAK,KAAK;QAAE,IAAI,CAAC,CAAC;MACrD;MACA,OAAO;QAAC;OAAI;IACd;IACA,iBAAiB,OAAO,MAAM;MAC5B,IAAI,UAAU,MAAM,eAAe,MAAM;MACzC,OAAO;QACL,MAAM,eACJ,OACA,QAAQ,SAAS,EACjB,OAAO,OAAO,MAAM,OAAO;OAE9B;IACH;IACA,iBAAiB,OAAO,MAAM;MAC5B,IAAI,UAAU,MAAM,eAAe,MAAM;MACzC,IAAI,OAAO,OAAO;MAClB,OAAO;QACL,MAAM,eAAe,OAAO,QAAQ,SAAS,EAAE,OAAO,KAAK,OAAO;OACnE;IACH;EACF,CAAC,EAAC"}
package/tools.ts ADDED
@@ -0,0 +1,45 @@
1
+ // Persisted tool calls are the explicit creation and disposal doors.
2
+ import { argsOf, identityEid } from '@yaks/graph'
3
+ import type { Runs } from 'jsr:@yaks/graph@0.2.36/tools'
4
+ import { sandboxDispose, sandboxNew, sandboxRestore } from './lifecycle.js'
5
+ import {
6
+ type Configuration,
7
+ type ConfigurationHost,
8
+ resolveOptions,
9
+ } from './configuration.js'
10
+
11
+ /** Resolve implementation bindings at invocation, after the graph is open. */
12
+ export let runs = (
13
+ host: ConfigurationHost,
14
+ configuration: Configuration = {},
15
+ ): Runs => ({
16
+ sandbox_new: async (call, graph) => {
17
+ let options = await resolveOptions(host, configuration)
18
+ let args = argsOf(call)
19
+ let row = await sandboxNew(graph, options.providers, {
20
+ id: identityEid('sandbox', [call.entity.eid]),
21
+ provider: String(args.provider),
22
+ ...(args.machine ? { machine: String(args.machine) } : {}),
23
+ ...(args.from ? { from: String(args.from) } : {}),
24
+ ...(args.image ? { image: String(args.image) } : {}),
25
+ })
26
+ return [row]
27
+ },
28
+ sandbox_restore: async (call, graph) => {
29
+ let options = await resolveOptions(host, configuration)
30
+ return [
31
+ await sandboxRestore(
32
+ graph,
33
+ options.providers,
34
+ String(argsOf(call).sandbox),
35
+ ),
36
+ ]
37
+ },
38
+ sandbox_dispose: async (call, graph) => {
39
+ let options = await resolveOptions(host, configuration)
40
+ let args = argsOf(call)
41
+ return [
42
+ await sandboxDispose(graph, options.providers, String(args.sandbox)),
43
+ ]
44
+ },
45
+ })
package/vocab.js ADDED
@@ -0,0 +1,13 @@
1
+ // Sandbox declarations shared by servers and browsers; no provisioning runs here.
2
+ import doc from './vocab.json' with {
3
+ type: 'json'
4
+ };
5
+ import manifest from './package.json' with {
6
+ type: 'json'
7
+ };
8
+ /** Containers, jails and confirmed disposal. */ export let sandboxDoc = doc;
9
+ /** The package description. */ export let description = manifest.description;
10
+ /** Every vocabulary document this package declares. */ export let docs = [
11
+ sandboxDoc
12
+ ];
13
+ //# sourceMappingURL=vocab.js.map
package/vocab.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab.js","sources":["./vocab.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAElF,OAAO,SAAS,oBAAoB;EAAE,MAAM;AAAO,EAAC;AACpD,OAAO,cAAc,sBAAsB;EAAE,MAAM;AAAO,EAAC;AAE3D,8CAA8C,GAC9C,OAAO,IAAI,aAAuB,IAAe;AACjD,6BAA6B,GAC7B,OAAO,IAAI,cAAsB,SAAS,WAAW,CAAA;AACrD,qDAAqD,GACrD,OAAO,IAAI,OAAmB;EAAC;CAAW,CAAA"}
package/vocab.json ADDED
@@ -0,0 +1,180 @@
1
+ {
2
+ "$id": "urn:uuid:07824ad7-e2f0-422e-8d00-576ece48ef68",
3
+ "$defs": {
4
+ "sandbox": {
5
+ "$id": "urn:uuid:9e9953ea-5b63-46da-b069-0042bf703361",
6
+ "component": true,
7
+ "journal": false,
8
+ "type": "object",
9
+ "embed": false,
10
+ "description": "an actual or requested container or jail on the computer recorded in its workspace; placement is never inferred from the graph host",
11
+ "status": {
12
+ "released": "released",
13
+ "failed": "failed",
14
+ "pending": "requested",
15
+ "default": "ready"
16
+ },
17
+ "properties": {
18
+ "provider": {
19
+ "$id": "urn:uuid:c82d2713-697c-4b11-8b86-15c5caefc3b5",
20
+ "type": "string",
21
+ "description": "the configured sandbox implementation, not an LLM provider entity"
22
+ },
23
+ "address": {
24
+ "$id": "urn:uuid:be208818-c3fb-4885-a765-732c4c2dc9d7",
25
+ "type": "string",
26
+ "description": "the external sandbox resource locator, not a computer address"
27
+ },
28
+ "from": {
29
+ "$id": "urn:uuid:82e94613-d442-41f4-a14b-6cccfe10e10c",
30
+ "type": "string",
31
+ "ref": "gitobj",
32
+ "death": "keep",
33
+ "description": "the initial Git commit; provenance does not reconstruct subsequent edits"
34
+ },
35
+ "image": {
36
+ "$id": "urn:uuid:133aa6a9-013a-4ab0-a955-e9d4f7cb96de",
37
+ "type": "string",
38
+ "description": "the requested image when the backend supports images"
39
+ }
40
+ }
41
+ },
42
+ "released": {
43
+ "$id": "urn:uuid:19604f71-2ce8-4da0-9098-9034c9e6c88f",
44
+ "component": true,
45
+ "journal": false,
46
+ "type": "object",
47
+ "description": "sandbox retained in recoverable trash after its provider stops execution; restored by sandbox_restore; never purged automatically",
48
+ "properties": {
49
+ "at": {
50
+ "$id": "urn:uuid:fee97d3b-3e59-4338-bcae-3fa83771b0c3",
51
+ "type": "string",
52
+ "format": "date-time",
53
+ "stamped": true,
54
+ "description": "when disposal was confirmed"
55
+ },
56
+ "by": {
57
+ "$id": "urn:uuid:db3ebd8f-13b1-4f96-be15-89dbbdc72107",
58
+ "type": "string",
59
+ "ref": "entity",
60
+ "death": "keep",
61
+ "description": "who requested disposal",
62
+ "stamped": true
63
+ },
64
+ "via": {
65
+ "$id": "urn:uuid:4f368063-9b46-4d92-a4c1-3f07b7d76d30",
66
+ "type": "string",
67
+ "ref": "entity",
68
+ "death": "keep",
69
+ "description": "the session through which disposal was requested",
70
+ "stamped": true
71
+ }
72
+ }
73
+ },
74
+ "lent": {
75
+ "$id": "urn:uuid:6a5be510-b2ee-4699-ab60-6c813f12a529",
76
+ "component": true,
77
+ "journal": false,
78
+ "type": "object",
79
+ "description": "a sandbox lent to one person within a group that allows only so many awake at once; kept while it sleeps, so the group's erasure finds every one",
80
+ "properties": {
81
+ "to": {
82
+ "$id": "urn:uuid:eba4d307-9eb1-4845-b678-b18538c651a5",
83
+ "type": "string",
84
+ "ref": "entity",
85
+ "death": "keep",
86
+ "description": "the person it is lent to; a group lends each person one"
87
+ },
88
+ "within": {
89
+ "$id": "urn:uuid:ffd52cae-3002-4029-b95f-cacfe5204baa",
90
+ "type": "string",
91
+ "ref": "entity",
92
+ "death": "cascade",
93
+ "description": "the group whose allowance of awake sandboxes it counts against, such as a space"
94
+ },
95
+ "until": {
96
+ "$id": "urn:uuid:f9e541dc-3567-4b7a-bc81-6aed3a6072dd",
97
+ "type": "string",
98
+ "format": "date-time",
99
+ "description": "when it sleeps on its own unless called again; absent once it is known to be asleep"
100
+ }
101
+ }
102
+ },
103
+ "sandbox_provision": {
104
+ "effect": true,
105
+ "created": [
106
+ "pending",
107
+ "sandbox",
108
+ "workspace"
109
+ ],
110
+ "changed": [
111
+ "workspace.machine"
112
+ ],
113
+ "target": ".sandbox .workspace .pending !released !failed",
114
+ "description": "provision a recorded sandbox intention using its preallocated durable resource id"
115
+ },
116
+ "sandbox_new": {
117
+ "tool": true,
118
+ "destructive": false,
119
+ "description": "Record a sandbox intention before external provisioning.",
120
+ "input": {
121
+ "provider": {
122
+ "type": "string"
123
+ },
124
+ "machine": {
125
+ "type": "string",
126
+ "ref": "machine"
127
+ },
128
+ "from": {
129
+ "type": "string",
130
+ "ref": "gitobj"
131
+ },
132
+ "image": {
133
+ "type": "string"
134
+ }
135
+ },
136
+ "required": [
137
+ "provider"
138
+ ],
139
+ "noun": "sandbox",
140
+ "verb": "new",
141
+ "applied": true,
142
+ "idempotent": true
143
+ },
144
+ "sandbox_dispose": {
145
+ "tool": true,
146
+ "description": "Stop a sandbox and retain its writable files in recoverable trash. Restore it with sandbox_restore. Does not purge storage.",
147
+ "input": {
148
+ "sandbox": {
149
+ "type": "string",
150
+ "ref": "sandbox"
151
+ }
152
+ },
153
+ "required": [
154
+ "sandbox"
155
+ ],
156
+ "noun": "sandbox",
157
+ "verb": "dispose",
158
+ "applied": true,
159
+ "idempotent": true
160
+ },
161
+ "sandbox_restore": {
162
+ "tool": true,
163
+ "description": "Restore a sandbox from the trash, preserving its existing writable files and identity.",
164
+ "input": {
165
+ "sandbox": {
166
+ "type": "string",
167
+ "ref": "sandbox"
168
+ }
169
+ },
170
+ "required": [
171
+ "sandbox"
172
+ ],
173
+ "noun": "sandbox",
174
+ "verb": "restore",
175
+ "applied": true,
176
+ "idempotent": true,
177
+ "destructive": false
178
+ }
179
+ }
180
+ }
package/vocab.ts ADDED
@@ -0,0 +1,11 @@
1
+ // Sandbox declarations shared by servers and browsers; no provisioning runs here.
2
+ import type { VocabDoc } from 'jsr:@yaks/vocab@0.2.36'
3
+ import doc from './vocab.json' with { type: 'json' }
4
+ import manifest from './package.json' with { type: 'json' }
5
+
6
+ /** Containers, jails and confirmed disposal. */
7
+ export let sandboxDoc: VocabDoc = doc as VocabDoc
8
+ /** The package description. */
9
+ export let description: string = manifest.description
10
+ /** Every vocabulary document this package declares. */
11
+ export let docs: VocabDoc[] = [sandboxDoc]