@lilbox/contracts 0.0.0-stage → 0.0.2

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,256 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$ref": "#/$defs/Manifest",
4
+ "$defs": {
5
+ "Manifest": {
6
+ "type": "object",
7
+ "properties": {
8
+ "version": {
9
+ "type": "number",
10
+ "const": 1
11
+ },
12
+ "name": {
13
+ "description": "Defaults to the app the manifest is deployed to.",
14
+ "type": "string",
15
+ "pattern": "^[a-z][a-z0-9-]{1,30}[a-z0-9]$"
16
+ },
17
+ "build": {
18
+ "type": "object",
19
+ "properties": {
20
+ "dockerfile": {
21
+ "default": "Dockerfile",
22
+ "type": "string"
23
+ },
24
+ "context": {
25
+ "default": ".",
26
+ "type": "string"
27
+ },
28
+ "builder": {
29
+ "description": "auto = buildpacks (later).",
30
+ "default": "dockerfile",
31
+ "type": "string",
32
+ "enum": [
33
+ "dockerfile",
34
+ "auto"
35
+ ]
36
+ },
37
+ "args": {
38
+ "type": "object",
39
+ "propertyNames": {
40
+ "type": "string",
41
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,127}$",
42
+ "description": "Environment variable or secret name."
43
+ },
44
+ "additionalProperties": {
45
+ "type": "string"
46
+ }
47
+ }
48
+ }
49
+ },
50
+ "run": {
51
+ "type": "object",
52
+ "properties": {
53
+ "port": {
54
+ "description": "Also exported as $PORT.",
55
+ "default": 8080,
56
+ "type": "integer",
57
+ "minimum": 1,
58
+ "maximum": 65535
59
+ },
60
+ "health": {
61
+ "type": "object",
62
+ "properties": {
63
+ "path": {
64
+ "default": "/",
65
+ "type": "string",
66
+ "pattern": "^\\/"
67
+ },
68
+ "timeout": {
69
+ "default": "2s",
70
+ "type": "string",
71
+ "pattern": "^\\d+(ms|s|m|h|d)$"
72
+ }
73
+ }
74
+ },
75
+ "size": {
76
+ "default": "nano",
77
+ "type": "string",
78
+ "enum": [
79
+ "nano",
80
+ "small",
81
+ "medium",
82
+ "large"
83
+ ],
84
+ "description": "nano .25 vCPU/.5 GB · small .5/1 · medium 1/2 · large 2/4. On serverless, sets memory."
85
+ },
86
+ "request_timeout": {
87
+ "type": "string",
88
+ "pattern": "^\\d+(ms|s|m|h|d)$"
89
+ },
90
+ "max_body": {
91
+ "type": "string",
92
+ "pattern": "^\\d+(KB|MB)$"
93
+ }
94
+ }
95
+ },
96
+ "scale": {
97
+ "type": "object",
98
+ "properties": {
99
+ "min": {
100
+ "description": "0 = scale to zero. ≥1 = always on (Pro).",
101
+ "default": 0,
102
+ "type": "integer",
103
+ "minimum": 0,
104
+ "maximum": 20
105
+ },
106
+ "max": {
107
+ "default": 3,
108
+ "type": "integer",
109
+ "minimum": 1,
110
+ "maximum": 100
111
+ },
112
+ "idle_timeout": {
113
+ "type": "string",
114
+ "pattern": "^\\d+(ms|s|m|h|d)$"
115
+ }
116
+ }
117
+ },
118
+ "region": {
119
+ "default": "us-east",
120
+ "type": "string",
121
+ "enum": [
122
+ "us-east"
123
+ ]
124
+ },
125
+ "runtime": {
126
+ "description": "serverless (Lambda, every plan) · container (Fargate, Pro) · auto lets plan choose.",
127
+ "default": "auto",
128
+ "type": "string",
129
+ "enum": [
130
+ "auto",
131
+ "serverless",
132
+ "container"
133
+ ]
134
+ },
135
+ "needs": {
136
+ "description": "Capabilities the app declares it needs. Always wins over detection.",
137
+ "type": "array",
138
+ "items": {
139
+ "type": "string",
140
+ "enum": [
141
+ "work_after_response",
142
+ "in_process_scheduler",
143
+ "queue_consumer",
144
+ "websockets",
145
+ "writes_outside_tmp",
146
+ "needs_root",
147
+ "long_requests",
148
+ "large_bodies",
149
+ "always_on",
150
+ "slow_boot"
151
+ ],
152
+ "description": "A runtime capability an app may need (05 §7.3)."
153
+ }
154
+ },
155
+ "env": {
156
+ "description": "Plain config. Secrets go through set_secret, never here.",
157
+ "type": "object",
158
+ "propertyNames": {
159
+ "type": "string",
160
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,127}$",
161
+ "description": "Environment variable or secret name."
162
+ },
163
+ "additionalProperties": {
164
+ "type": "string"
165
+ }
166
+ },
167
+ "secrets": {
168
+ "description": "Names of secrets the app expects. Values are set with set_secret.",
169
+ "type": "array",
170
+ "items": {
171
+ "type": "string",
172
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,127}$",
173
+ "description": "Environment variable or secret name."
174
+ }
175
+ },
176
+ "cron": {
177
+ "description": "Platform cron: signed POSTs to the app on a schedule.",
178
+ "maxItems": 20,
179
+ "type": "array",
180
+ "items": {
181
+ "type": "object",
182
+ "properties": {
183
+ "schedule": {
184
+ "type": "string",
185
+ "minLength": 9,
186
+ "maxLength": 100,
187
+ "description": "Cron expression in UTC, e.g. \"*/30 * * * *\"."
188
+ },
189
+ "path": {
190
+ "type": "string",
191
+ "pattern": "^\\/[^\\s]*$",
192
+ "description": "Path that receives a signed POST (X-Lilbox-Signature)."
193
+ },
194
+ "timeout": {
195
+ "default": "60s",
196
+ "type": "string",
197
+ "pattern": "^\\d+(ms|s|m|h|d)$"
198
+ }
199
+ },
200
+ "required": [
201
+ "schedule",
202
+ "path"
203
+ ]
204
+ }
205
+ },
206
+ "release": {
207
+ "type": "object",
208
+ "properties": {
209
+ "migrate": {
210
+ "type": "array",
211
+ "items": {
212
+ "type": "string"
213
+ }
214
+ },
215
+ "seed": {
216
+ "type": "array",
217
+ "items": {
218
+ "type": "string"
219
+ }
220
+ }
221
+ }
222
+ },
223
+ "database": {
224
+ "description": "Managed Postgres (coming soon). Until then, bring your own and set DATABASE_URL as a secret.",
225
+ "type": "object",
226
+ "properties": {
227
+ "postgres": {
228
+ "type": "object",
229
+ "properties": {
230
+ "tier": {
231
+ "default": "shared",
232
+ "type": "string",
233
+ "enum": [
234
+ "shared",
235
+ "dedicated"
236
+ ]
237
+ },
238
+ "version": {
239
+ "type": "string"
240
+ }
241
+ }
242
+ }
243
+ },
244
+ "required": [
245
+ "postgres"
246
+ ]
247
+ }
248
+ },
249
+ "required": [
250
+ "version"
251
+ ],
252
+ "title": "lilbox app.yaml"
253
+ }
254
+ },
255
+ "$id": "https://api.lilbox.ai/schemas/app.schema.json"
256
+ }
@@ -0,0 +1,127 @@
1
+ import { z } from "zod";
2
+ export declare const SuspensionReason: z.ZodEnum<{
3
+ abuse: "abuse";
4
+ phishing: "phishing";
5
+ malware: "malware";
6
+ spam: "spam";
7
+ fraud: "fraud";
8
+ legal: "legal";
9
+ }>;
10
+ export declare const ActivityEvent: z.ZodObject<{
11
+ id: z.ZodString;
12
+ at: z.ZodISODateTime;
13
+ actor: z.ZodObject<{
14
+ user_id: z.ZodString;
15
+ via: z.ZodEnum<{
16
+ dashboard: "dashboard";
17
+ agent: "agent";
18
+ github: "github";
19
+ api_key: "api_key";
20
+ system: "system";
21
+ }>;
22
+ credential_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
23
+ credential_name: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strip>;
25
+ operation: z.ZodString;
26
+ app_id: z.ZodOptional<z.ZodString>;
27
+ deployment_id: z.ZodOptional<z.ZodString>;
28
+ summary: z.ZodString;
29
+ result: z.ZodEnum<{
30
+ failed: "failed";
31
+ succeeded: "succeeded";
32
+ }>;
33
+ error_code: z.ZodOptional<z.ZodEnum<{
34
+ internal: "internal";
35
+ unauthenticated: "unauthenticated";
36
+ forbidden_scope: "forbidden_scope";
37
+ approval_required: "approval_required";
38
+ payment_required: "payment_required";
39
+ quota_exceeded: "quota_exceeded";
40
+ rate_limited: "rate_limited";
41
+ suspended: "suspended";
42
+ invalid_request: "invalid_request";
43
+ invalid_manifest: "invalid_manifest";
44
+ not_found: "not_found";
45
+ conflict: "conflict";
46
+ not_available: "not_available";
47
+ plan_unavailable: "plan_unavailable";
48
+ source_too_large: "source_too_large";
49
+ build_failed: "build_failed";
50
+ image_too_large: "image_too_large";
51
+ migration_failed: "migration_failed";
52
+ healthcheck_failed: "healthcheck_failed";
53
+ app_crashed_on_start: "app_crashed_on_start";
54
+ deploy_timeout: "deploy_timeout";
55
+ capability_requires_plan: "capability_requires_plan";
56
+ capability_unconfirmed: "capability_unconfirmed";
57
+ domain_unverified: "domain_unverified";
58
+ cert_pending: "cert_pending";
59
+ db_quota_exceeded: "db_quota_exceeded";
60
+ }>>;
61
+ request_id: z.ZodString;
62
+ ip: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strip>;
64
+ export declare const list_activity: import("./define.js").OperationDef<z.ZodObject<{
65
+ limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
66
+ cursor: z.ZodOptional<z.ZodString>;
67
+ app_id: z.ZodOptional<z.ZodString>;
68
+ credential_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
69
+ since: z.ZodOptional<z.ZodISODateTime>;
70
+ until: z.ZodOptional<z.ZodISODateTime>;
71
+ }, z.core.$strip>, z.ZodObject<{
72
+ events: z.ZodArray<z.ZodObject<{
73
+ id: z.ZodString;
74
+ at: z.ZodISODateTime;
75
+ actor: z.ZodObject<{
76
+ user_id: z.ZodString;
77
+ via: z.ZodEnum<{
78
+ dashboard: "dashboard";
79
+ agent: "agent";
80
+ github: "github";
81
+ api_key: "api_key";
82
+ system: "system";
83
+ }>;
84
+ credential_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
85
+ credential_name: z.ZodOptional<z.ZodString>;
86
+ }, z.core.$strip>;
87
+ operation: z.ZodString;
88
+ app_id: z.ZodOptional<z.ZodString>;
89
+ deployment_id: z.ZodOptional<z.ZodString>;
90
+ summary: z.ZodString;
91
+ result: z.ZodEnum<{
92
+ failed: "failed";
93
+ succeeded: "succeeded";
94
+ }>;
95
+ error_code: z.ZodOptional<z.ZodEnum<{
96
+ internal: "internal";
97
+ unauthenticated: "unauthenticated";
98
+ forbidden_scope: "forbidden_scope";
99
+ approval_required: "approval_required";
100
+ payment_required: "payment_required";
101
+ quota_exceeded: "quota_exceeded";
102
+ rate_limited: "rate_limited";
103
+ suspended: "suspended";
104
+ invalid_request: "invalid_request";
105
+ invalid_manifest: "invalid_manifest";
106
+ not_found: "not_found";
107
+ conflict: "conflict";
108
+ not_available: "not_available";
109
+ plan_unavailable: "plan_unavailable";
110
+ source_too_large: "source_too_large";
111
+ build_failed: "build_failed";
112
+ image_too_large: "image_too_large";
113
+ migration_failed: "migration_failed";
114
+ healthcheck_failed: "healthcheck_failed";
115
+ app_crashed_on_start: "app_crashed_on_start";
116
+ deploy_timeout: "deploy_timeout";
117
+ capability_requires_plan: "capability_requires_plan";
118
+ capability_unconfirmed: "capability_unconfirmed";
119
+ domain_unverified: "domain_unverified";
120
+ cert_pending: "cert_pending";
121
+ db_quota_exceeded: "db_quota_exceeded";
122
+ }>>;
123
+ request_id: z.ZodString;
124
+ ip: z.ZodOptional<z.ZodString>;
125
+ }, z.core.$strip>>;
126
+ next_cursor: z.ZodOptional<z.ZodString>;
127
+ }, z.core.$strip>>;
@@ -0,0 +1,64 @@
1
+ // Group 5: Security & Safety. What's refused, what's shut down, and the record of what happened.
2
+ //
3
+ // It never runs anything itself. To shut something down it tells Runtime to suspend, Deployment to refuse and
4
+ // Account to block credentials.
5
+ //
6
+ // Activity event one per change (every mutating call): who, through which agent or key, what, result.
7
+ // Append-only. Visible to the owner through list_activity.
8
+ // Suspension a shutdown by lilbox, of an app or a whole account. Admin-only (internal admin API,
9
+ // not in these contracts); users see its effects: `suspended` errors and the suspended page.
10
+ // Trial eligibility one trial per person: normalised verified email, GitHub ID, card fingerprint at subscribe;
11
+ // disposable-email domains blocked. Billing asks before starting a trial.
12
+ // Name policy besides RESERVED_APP_NAMES, brand and lookalike names are refused at create_app
13
+ // (conflict, reason name_not_allowed).
14
+ // Secret encryption KMS key + one data key per owner; secrets are decrypted only by the worker, into the
15
+ // app's function.
16
+ // Rate limits per credential and per IP (rate_limited). Abuse protection, not a Billing limit.
17
+ //
18
+ // No approvals in phase 1: subscribing goes through Stripe Checkout. Policy approvals come in phase 2.
19
+ import { z } from "zod";
20
+ import { ActivityEventId, AgentGrantId, ApiKeyId, AppId, DeploymentId, NextCursor, PageInput, Timestamp, UserId } from "./common.js";
21
+ import { defineOperation } from "./define.js";
22
+ import { ErrorCodeSchema } from "./errors.js";
23
+ export const SuspensionReason = z.enum(["abuse", "phishing", "malware", "spam", "fraud", "legal"]);
24
+ export const ActivityEvent = z
25
+ .object({
26
+ id: ActivityEventId,
27
+ at: Timestamp,
28
+ actor: z.object({
29
+ user_id: UserId,
30
+ via: z.enum(["dashboard", "agent", "api_key", "github", "system"]),
31
+ credential_id: z.union([AgentGrantId, ApiKeyId]).optional().meta({ description: "The connected agent or API key, when via is agent or api_key." }),
32
+ credential_name: z.string().optional().meta({ description: 'e.g. "Claude Code" or the API key\'s name.' }),
33
+ }),
34
+ operation: z.string().meta({ description: 'The operation called, e.g. "create_deployment", "set_secret".' }),
35
+ app_id: AppId.optional(),
36
+ deployment_id: DeploymentId.optional(),
37
+ summary: z.string().meta({ description: 'Human-readable, e.g. "set secret STRIPE_KEY" (never the value).' }),
38
+ result: z.enum(["succeeded", "failed"]),
39
+ error_code: ErrorCodeSchema.optional(),
40
+ request_id: z.string(),
41
+ ip: z.string().optional(),
42
+ })
43
+ .meta({ id: "ActivityEvent" });
44
+ export const list_activity = defineOperation({
45
+ name: "list_activity",
46
+ title: "List activity",
47
+ description: "Lists every change made on the account, newest first: who made it and through which agent or API key, what " +
48
+ "operation, on which app, and whether it succeeded. Filter by app, credential or time. Use it to answer " +
49
+ "what an agent did, or what changed before something broke.",
50
+ http: { method: "GET", path: "/v1/activity" },
51
+ scopes: ["apps:read"],
52
+ mutating: false,
53
+ phase: 1,
54
+ audience: "agent",
55
+ input: z.object({
56
+ app_id: AppId.optional(),
57
+ credential_id: z.union([AgentGrantId, ApiKeyId]).optional(),
58
+ since: Timestamp.optional(),
59
+ until: Timestamp.optional(),
60
+ ...PageInput,
61
+ }),
62
+ output: z.object({ events: z.array(ActivityEvent), next_cursor: NextCursor }),
63
+ hints: { readOnly: true },
64
+ });
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "@lilbox/contracts",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.2",
4
+ "description": "The lilbox API's shapes: MCP tools, REST operations, errors, app.yaml, and the contracts between lilbox repos. zod schemas.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/lilbox-ai/lilbox-platform.git",
10
+ "directory": "libs/contracts"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./openapi.json": "./dist/openapi.json",
18
+ "./schemas/*": "./dist/schemas/*"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "!dist/internal"
23
+ ],
24
+ "sideEffects": false,
25
+ "peerDependencies": {
26
+ "zod": "^4.1.0"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ }
31
+ }