@agentproto/computer-api 0.0.0-stage → 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/LICENSE +202 -0
- package/README.md +58 -2
- package/dist/index.d.ts +170 -0
- package/dist/index.mjs +94 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +59 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @agentproto/computer-api
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Versioned public contract for the computer controller's HTTP API
|
|
4
|
+
(`POST/GET/DELETE /v1/computers...`): zod schemas plus inferred types for
|
|
5
|
+
every request body, response body, the error envelope, computer states and
|
|
6
|
+
published ports.
|
|
7
|
+
|
|
8
|
+
Generic and deployment-independent: no host names, no IPs, no tenant names,
|
|
9
|
+
no deployment specifics. Template ids are an OPEN string (any id a
|
|
10
|
+
controller has registered); controller error strings are also open.
|
|
11
|
+
|
|
12
|
+
## Design rules
|
|
13
|
+
|
|
14
|
+
- MINIMAL: only fields a client actually consumes are declared.
|
|
15
|
+
- Passthrough everywhere: a controller adding fields never breaks an
|
|
16
|
+
older client.
|
|
17
|
+
- Read-tolerant computer states: unknown future states bucket under
|
|
18
|
+
`"unknown"` instead of throwing.
|
|
19
|
+
- Synchronous, no-throw status reads: the state transform is a widening
|
|
20
|
+
map, not an enum validator.
|
|
21
|
+
|
|
22
|
+
## Versioning
|
|
23
|
+
|
|
24
|
+
`COMPUTER_API_VERSION` (currently `"v1"`) is the API version the schemas
|
|
25
|
+
describe. A major bump of this package is where that constant changes.
|
|
26
|
+
|
|
27
|
+
## Endpoints covered
|
|
28
|
+
|
|
29
|
+
| Method | Route | Request schema | Response schema |
|
|
30
|
+
| ------ | ---------------------------- | --------------------------- | ---------------------------- |
|
|
31
|
+
| POST | `/v1/computers` | `createComputerRequestSchema` | `createComputerResponseSchema` |
|
|
32
|
+
| GET | `/v1/computers/:id` | - | `computerStatusSchema` |
|
|
33
|
+
| POST | `/v1/computers/:id/exec` | `execRequestSchema` | `execResponseSchema` |
|
|
34
|
+
| POST | `/v1/computers/:id/suspend` | - | `suspendResponseSchema` |
|
|
35
|
+
| POST | `/v1/computers/:id/resume` | - | `resumeResponseSchema` |
|
|
36
|
+
| POST | `/v1/computers/:id/attach` | - | `sessionsResponseSchema` |
|
|
37
|
+
| POST | `/v1/computers/:id/detach` | - | `sessionsResponseSchema` |
|
|
38
|
+
| DELETE | `/v1/computers/:id` | - (`?force=true` optional) | `suspendResponseSchema` shape (all-optional) |
|
|
39
|
+
| any | error body | - | `errorResponseSchema` |
|
|
40
|
+
|
|
41
|
+
## Contract tests
|
|
42
|
+
|
|
43
|
+
`src/__tests__/fixtures.ts` carries a valid and an invalid fixture per
|
|
44
|
+
payload; `contract.test.ts` pins them. The fake controller used by
|
|
45
|
+
`@agentproto/sandbox-computer` validates everything it emits against the
|
|
46
|
+
same schemas, so the test double cannot drift from the published contract.
|
|
47
|
+
|
|
48
|
+
## Notes
|
|
49
|
+
|
|
50
|
+
- Sessions: `maxSessions` on create sizes the computer for that many
|
|
51
|
+
concurrent sessions. `attach` takes a slot (409 at the cap), `detach`
|
|
52
|
+
releases one (floors at 0), and `DELETE` answers 409 while sessions are
|
|
53
|
+
attached unless `?force=true` is passed.
|
|
54
|
+
- `resume` MAY rename the computer: the controller can restore the suspend
|
|
55
|
+
snapshot into a fresh computer under a NEW generated id and answer
|
|
56
|
+
`{ id: <new>, state: "running" }`. Callers must treat the old id as gone
|
|
57
|
+
and adopt the returned id.
|
|
58
|
+
- Egress is deny-by-default: a computer created without an
|
|
59
|
+
`egress.allow` list has no DNS.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Version of the computer controller HTTP contract described by this
|
|
5
|
+
* package. The controller routes live under this version prefix (for
|
|
6
|
+
* example `POST /v1/computers`), and every payload schema here corresponds
|
|
7
|
+
* to that version.
|
|
8
|
+
*
|
|
9
|
+
* Semver of the PACKAGE tracks this contract: a MAJOR bump of
|
|
10
|
+
* `@agentproto/computer-api` is where this constant changes.
|
|
11
|
+
*/
|
|
12
|
+
declare const COMPUTER_API_VERSION = "v1";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Driver-level computer states, as reported by `GET /v1/computers/:id`.
|
|
16
|
+
*
|
|
17
|
+
* The controller itself never reports `suspended`: a suspended computer
|
|
18
|
+
* reads back as `stopped`. The state is kept here as a tolerated alias so
|
|
19
|
+
* a newer controller can report it without breaking an older client.
|
|
20
|
+
*/
|
|
21
|
+
declare const COMPUTER_STATES: readonly ["running", "stopped", "paused", "crashed", "starting", "unknown", "missing", "suspended"];
|
|
22
|
+
type ComputerState = (typeof COMPUTER_STATES)[number];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The state field is READ-tolerant: any unknown future state is bucketed
|
|
26
|
+
* under `"unknown"` instead of rejecting, so a status read never throws on
|
|
27
|
+
* controller evolution.
|
|
28
|
+
*/
|
|
29
|
+
declare const computerStateSchema: z.ZodPipe<z.ZodString, z.ZodTransform<"running" | "stopped" | "paused" | "crashed" | "starting" | "unknown" | "missing" | "suspended", string>>;
|
|
30
|
+
declare const COMPUTER_STATE_UNKNOWN: ComputerState;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Zod schemas for the computer controller's HTTP contract constants -
|
|
34
|
+
* the generic, deployment-independent shape of every endpoint:
|
|
35
|
+
*
|
|
36
|
+
* POST /v1/computers create
|
|
37
|
+
* GET /v1/computers/:id status
|
|
38
|
+
* POST /v1/computers/:id/exec synchronous exec of an argv array
|
|
39
|
+
* POST /v1/computers/:id/suspend full snapshot + stop
|
|
40
|
+
* POST /v1/computers/:id/resume restore into a FRESH computer
|
|
41
|
+
* POST /v1/computers/:id/attach take a session slot
|
|
42
|
+
* POST /v1/computers/:id/detach release a session slot
|
|
43
|
+
* DELETE /v1/computers/:id rm + snapshot cleanup (?force=true skips the session check)
|
|
44
|
+
*
|
|
45
|
+
* These are deliberately MINIMAL: only the fields a client actually
|
|
46
|
+
* consumes are declared, and every schema allows (and preserves) extra
|
|
47
|
+
* fields so a controller version adding fields never breaks an older
|
|
48
|
+
* client. Template ids are an OPEN string - any registered id is valid.
|
|
49
|
+
*
|
|
50
|
+
* Nothing deployment-specific belongs here: no host names, no IPs, no
|
|
51
|
+
* tenant names, no auth realm details. Auth headers are wired by the
|
|
52
|
+
* client, not the contract.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/** A published port: the host-side port mapped to the guest-side port. */
|
|
56
|
+
declare const portPublishSchema: z.ZodObject<{
|
|
57
|
+
host: z.ZodNumber;
|
|
58
|
+
guest: z.ZodNumber;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
type PortPublish = z.infer<typeof portPublishSchema>;
|
|
61
|
+
/** Egress allowlist entry in the create body: destination host + port. */
|
|
62
|
+
declare const egressRuleSchema: z.ZodObject<{
|
|
63
|
+
host: z.ZodString;
|
|
64
|
+
port: z.ZodNumber;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
type EgressRule = z.infer<typeof egressRuleSchema>;
|
|
67
|
+
/**
|
|
68
|
+
* Controller error bodies are always `{ error: string }`, sometimes with a
|
|
69
|
+
* `detail` array of validation issues. The `code` strings a controller may
|
|
70
|
+
* emit (for example unknown template, capacity) are contract-OPEN: clients
|
|
71
|
+
* inspect but never switch exhaustively on them.
|
|
72
|
+
*/
|
|
73
|
+
declare const errorResponseSchema: z.ZodObject<{
|
|
74
|
+
error: z.ZodString;
|
|
75
|
+
detail: z.ZodOptional<z.ZodUnknown>;
|
|
76
|
+
}, z.core.$loose>;
|
|
77
|
+
type ErrorResponse = z.infer<typeof errorResponseSchema>;
|
|
78
|
+
/** Request body for `POST /v1/computers`. */
|
|
79
|
+
declare const createComputerRequestSchema: z.ZodObject<{
|
|
80
|
+
template: z.ZodString;
|
|
81
|
+
tenantId: z.ZodString;
|
|
82
|
+
cpus: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
memoryMiB: z.ZodOptional<z.ZodNumber>;
|
|
84
|
+
rootDiskMiB: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
ttl: z.ZodOptional<z.ZodNumber>;
|
|
86
|
+
maxSessions: z.ZodOptional<z.ZodNumber>;
|
|
87
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
88
|
+
egress: z.ZodOptional<z.ZodObject<{
|
|
89
|
+
allow: z.ZodArray<z.ZodObject<{
|
|
90
|
+
host: z.ZodString;
|
|
91
|
+
port: z.ZodNumber;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
}, z.core.$strip>>;
|
|
94
|
+
}, z.core.$loose>;
|
|
95
|
+
type CreateComputerRequest = z.infer<typeof createComputerRequestSchema>;
|
|
96
|
+
/** 201 response body of `POST /v1/computers`. */
|
|
97
|
+
declare const createComputerResponseSchema: z.ZodObject<{
|
|
98
|
+
id: z.ZodString;
|
|
99
|
+
template: z.ZodString;
|
|
100
|
+
state: z.ZodString;
|
|
101
|
+
ports: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
102
|
+
host: z.ZodNumber;
|
|
103
|
+
guest: z.ZodNumber;
|
|
104
|
+
}, z.core.$strip>>>;
|
|
105
|
+
}, z.core.$loose>;
|
|
106
|
+
type CreateComputerResponse = z.infer<typeof createComputerResponseSchema>;
|
|
107
|
+
/**
|
|
108
|
+
* Status response of `GET /v1/computers/:id` (status + published ports and
|
|
109
|
+
* any egress/template metadata; extras preserved). The state is parsed
|
|
110
|
+
* READ-tOLERANTLY: unknown future states bucket under `"unknown"`.
|
|
111
|
+
*/
|
|
112
|
+
declare const computerStatusSchema: z.ZodObject<{
|
|
113
|
+
name: z.ZodString;
|
|
114
|
+
state: z.ZodPipe<z.ZodString, z.ZodTransform<"running" | "stopped" | "paused" | "crashed" | "starting" | "unknown" | "missing" | "suspended", string>>;
|
|
115
|
+
ports: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
116
|
+
host: z.ZodNumber;
|
|
117
|
+
guest: z.ZodNumber;
|
|
118
|
+
}, z.core.$strip>>>;
|
|
119
|
+
template: z.ZodOptional<z.ZodString>;
|
|
120
|
+
tenantId: z.ZodOptional<z.ZodString>;
|
|
121
|
+
}, z.core.$loose>;
|
|
122
|
+
type ComputerStatus = z.infer<typeof computerStatusSchema>;
|
|
123
|
+
/** Request body of `POST /v1/computers/:id/exec` - synchronous argv exec. */
|
|
124
|
+
declare const execRequestSchema: z.ZodObject<{
|
|
125
|
+
argv: z.ZodArray<z.ZodString>;
|
|
126
|
+
timeoutSec: z.ZodNumber;
|
|
127
|
+
}, z.core.$loose>;
|
|
128
|
+
type ExecRequest = z.infer<typeof execRequestSchema>;
|
|
129
|
+
/** 200 response body of `POST /v1/computers/:id/exec`. Controllers may
|
|
130
|
+
* redact registered secret values from the streams and cap their length. */
|
|
131
|
+
declare const execResponseSchema: z.ZodObject<{
|
|
132
|
+
exitCode: z.ZodNumber;
|
|
133
|
+
stdout: z.ZodString;
|
|
134
|
+
stderr: z.ZodString;
|
|
135
|
+
}, z.core.$loose>;
|
|
136
|
+
type ExecResponse = z.infer<typeof execResponseSchema>;
|
|
137
|
+
/** 200 response body of `POST /v1/computers/:id/suspend`. */
|
|
138
|
+
declare const suspendResponseSchema: z.ZodObject<{
|
|
139
|
+
ok: z.ZodOptional<z.ZodBoolean>;
|
|
140
|
+
snapshot: z.ZodOptional<z.ZodString>;
|
|
141
|
+
state: z.ZodOptional<z.ZodString>;
|
|
142
|
+
}, z.core.$loose>;
|
|
143
|
+
type SuspendResponse = z.infer<typeof suspendResponseSchema>;
|
|
144
|
+
/**
|
|
145
|
+
* Response of `POST /v1/computers/:id/resume`. MAY rename the computer:
|
|
146
|
+
* the controller can restore the suspend snapshot into a FRESH computer
|
|
147
|
+
* under a NEW generated id and answer `{ id: <new>, state: "running" }`.
|
|
148
|
+
* Callers must treat the old id as gone and adopt the returned id.
|
|
149
|
+
*/
|
|
150
|
+
declare const resumeResponseSchema: z.ZodObject<{
|
|
151
|
+
ok: z.ZodOptional<z.ZodBoolean>;
|
|
152
|
+
id: z.ZodOptional<z.ZodString>;
|
|
153
|
+
state: z.ZodOptional<z.ZodString>;
|
|
154
|
+
}, z.core.$loose>;
|
|
155
|
+
type ResumeResponse = z.infer<typeof resumeResponseSchema>;
|
|
156
|
+
/**
|
|
157
|
+
* 200 response body of `POST /v1/computers/:id/attach` and `.../detach`:
|
|
158
|
+
* the controller-held session count after the call and the cap the computer
|
|
159
|
+
* was sized for. Neither route takes a body. Attach answers 409 when the
|
|
160
|
+
* computer already hosts `maxSessions` sessions; detach floors at 0.
|
|
161
|
+
* `DELETE /v1/computers/:id` answers 409 while sessions are attached unless
|
|
162
|
+
* the `force=true` query parameter is passed.
|
|
163
|
+
*/
|
|
164
|
+
declare const sessionsResponseSchema: z.ZodObject<{
|
|
165
|
+
sessions: z.ZodOptional<z.ZodNumber>;
|
|
166
|
+
maxSessions: z.ZodOptional<z.ZodNumber>;
|
|
167
|
+
}, z.core.$loose>;
|
|
168
|
+
type SessionsResponse = z.infer<typeof sessionsResponseSchema>;
|
|
169
|
+
|
|
170
|
+
export { COMPUTER_API_VERSION, COMPUTER_STATES, COMPUTER_STATE_UNKNOWN, type ComputerState, type ComputerStatus, type CreateComputerRequest, type CreateComputerResponse, type EgressRule, type ErrorResponse, type ExecRequest, type ExecResponse, type PortPublish, type ResumeResponse, type SessionsResponse, type SuspendResponse, computerStateSchema, computerStatusSchema, createComputerRequestSchema, createComputerResponseSchema, egressRuleSchema, errorResponseSchema, execRequestSchema, execResponseSchema, portPublishSchema, resumeResponseSchema, sessionsResponseSchema, suspendResponseSchema };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @agentproto/computer-api v0.1.0
|
|
5
|
+
*
|
|
6
|
+
* Versioned public contract for the computer controller HTTP API.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// src/version.ts
|
|
10
|
+
var COMPUTER_API_VERSION = "v1";
|
|
11
|
+
var COMPUTER_STATES = [
|
|
12
|
+
"running",
|
|
13
|
+
"stopped",
|
|
14
|
+
"paused",
|
|
15
|
+
"crashed",
|
|
16
|
+
"starting",
|
|
17
|
+
"unknown",
|
|
18
|
+
"missing",
|
|
19
|
+
"suspended"
|
|
20
|
+
];
|
|
21
|
+
var computerStateSchema = z.string().transform((v) => {
|
|
22
|
+
return COMPUTER_STATES.includes(v) ? v : "unknown";
|
|
23
|
+
});
|
|
24
|
+
var COMPUTER_STATE_UNKNOWN = "unknown";
|
|
25
|
+
var portPublishSchema = z.object({
|
|
26
|
+
host: z.number().int(),
|
|
27
|
+
guest: z.number().int()
|
|
28
|
+
});
|
|
29
|
+
var egressRuleSchema = z.object({
|
|
30
|
+
host: z.string(),
|
|
31
|
+
port: z.number().int()
|
|
32
|
+
});
|
|
33
|
+
var errorResponseSchema = z.object({
|
|
34
|
+
error: z.string(),
|
|
35
|
+
detail: z.unknown().optional()
|
|
36
|
+
}).passthrough();
|
|
37
|
+
var createComputerRequestSchema = z.object({
|
|
38
|
+
/** Registered template id (OPEN string; a controller rejects unknown ids). */
|
|
39
|
+
template: z.string(),
|
|
40
|
+
/** Tenant the computer is created under (scope marker, not a name). */
|
|
41
|
+
tenantId: z.string(),
|
|
42
|
+
cpus: z.number().int().optional(),
|
|
43
|
+
memoryMiB: z.number().int().optional(),
|
|
44
|
+
rootDiskMiB: z.number().int().optional(),
|
|
45
|
+
/** Computer TTL seconds. */
|
|
46
|
+
ttl: z.number().int().optional(),
|
|
47
|
+
/** Concurrent sessions the computer is sized for (controller default 1). */
|
|
48
|
+
maxSessions: z.number().int().optional(),
|
|
49
|
+
/** Environment variables injected into the computer. */
|
|
50
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
51
|
+
/** Deny-by-default egress allowlist; a computer created without one has no DNS. */
|
|
52
|
+
egress: z.object({ allow: z.array(egressRuleSchema) }).optional()
|
|
53
|
+
}).passthrough();
|
|
54
|
+
var createComputerResponseSchema = z.object({
|
|
55
|
+
id: z.string(),
|
|
56
|
+
template: z.string(),
|
|
57
|
+
state: z.string(),
|
|
58
|
+
ports: z.array(portPublishSchema).optional()
|
|
59
|
+
}).passthrough();
|
|
60
|
+
var computerStatusSchema = z.object({
|
|
61
|
+
name: z.string(),
|
|
62
|
+
state: computerStateSchema,
|
|
63
|
+
ports: z.array(portPublishSchema).optional(),
|
|
64
|
+
template: z.string().optional(),
|
|
65
|
+
tenantId: z.string().optional()
|
|
66
|
+
}).passthrough();
|
|
67
|
+
var execRequestSchema = z.object({
|
|
68
|
+
argv: z.array(z.string()),
|
|
69
|
+
/** Per-exec timeout; controllers cap this (for example at 600 seconds). */
|
|
70
|
+
timeoutSec: z.number().int()
|
|
71
|
+
}).passthrough();
|
|
72
|
+
var execResponseSchema = z.object({
|
|
73
|
+
exitCode: z.number().int(),
|
|
74
|
+
stdout: z.string(),
|
|
75
|
+
stderr: z.string()
|
|
76
|
+
}).passthrough();
|
|
77
|
+
var suspendResponseSchema = z.object({
|
|
78
|
+
ok: z.boolean().optional(),
|
|
79
|
+
snapshot: z.string().optional(),
|
|
80
|
+
state: z.string().optional()
|
|
81
|
+
}).passthrough();
|
|
82
|
+
var resumeResponseSchema = z.object({
|
|
83
|
+
ok: z.boolean().optional(),
|
|
84
|
+
id: z.string().optional(),
|
|
85
|
+
state: z.string().optional()
|
|
86
|
+
}).passthrough();
|
|
87
|
+
var sessionsResponseSchema = z.object({
|
|
88
|
+
sessions: z.number().int().optional(),
|
|
89
|
+
maxSessions: z.number().int().optional()
|
|
90
|
+
}).passthrough();
|
|
91
|
+
|
|
92
|
+
export { COMPUTER_API_VERSION, COMPUTER_STATES, COMPUTER_STATE_UNKNOWN, computerStateSchema, computerStatusSchema, createComputerRequestSchema, createComputerResponseSchema, egressRuleSchema, errorResponseSchema, execRequestSchema, execResponseSchema, portPublishSchema, resumeResponseSchema, sessionsResponseSchema, suspendResponseSchema };
|
|
93
|
+
//# sourceMappingURL=index.mjs.map
|
|
94
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/version.ts","../src/computer-states.ts","../src/schemas.ts"],"names":["z"],"mappings":"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","file":"index.mjs","sourcesContent":["/**\n * Version of the computer controller HTTP contract described by this\n * package. The controller routes live under this version prefix (for\n * example `POST /v1/computers`), and every payload schema here corresponds\n * to that version.\n *\n * Semver of the PACKAGE tracks this contract: a MAJOR bump of\n * `@agentproto/computer-api` is where this constant changes.\n */\nexport const COMPUTER_API_VERSION = \"v1\"\n","/**\n * Driver-level computer states, as reported by `GET /v1/computers/:id`.\n *\n * The controller itself never reports `suspended`: a suspended computer\n * reads back as `stopped`. The state is kept here as a tolerated alias so\n * a newer controller can report it without breaking an older client.\n */\nexport const COMPUTER_STATES = [\n \"running\",\n \"stopped\",\n \"paused\",\n \"crashed\",\n \"starting\",\n \"unknown\",\n \"missing\",\n \"suspended\",\n] as const\n\nexport type ComputerState = (typeof COMPUTER_STATES)[number]\n\nimport { z } from \"zod\"\n\n/**\n * The state field is READ-tolerant: any unknown future state is bucketed\n * under `\"unknown\"` instead of rejecting, so a status read never throws on\n * controller evolution.\n */\nexport const computerStateSchema = z.string().transform((v): ComputerState => {\n return (COMPUTER_STATES as readonly string[]).includes(v) ? (v as ComputerState) : \"unknown\"\n})\n\nexport const COMPUTER_STATE_UNKNOWN: ComputerState = \"unknown\"\n","/**\n * Zod schemas for the computer controller's HTTP contract constants -\n * the generic, deployment-independent shape of every endpoint:\n *\n * POST /v1/computers create\n * GET /v1/computers/:id status\n * POST /v1/computers/:id/exec synchronous exec of an argv array\n * POST /v1/computers/:id/suspend full snapshot + stop\n * POST /v1/computers/:id/resume restore into a FRESH computer\n * POST /v1/computers/:id/attach take a session slot\n * POST /v1/computers/:id/detach release a session slot\n * DELETE /v1/computers/:id rm + snapshot cleanup (?force=true skips the session check)\n *\n * These are deliberately MINIMAL: only the fields a client actually\n * consumes are declared, and every schema allows (and preserves) extra\n * fields so a controller version adding fields never breaks an older\n * client. Template ids are an OPEN string - any registered id is valid.\n *\n * Nothing deployment-specific belongs here: no host names, no IPs, no\n * tenant names, no auth realm details. Auth headers are wired by the\n * client, not the contract.\n */\n\nimport { z } from \"zod\"\nimport { computerStateSchema } from \"./computer-states.js\"\n\n// ── transport pieces ──────────────────────────────────────────────────\n\n/** A published port: the host-side port mapped to the guest-side port. */\nexport const portPublishSchema = z.object({\n host: z.number().int(),\n guest: z.number().int(),\n})\nexport type PortPublish = z.infer<typeof portPublishSchema>\n\n/** Egress allowlist entry in the create body: destination host + port. */\nexport const egressRuleSchema = z.object({\n host: z.string(),\n port: z.number().int(),\n})\nexport type EgressRule = z.infer<typeof egressRuleSchema>\n\n/**\n * Controller error bodies are always `{ error: string }`, sometimes with a\n * `detail` array of validation issues. The `code` strings a controller may\n * emit (for example unknown template, capacity) are contract-OPEN: clients\n * inspect but never switch exhaustively on them.\n */\nexport const errorResponseSchema = z.object({\n error: z.string(),\n detail: z.unknown().optional(),\n}).passthrough()\nexport type ErrorResponse = z.infer<typeof errorResponseSchema>\n\n// ── POST /v1/computers ────────────────────────────────────────────────\n\n/** Request body for `POST /v1/computers`. */\nexport const createComputerRequestSchema = z.object({\n /** Registered template id (OPEN string; a controller rejects unknown ids). */\n template: z.string(),\n /** Tenant the computer is created under (scope marker, not a name). */\n tenantId: z.string(),\n cpus: z.number().int().optional(),\n memoryMiB: z.number().int().optional(),\n rootDiskMiB: z.number().int().optional(),\n /** Computer TTL seconds. */\n ttl: z.number().int().optional(),\n /** Concurrent sessions the computer is sized for (controller default 1). */\n maxSessions: z.number().int().optional(),\n /** Environment variables injected into the computer. */\n env: z.record(z.string(), z.string()).optional(),\n /** Deny-by-default egress allowlist; a computer created without one has no DNS. */\n egress: z.object({ allow: z.array(egressRuleSchema) }).optional(),\n}).passthrough()\nexport type CreateComputerRequest = z.infer<typeof createComputerRequestSchema>\n\n/** 201 response body of `POST /v1/computers`. */\nexport const createComputerResponseSchema = z.object({\n id: z.string(),\n template: z.string(),\n state: z.string(),\n ports: z.array(portPublishSchema).optional(),\n}).passthrough()\nexport type CreateComputerResponse = z.infer<typeof createComputerResponseSchema>\n\n// ── GET /v1/computers/:id ─────────────────────────────────────────────\n\n/**\n * Status response of `GET /v1/computers/:id` (status + published ports and\n * any egress/template metadata; extras preserved). The state is parsed\n * READ-tOLERANTLY: unknown future states bucket under `\"unknown\"`.\n */\nexport const computerStatusSchema = z.object({\n name: z.string(),\n state: computerStateSchema,\n ports: z.array(portPublishSchema).optional(),\n template: z.string().optional(),\n tenantId: z.string().optional(),\n}).passthrough()\nexport type ComputerStatus = z.infer<typeof computerStatusSchema>\n\n// ── POST /v1/computers/:id/exec ───────────────────────────────────────\n\n/** Request body of `POST /v1/computers/:id/exec` - synchronous argv exec. */\nexport const execRequestSchema = z.object({\n argv: z.array(z.string()),\n /** Per-exec timeout; controllers cap this (for example at 600 seconds). */\n timeoutSec: z.number().int(),\n}).passthrough()\nexport type ExecRequest = z.infer<typeof execRequestSchema>\n\n/** 200 response body of `POST /v1/computers/:id/exec`. Controllers may\n * redact registered secret values from the streams and cap their length. */\nexport const execResponseSchema = z.object({\n exitCode: z.number().int(),\n stdout: z.string(),\n stderr: z.string(),\n}).passthrough()\nexport type ExecResponse = z.infer<typeof execResponseSchema>\n\n// ── POST /v1/computers/:id/suspend ────────────────────────────────────\n\n/** 200 response body of `POST /v1/computers/:id/suspend`. */\nexport const suspendResponseSchema = z.object({\n ok: z.boolean().optional(),\n snapshot: z.string().optional(),\n state: z.string().optional(),\n}).passthrough()\nexport type SuspendResponse = z.infer<typeof suspendResponseSchema>\n\n// ── POST /v1/computers/:id/resume ─────────────────────────────────────\n\n/**\n * Response of `POST /v1/computers/:id/resume`. MAY rename the computer:\n * the controller can restore the suspend snapshot into a FRESH computer\n * under a NEW generated id and answer `{ id: <new>, state: \"running\" }`.\n * Callers must treat the old id as gone and adopt the returned id.\n */\nexport const resumeResponseSchema = z.object({\n ok: z.boolean().optional(),\n id: z.string().optional(),\n state: z.string().optional(),\n}).passthrough()\nexport type ResumeResponse = z.infer<typeof resumeResponseSchema>\n\n// ── POST /v1/computers/:id/attach | detach ────────────────────────────\n\n/**\n * 200 response body of `POST /v1/computers/:id/attach` and `.../detach`:\n * the controller-held session count after the call and the cap the computer\n * was sized for. Neither route takes a body. Attach answers 409 when the\n * computer already hosts `maxSessions` sessions; detach floors at 0.\n * `DELETE /v1/computers/:id` answers 409 while sessions are attached unless\n * the `force=true` query parameter is passed.\n */\nexport const sessionsResponseSchema = z.object({\n sessions: z.number().int().optional(),\n maxSessions: z.number().int().optional(),\n}).passthrough()\nexport type SessionsResponse = z.infer<typeof sessionsResponseSchema>\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentproto/computer-api",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "@agentproto/computer-api — versioned public contract for the computer controller HTTP API: zod schemas and inferred types for create/get/exec/suspend/resume/rm of computers, published ports, status and the error envelope.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agentproto",
|
|
7
|
+
"aip-36",
|
|
8
|
+
"sandbox",
|
|
9
|
+
"computer",
|
|
10
|
+
"microvm",
|
|
11
|
+
"contract",
|
|
12
|
+
"open-standard"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://agentproto.sh/docs/aip-36",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/agentproto/ts",
|
|
18
|
+
"directory": "packages/computer-api"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/agentproto/ts/issues"
|
|
22
|
+
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "dist/index.mjs",
|
|
26
|
+
"module": "dist/index.mjs",
|
|
27
|
+
"types": "dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.mjs",
|
|
32
|
+
"default": "./dist/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE"
|
|
40
|
+
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"zod": "^4.6.5"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "^25.9.5",
|
|
49
|
+
"tsup": "^8.5.1",
|
|
50
|
+
"typescript": "^5.9.3",
|
|
51
|
+
"vitest": "^3.2.7",
|
|
52
|
+
"@agentproto/tooling": "0.1.0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"dev": "tsup --watch",
|
|
56
|
+
"build": "tsup",
|
|
57
|
+
"clean": "rm -rf dist",
|
|
58
|
+
"check-types": "tsc --noEmit",
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"test:watch": "vitest"
|
|
61
|
+
}
|
|
6
62
|
}
|