sandcovery 0.9.0 → 0.11.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/README.md +6 -4
- package/dist/cli/index.mjs +80 -44
- package/dist/cli/sandcovery-docker.mjs +43 -43
- package/dist/cli/sandcovery-kubectl.mjs +3 -3
- package/dist/cli/sandcovery-t3.mjs +71 -14
- package/dist/index.d.mts +382 -23
- package/dist/index.mjs +1 -1
- package/dist/{kubectl-Ck04daor.mjs → kubectl-BFu8MVmy.mjs} +2 -2
- package/dist/{saved-sandboxes-BMjkAVGx.mjs → saved-sandboxes-aG7Z7wiX.mjs} +1 -1
- package/dist/{src-DjOLw-ft.mjs → src-Cba__VPt.mjs} +3174 -2849
- package/dist/{sync-rEFjHNC4.mjs → sync-CZQCyiFK.mjs} +2 -2
- package/dist/{types-DotsDqXt.d.mts → types-DLH1pZHc.d.mts} +14 -2
- package/dist/types.d.mts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ sandcovery sandboxes destroySandbox --sandbox_id "$id"
|
|
|
79
79
|
|
|
80
80
|
- A command prints the API's answer body on stdout. An error answer goes to stderr as the API sent it, and the command exits 1.
|
|
81
81
|
- It sends `SANDCOVERY_API_KEY` as the key, and calls `SANDCOVERY_BASE_URL` when it is set, or https://www.sandcovery.com.
|
|
82
|
-
- A flag for a field that is not text, such as a number, a list, or an object, takes JSON. An operation whose body is a file, such as `sandboxes uploadFile`, reads that body from stdin.
|
|
82
|
+
- A flag for a body field that is not text, such as a number, a list, or an object, takes JSON, either as the flag value or as `@` and a path relative to the current directory to a file inside it, such as `--env @env.json`. Every other flag takes its value as text as written, so `--command @run.sh` sends the text `@run.sh`. An operation whose body is a file, such as `sandboxes uploadFile`, reads that body from stdin.
|
|
83
83
|
- `--help` works on every command.
|
|
84
84
|
|
|
85
85
|
## Docker, kubectl, and T3 Code
|
|
@@ -100,7 +100,7 @@ Provider, region, and slug names are open strings, so a name the API adds later
|
|
|
100
100
|
|
|
101
101
|
## Keys and provider credentials
|
|
102
102
|
|
|
103
|
-
`keys`, `credentials`, `usage`, and `billing` need a management key, which an organization
|
|
103
|
+
`keys`, `credentials`, `usage`, and `billing` need a management key, which an organization admin mints in the dashboard. An API key receives 403 there.
|
|
104
104
|
|
|
105
105
|
```ts
|
|
106
106
|
const admin = new Sandcovery({ apiKey: process.env.SANDCOVERY_MANAGEMENT_KEY })
|
|
@@ -110,7 +110,9 @@ await admin.credentials.set('e2b', { api_key: process.env.E2B_API_KEY ?? '' })
|
|
|
110
110
|
|
|
111
111
|
On Pro or the Enterprise plan, an organization holds as many credentials per provider as it needs: `credentials.add(provider, fields)` adds another, a create tries a provider's credentials in the order they were added, and `credentials.deleteOne(provider, id)` deletes one. A Free organization routes one of its own keys per provider, so adding a second key of the same provider receives 403. When an organization leaves Pro or the Enterprise plan, it keeps every key, routes the oldest key of each provider, and `paused` is `true` on the others until it is on Pro or the Enterprise plan again.
|
|
112
112
|
|
|
113
|
-
The fields each provider takes are its `credential_fields` on `sandcovery.providers.get(provider)`. `sandcovery.providers.catalog()` lists every provider on the [provider board](https://www.sandcovery.com/providers), where `routed` is `false` for a provider that is coming soon. `credentials.offer()` reads the free vCPUh your keys have earned, `credentials.countXPost()` finds your newest post on X of the last day that tags @Sandcovery and counts it as one key,
|
|
113
|
+
The fields each provider takes are its `credential_fields` on `sandcovery.providers.get(provider)`. `sandcovery.providers.catalog()` lists every provider on the [provider board](https://www.sandcovery.com/providers), where `routed` is `false` for a provider that is coming soon. `credentials.offer()` reads the free vCPUh your keys have earned, `credentials.countXPost()` finds your newest post on X of the last day that tags @Sandcovery and counts it as one key, counting at most 10 reads of X a UTC day for an organization, 30 seconds apart, and otherwise answering `retry_later` with `retry_at`. `credentials.countXPost()` also answers `retry_later`, without counting the read, when X answers 429 or a 5xx status, times out, or drops the connection.
|
|
114
|
+
|
|
115
|
+
`billing.get()` reads the plan, the credit balance, whether credits are on sale, and auto top-up. `billing.startSubscription({ plan })` answers the Stripe Checkout page that starts a Pro or Enterprise subscription, and `billing.openBillingPortal()` answers the Stripe billing portal page where an admin manages the subscription, payment method, and invoices. `billing.buyCredits({ amount_micro_usd })` answers the Stripe Checkout page that takes a credit payment. `billing.setAutoTopUp({ amount_micro_usd, threshold_micro_usd })` sets the amount Sandcovery charges the saved card each time the credit balance falls below the threshold or a create needs credit that one top-up covers. While auto top-up is on, the change applies at once. While it is off, the answer carries the Stripe Checkout page that saves a card and then turns auto top-up on with these settings. `billing.stopAutoTopUp()` turns auto top-up off. Auto top-up charges the card its own Checkout page saved, not the card the billing portal sets, and removing that card in the portal turns auto top-up off at its next charge. To move it to another card, call `billing.stopAutoTopUp()` and then `billing.setAutoTopUp(...)` again. `billing.openBillingPortal()` throws with the error code `not_found` until the organization has a Stripe customer, which each of these Checkout pages makes.
|
|
114
116
|
|
|
115
117
|
## X account
|
|
116
118
|
|
|
@@ -118,7 +120,7 @@ The fields each provider takes are its `credential_fields` on `sandcovery.provid
|
|
|
118
120
|
|
|
119
121
|
## Interfaces
|
|
120
122
|
|
|
121
|
-
This client
|
|
123
|
+
This client and the Python client have a method for every operation of the REST API except CLI sign-in, the health check, and the choices for a credential field. The `sandcovery` command reaches every operation.
|
|
122
124
|
|
|
123
125
|
## Errors
|
|
124
126
|
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as toTransform, $a as
|
|
3
|
-
import { c as exhaustive, d as value$1, r as follow, t as quoted, u as tag$1 } from "../sync-
|
|
4
|
-
import { r as onPath } from "../kubectl-
|
|
5
|
-
import { a as Credentials, c as credentialsFileOf, d as storedKey, f as writePrivateFile, l as startTool, u as stopSignalOf, w as noop } from "../saved-sandboxes-
|
|
2
|
+
import { $ as toTransform, $a as merge, $i as isFailReason, $n as acquireRelease, $o as dual, $t as makeFilter, A as fail$2, Aa as reduce, Ai as addFinalizerExit, An as merge$2, Ao as getStackTraceLimit, Ar as gen, At as Record, B as mkUint8Array, Bi as fail$3, Bn as fromInputUnsafe$1, Br as matchCauseEffect, Bt as Union, Ca as head, Ci as effect, Cn as fromBody, Co as toArray, Cr as fn, D as drainFork, Da as match$1, Di as succeed$4, Dn as fromInput$1, Do as Prototype, Dr as forkChild, Dt as OptionFromOptionalNullOr, E as decodeText, Ea as map$8, Ei as provideMerge, En as empty$3, Eo as mapInput, Er as forever, Et as OptionFromOptionalKey, F as interruptWhen, Fa as map$9, Fi as doneUnsafe, Fn as make$18, Fo as format, Fr as logError, Ft as TaggedError$1, G as splitLines, Ga as Reference, Gi as Done, Gn as offerUnsafe, Go as isTagged, Gr as onInterrupt, Gt as decodeUnknownEffect$1, H as runCollect, Ha as map$6, Hi as isSuccess, Hn as failCauseUnsafe, Ho as isNullish, Hr as never, Ht as declare, I as isStream, Ia as all$2, Ii as fail$4, In as value, Io as redact, Ir as map$5, It as TaggedUnion, J as toReadableStreamEffect, Ja as empty$6, Ji as fail$5, Jn as take, Jo as ownEnumerableKeys, Jr as provideContext, Jt as encodeSync, K as suspend$1, Ka as Service, Ki as UnknownError, Kn as poll, Ko as isUndefined, Kr as orDie, Kt as decodeUnknownOption, L as merge$1, La as fail$1, Li as isDone, Ln as stringOrRedacted, Lo as hasProperty, Lr as mapEager, Lt as Trim, M as fromChannel$1, Ma as fromIterableWith, Mi as makeUnsafe$1, Mn as set, Mo as BaseProto, Mr as ignoreCause, Mt as SchemaError, N as fromPull, Na as get$4, Ni as provide, Nn as setAll, No as Class, Nr as interrupt$1, Nt as String$7, O as empty$4, Oi as Scope, On as fromRecordUnsafe, Oo as PipeInspectableProto, Or as forkScoped, P as fromReadableStream, Pa as getSomes, Pi as _await, Pn as isRedacted, Po as NodeInspectSymbol, Pr as isEffect, Pt as Struct, Q as mapDone, Qa as make$21, Qi as isDieReason, Qn as runIn, Qo as constant, Qr as runForkWith, Qt as make$17, R as mkArrayBuffer, Ra as getOrThrow, Ri as isDoneUnsafe, Rn as fromSetCookie, Ro as isFunction, Rr as mapError, Rt as TrueLiterals, Si as round, Sn as toString, So as some, Sr as flatMapEager, St as NullOr, T as catchReason$1, Ta as isReadonlyArrayNonEmpty, Ti as provide$1, Tn as CurrentRedactedNames$1, To as String$6, Tr as forEach$1, Tt as OptionFromOptional, U as runDrain, Ua as succeed$1, Ui as succeed$3, Un as make$20, Uo as isObjectKeyword, Ur as onError, Ut as decodeEffect, V as run$3, Va as isSuccess$1, Vi as isFailure, Vn as endUnsafe, Vo as isNotUndefined, Vr as matchEffect, Vt as Unknown, Wa as try_$1, Wi as void_, Wn as offer, Wo as isString, Wr as onExit, Wt as decodeTo$1, X as unwrap$4, Xa as getOrUndefined, Xi as hasInterrupts, Xn as interrupt, Xo as constTrue, Xr as raceFirst, Xt as is, Y as transduce, Ya as get$3, Yi as fromReasons, Yn as getCurrent, Yo as constFalse, Yr as provideService, Yt as fromJsonString, Z as fromTransform$1, Za as getUnsafe, Zi as hasInterruptsOnly, Zn as join$2, Zo as constVoid, Zr as runFork, Zt as isNonEmpty, _ as isHttpMethod, _a as toMillis, _i as withFiber, _n as CurrentRedactedNames, _o as liftThrowable, _r as ensuring, _t as Finite, a as CliSignInStart, aa as ConsoleRef, ai as succeed$2, ao as flatMap$2, ar as callback, ba as findFirstIndex, bi as catchDone, bn as redactUrl, bo as none, br as failSync, bt as Literals$2, ca as MinimumLogLevel$1, ci as tap, cn as decodeTo, co as fromNullishOr, cr as catchFilter, da as DisablePropagation, di as try_, dn as unknown, do as getOrNull, dr as catchTag, dt as ArraySchema, ea as makeDieReason, ei as runSync, en as optional$3, er as addFinalizer$1, es as flow, et as unwrap$3, f as SANDCOVERY_ORIGIN, fa as Error$1, fi as uninterruptible, fn as Transformation, fo as getOrThrowWith, fr as catchTags, ft as Boolean$3, g as allShort, ga as isFinite, gi as void_$1, gn as Pointer, go as liftPredicate, gr as effectify, gt as FalseLiterals, h as fromApi, ha as fromInputUnsafe, hi as useSpan, hn as InvalidValue$1, ho as isSome, hr as contextWith, ht as Error$2, i as SandcoveryApi, ia as ClockRef, ii as sleep, in as toCodecStringTree, ir as cached, is as pipeArguments, ja as sort, ji as close, jn as remove$1, jo as setStackTraceLimit, jr as ignore, jt as RedactedFromValue, k as ensuring$1, ka as of, ki as addFinalizer, kn as isRedactedName, ko as withFiber$1, kr as fromResult, la as TracerEnabled$1, li as tapCause, ln as getIndexSignatureKeys, lo as fromUndefinedOr, lr as catchIf, ma as taggedEnum, mi as updateContext, mn as transformEffect, mo as isNone, mr as context, mt as Defect, n as call, na as reasonAnnotations, ni as scoped, nn as tag, no as exists, nr as andThen, ns as memoize, o as CliSignInToken, oa as LogToStderr$1, oi as suspend, on as decodeUnknownEffect, oo as flatten, or as catchCause, ot as make$19, pa as TaggedError, pi as uninterruptibleMask, pn as passthrough, po as getOrUndefined$1, pr as catch_, pt as BooleanLiterals, q as tapError, qa as add, qi as done, qn as sliding, qo as assignProperty, qr as provide$2, qt as decodeUnknownSync, r as read, ra as squash, ri as serviceOption, rn as toCodecJson, ro as filter, rr as as, rs as pipe, sa as sync$1, si as sync, sn as applyToSelfOrLastLinkEncoding, so as fromNullOr, sr as catchEager, ta as makeFailReason, ti as scope, tn as optionalKey, to as contains, tr as all$1, ts as identity, ua as TracerTimingEnabled$1, ui as tryPromise, un as toEncoded, uo as getOrElse, ur as catchReason, ut as makeUnsafe$2, va as empty$5, vi as withParentSpan, vn as empty$2, vo as map$7, vr as fail, vt as Json, w as callback$1, wa as isCanonicalArrayIndex, wi as mergeAll, wn as unwrap$5, wr as fnUntraced, x as AgentId, xa as findLast, xi as isDoneCause, xn as setAll$1, xo as orElse, xr as flatMap$1, y as Process, ya as findFirst, yi as zipWith, yn as fromInput, yo as match, yr as failCause, yt as Literal, z as mkString, za as isFailure$1, zi as makeUnsafe, zn as bytes, zo as isNotNull, zr as match$2, zt as URL$2 } from "../src-Cba__VPt.mjs";
|
|
3
|
+
import { c as exhaustive, d as value$1, r as follow, t as quoted, u as tag$1 } from "../sync-CZQCyiFK.mjs";
|
|
4
|
+
import { r as onPath } from "../kubectl-BFu8MVmy.mjs";
|
|
5
|
+
import { a as Credentials, c as credentialsFileOf, d as storedKey, f as writePrivateFile, l as startTool, u as stopSignalOf, w as noop } from "../saved-sandboxes-aG7Z7wiX.mjs";
|
|
6
6
|
import http from "node:http";
|
|
7
7
|
import * as OS from "node:os";
|
|
8
8
|
import os, { constants } from "node:os";
|
|
@@ -14132,18 +14132,18 @@ const ApiOperation = Service("@coveries/cli-core/ApiOperation");
|
|
|
14132
14132
|
const FIELD_BODIES = /* @__PURE__ */ new Map([["application/json", "Json"], ["application/x-www-form-urlencoded", "FormUrlEncoded"]]);
|
|
14133
14133
|
const JsonNode = Struct({
|
|
14134
14134
|
$ref: OptionFromOptionalKey(String$7),
|
|
14135
|
-
additionalProperties:
|
|
14135
|
+
additionalProperties: OptionFromOptionalKey(Json),
|
|
14136
14136
|
anyOf: OptionFromOptionalKey(ArraySchema(Json)),
|
|
14137
14137
|
const: OptionFromOptionalKey(Json),
|
|
14138
|
-
description:
|
|
14138
|
+
description: OptionFromOptionalKey(String$7),
|
|
14139
14139
|
enum: OptionFromOptionalKey(ArraySchema(Json)),
|
|
14140
|
-
patternProperties:
|
|
14141
|
-
properties:
|
|
14142
|
-
required:
|
|
14143
|
-
type:
|
|
14140
|
+
patternProperties: OptionFromOptionalKey(Record(String$7, Json)),
|
|
14141
|
+
properties: OptionFromOptionalKey(Record(String$7, Json)),
|
|
14142
|
+
required: OptionFromOptionalKey(ArraySchema(String$7)),
|
|
14143
|
+
type: OptionFromOptionalKey(Json)
|
|
14144
14144
|
});
|
|
14145
14145
|
const Parameter = Struct({
|
|
14146
|
-
description:
|
|
14146
|
+
description: OptionFromOptional(String$7),
|
|
14147
14147
|
in: Literals$2([
|
|
14148
14148
|
"cookie",
|
|
14149
14149
|
"header",
|
|
@@ -14151,23 +14151,23 @@ const Parameter = Struct({
|
|
|
14151
14151
|
"query"
|
|
14152
14152
|
]),
|
|
14153
14153
|
name: String$7,
|
|
14154
|
-
required:
|
|
14155
|
-
schema:
|
|
14154
|
+
required: OptionFromOptional(Boolean$3),
|
|
14155
|
+
schema: OptionFromOptionalNullOr(Json)
|
|
14156
14156
|
});
|
|
14157
14157
|
const OperationSchema = Struct({
|
|
14158
|
-
description:
|
|
14158
|
+
description: OptionFromOptional(String$7),
|
|
14159
14159
|
operationId: String$7,
|
|
14160
|
-
parameters:
|
|
14161
|
-
requestBody:
|
|
14162
|
-
summary:
|
|
14163
|
-
tags:
|
|
14160
|
+
parameters: OptionFromOptional(ArraySchema(Parameter)),
|
|
14161
|
+
requestBody: OptionFromOptional(Struct({ content: Record(String$7, Struct({ schema: OptionFromOptionalNullOr(Json) })) })),
|
|
14162
|
+
summary: OptionFromOptional(String$7),
|
|
14163
|
+
tags: OptionFromOptional(ArraySchema(String$7))
|
|
14164
14164
|
});
|
|
14165
14165
|
const ApiDocumentSchema = Struct({
|
|
14166
|
-
components:
|
|
14167
|
-
info:
|
|
14166
|
+
components: OptionFromOptional(Struct({ schemas: OptionFromOptional(Record(String$7, Json)) })),
|
|
14167
|
+
info: OptionFromOptional(Struct({ description: OptionFromOptional(String$7) })),
|
|
14168
14168
|
paths: Record(String$7, Record(String$7, Unknown)),
|
|
14169
|
-
tags:
|
|
14170
|
-
description:
|
|
14169
|
+
tags: OptionFromOptional(ArraySchema(Struct({
|
|
14170
|
+
description: OptionFromOptional(String$7),
|
|
14171
14171
|
name: String$7
|
|
14172
14172
|
})))
|
|
14173
14173
|
});
|
|
@@ -14187,20 +14187,20 @@ const nodeOf = (document, schema) => {
|
|
|
14187
14187
|
const node = decodeUnknownSync(JsonNode)(schema);
|
|
14188
14188
|
return match(node.$ref, {
|
|
14189
14189
|
onNone: () => node,
|
|
14190
|
-
onSome: (ref) => nodeOf(document, getOrThrowWith(get$4(document.components
|
|
14190
|
+
onSome: (ref) => nodeOf(document, getOrThrowWith(get$4(document.components.pipe(flatMap$2(({ schemas }) => schemas), getOrElse(() => ({}))), ref.replace("#/components/schemas/", "")), () => /* @__PURE__ */ new TypeError(`${ref} names no schema`)))
|
|
14191
14191
|
});
|
|
14192
14192
|
};
|
|
14193
|
-
const hasFixedKeys = (node) => node.type
|
|
14193
|
+
const hasFixedKeys = (node) => contains(node.type, "object") && contains(node.additionalProperties, false) && Object.values(getOrElse(node.patternProperties, () => ({}))).every((value) => value === false);
|
|
14194
14194
|
const isText = (document, schema) => {
|
|
14195
14195
|
const node = nodeOf(document, schema);
|
|
14196
|
-
return node.anyOf.pipe(map$7((members) => members.filter((member) => nodeOf(document, member).type
|
|
14196
|
+
return node.anyOf.pipe(map$7((members) => members.filter((member) => !contains(nodeOf(document, member).type, "null")).every((member) => isText(document, member))), orElse(() => node.enum.pipe(map$7((values) => values.every(isString)))), orElse(() => node.const.pipe(map$7(isString))), getOrElse(() => contains(node.type, "string")));
|
|
14197
14197
|
};
|
|
14198
14198
|
const bodyOf = (document, operation) => {
|
|
14199
|
-
const content = Object.entries(operation.requestBody
|
|
14199
|
+
const content = Object.entries(operation.requestBody.pipe(map$7((body) => body.content), getOrElse(() => ({})))).filter(([, { schema }]) => !contains(nodeOf(document, getOrElse(schema, () => ({}))).type, "null"));
|
|
14200
14200
|
const contentTypes = content.map(([contentType]) => contentType);
|
|
14201
14201
|
if (contentTypes.some((type) => type.startsWith("multipart/"))) throw new TypeError(`${operation.operationId} takes a multipart body`);
|
|
14202
14202
|
const fieldBody = findFirst(content, ([contentType, { schema }]) => fromNullishOr(FIELD_BODIES.get(contentType)).pipe(map$7((tag) => ({
|
|
14203
|
-
node: nodeOf(document, schema
|
|
14203
|
+
node: nodeOf(document, getOrElse(schema, () => ({}))),
|
|
14204
14204
|
tag
|
|
14205
14205
|
})), filter(({ node }) => hasFixedKeys(node))));
|
|
14206
14206
|
return match(fieldBody, {
|
|
@@ -14209,11 +14209,11 @@ const bodyOf = (document, operation) => {
|
|
|
14209
14209
|
contentTypes
|
|
14210
14210
|
},
|
|
14211
14211
|
onSome: ({ node, tag }) => {
|
|
14212
|
-
const required = new Set(node.required);
|
|
14212
|
+
const required = new Set(getOrElse(node.required, () => []));
|
|
14213
14213
|
return {
|
|
14214
14214
|
_tag: tag,
|
|
14215
|
-
fields: Object.entries(node.properties
|
|
14216
|
-
description: nodeOf(document, property).description
|
|
14215
|
+
fields: Object.entries(getOrElse(node.properties, () => ({}))).map(([name, property]) => ({
|
|
14216
|
+
description: nodeOf(document, property).description.pipe(getOrElse(() => "")),
|
|
14217
14217
|
optional: !required.has(name),
|
|
14218
14218
|
text: isText(document, property),
|
|
14219
14219
|
name
|
|
@@ -14236,13 +14236,37 @@ const segmentsOf = ({ operationId }) => {
|
|
|
14236
14236
|
if (segments.length > 2) throw new TypeError(`${operationId} has more than one dot`);
|
|
14237
14237
|
return segments;
|
|
14238
14238
|
};
|
|
14239
|
-
const parameterFields = (document, operation, part) => (operation.parameters
|
|
14240
|
-
description: parameter.description
|
|
14239
|
+
const parameterFields = (document, operation, part) => getOrElse(operation.parameters, () => []).flatMap((parameter) => parameter.in === part ? [{
|
|
14240
|
+
description: parameter.description.pipe(orElse(() => nodeOf(document, getOrElse(parameter.schema, () => ({}))).description), getOrElse(() => "")),
|
|
14241
14241
|
name: parameter.name,
|
|
14242
|
-
optional: parameter.required
|
|
14242
|
+
optional: !contains(parameter.required, true),
|
|
14243
14243
|
text: true
|
|
14244
14244
|
}] : []);
|
|
14245
|
-
const
|
|
14245
|
+
const FETCH_LIMIT_SECONDS = 300;
|
|
14246
|
+
const ANSWER_MARGIN_SECONDS = 60;
|
|
14247
|
+
const answerWaitSeconds = (seconds) => Math.max(FETCH_LIMIT_SECONDS, seconds + ANSWER_MARGIN_SECONDS);
|
|
14248
|
+
const outsideCwd = new InvalidValue$1({ expected: "a JSON value or @path under the current directory" });
|
|
14249
|
+
const unreadableFile = new InvalidValue$1({ expected: "a readable JSON file" });
|
|
14250
|
+
const readJsonFile = fn("readJsonFile")(function* (input) {
|
|
14251
|
+
const path = yield* Path$1;
|
|
14252
|
+
const fileSystem = yield* FileSystem;
|
|
14253
|
+
const root = yield* fileSystem.realPath(".").pipe(mapError(() => unreadableFile));
|
|
14254
|
+
const file = yield* match(path.resolveWithin(root, input), {
|
|
14255
|
+
onNone: () => fail(outsideCwd),
|
|
14256
|
+
onSome: (candidate) => fileSystem.realPath(candidate).pipe(mapError(() => unreadableFile))
|
|
14257
|
+
});
|
|
14258
|
+
return yield* match(path.resolveWithin(root, path.relative(root, file)), {
|
|
14259
|
+
onNone: () => fail(outsideCwd),
|
|
14260
|
+
onSome: (inside) => fileSystem.readFileString(inside).pipe(mapError(() => unreadableFile))
|
|
14261
|
+
});
|
|
14262
|
+
});
|
|
14263
|
+
const json = String$7.pipe(decodeTo$1(fromJsonString(Json), {
|
|
14264
|
+
decode: transformEffect((value) => match(liftPredicate(value, (flag) => flag.startsWith("@")), {
|
|
14265
|
+
onNone: () => succeed$2(value),
|
|
14266
|
+
onSome: (flag) => readJsonFile(flag.slice(1))
|
|
14267
|
+
})),
|
|
14268
|
+
encode: passthrough()
|
|
14269
|
+
}));
|
|
14246
14270
|
const OTHER_ROUTE_SEGMENTS = /* @__PURE__ */ new Set([
|
|
14247
14271
|
"",
|
|
14248
14272
|
".",
|
|
@@ -14265,7 +14289,7 @@ const CONTENT_TYPE = {
|
|
|
14265
14289
|
const endpointCommand = (document, { body, method, operation, path }, { argument, listings, name, parents }) => {
|
|
14266
14290
|
const contentTypes = body._tag === "Stdin" ? body.contentTypes : [];
|
|
14267
14291
|
const media = contentTypes.length > 1 ? [CONTENT_TYPE] : [];
|
|
14268
|
-
if ((operation.parameters
|
|
14292
|
+
if (getOrElse(operation.parameters, () => []).some(({ in: part }) => part === "cookie")) throw new TypeError(`${operation.operationId} takes a cookie parameter`);
|
|
14269
14293
|
const queryFields = parameterFields(document, operation, "query");
|
|
14270
14294
|
const positional = queryFields.filter((field) => contains(argument, field.name));
|
|
14271
14295
|
if (isSome(argument) && positional.length === 0) throw new TypeError(`${operation.operationId} has no query field ${argument.value}`);
|
|
@@ -14276,7 +14300,10 @@ const endpointCommand = (document, { body, method, operation, path }, { argument
|
|
|
14276
14300
|
}),
|
|
14277
14301
|
form: textFlags(body._tag === "FormUrlEncoded" ? body.fields : []),
|
|
14278
14302
|
headers: flagsOf(parameterFields(document, operation, "header"), (field) => withSchema(String$1(field.name), HeaderValue)),
|
|
14279
|
-
json: flagsOf(body._tag === "Json" ? body.fields
|
|
14303
|
+
json: flagsOf(body._tag === "Json" ? body.fields.map((field) => ({
|
|
14304
|
+
...field,
|
|
14305
|
+
description: field.text ? field.description : [field.description, "Takes JSON or @path."].filter((part) => part !== "").join(" ")
|
|
14306
|
+
})) : [], (field) => field.text ? String$1(field.name) : withSchema(String$1(field.name), json)),
|
|
14280
14307
|
media: flagsOf(media, (field) => Literals(field.name, contentTypes)),
|
|
14281
14308
|
params: flagsOf(parameterFields(document, operation, "path").map((field) => ({
|
|
14282
14309
|
...field,
|
|
@@ -14336,7 +14363,7 @@ const endpointCommand = (document, { body, method, operation, path }, { argument
|
|
|
14336
14363
|
"2xx": ({ stream }) => stream.pipe(catchReason$1("HttpClientError", "EmptyBodyError", () => empty$4), run$3(stdio.stdout())),
|
|
14337
14364
|
orElse: answeredOnStderr
|
|
14338
14365
|
});
|
|
14339
|
-
})).pipe(withDescription(operation.summary
|
|
14366
|
+
})).pipe(withDescription(operation.summary.pipe(orElse(() => operation.description), getOrElse(() => ""))));
|
|
14340
14367
|
};
|
|
14341
14368
|
const apiCommand = (name, document, { pickers, verbs }) => {
|
|
14342
14369
|
const endpoints = endpointsOf(document);
|
|
@@ -14360,9 +14387,9 @@ const apiCommand = (name, document, { pickers, verbs }) => {
|
|
|
14360
14387
|
listings
|
|
14361
14388
|
})] : []);
|
|
14362
14389
|
const groups = Map.groupBy(named.filter(({ segments }) => segments.length === 2), ({ segments }) => segments[0]);
|
|
14363
|
-
return make(name).pipe(withDescription(document.info
|
|
14364
|
-
const tag = members[0].endpoint.operation.tags
|
|
14365
|
-
const description = document.tags
|
|
14390
|
+
return make(name).pipe(withDescription(document.info.pipe(flatMap$2(({ description }) => description), getOrElse(() => ""))), withSubcommands([...topLevel, ...Array.from(groups, ([group, members]) => {
|
|
14391
|
+
const tag = members[0].endpoint.operation.tags.pipe(flatMap$2(head));
|
|
14392
|
+
const description = document.tags.pipe(flatMap$2(findFirst((entry) => contains(tag, entry.name))), flatMap$2((entry) => entry.description), getOrElse(() => ""));
|
|
14366
14393
|
const subcommands = members.map(({ argument, endpoint, plain, segments }) => match(flatten(plain), {
|
|
14367
14394
|
onNone: () => endpointCommand(document, endpoint, {
|
|
14368
14395
|
argument: none(),
|
|
@@ -14389,14 +14416,12 @@ const apiCommand = (name, document, { pickers, verbs }) => {
|
|
|
14389
14416
|
})]));
|
|
14390
14417
|
};
|
|
14391
14418
|
// ../cli-core/src/answer-wait.ts
|
|
14392
|
-
const FETCH_LIMIT_SECONDS = 300;
|
|
14393
|
-
const ANSWER_MARGIN_SECONDS = 60;
|
|
14394
14419
|
const UNDICI_NO_LIMIT_MS = 0;
|
|
14395
14420
|
const [FETCH_UNDICI_MAJOR] = (process.versions.undici ?? "").split(".");
|
|
14396
14421
|
const GLOBAL_DISPATCHER = Symbol.for(`undici.globalDispatcher.${Number(FETCH_UNDICI_MAJOR) >= 8 ? "2" : "1"}`);
|
|
14397
14422
|
const decodeGlobalDispatcher = decodeUnknownSync(Struct({ [GLOBAL_DISPATCHER]: declare((input) => hasProperty(input, "dispatch") && isFunction(input.dispatch)) }));
|
|
14398
14423
|
const answeredWithin = (seconds) => {
|
|
14399
|
-
const limit = Number.isFinite(seconds) ?
|
|
14424
|
+
const limit = Number.isFinite(seconds) ? answerWaitSeconds(seconds) * 1e3 : UNDICI_NO_LIMIT_MS;
|
|
14400
14425
|
const dispatcher = { dispatch: (options, handler) => decodeGlobalDispatcher(globalThis)[GLOBAL_DISPATCHER].dispatch({
|
|
14401
14426
|
...options,
|
|
14402
14427
|
bodyTimeout: limit,
|
|
@@ -14477,7 +14502,7 @@ const runApiCli = ({ answerSeconds, name, origin, spec, storedToken, token, vers
|
|
|
14477
14502
|
});
|
|
14478
14503
|
};
|
|
14479
14504
|
// package.json
|
|
14480
|
-
var version = "0.
|
|
14505
|
+
var version = "0.11.0";
|
|
14481
14506
|
// src/cli/commands/sign-in.ts
|
|
14482
14507
|
const LOGIN_USAGE = `Usage: sandcovery login
|
|
14483
14508
|
|
|
@@ -14802,10 +14827,21 @@ if (isSome(local)) {
|
|
|
14802
14827
|
const { timeout_seconds, ttl_seconds } = getOrElse(decodeWaits(json), () => NO_WAITS);
|
|
14803
14828
|
const exec = timeout_seconds ?? 300;
|
|
14804
14829
|
return (/* @__PURE__ */ new Map([
|
|
14830
|
+
["agents.createAgent", PROVIDER_PACED_SECONDS],
|
|
14831
|
+
["agents.deleteAgent", PROVIDER_PACED_SECONDS],
|
|
14832
|
+
["agents.getAgentLogs", PROVIDER_PACED_SECONDS],
|
|
14833
|
+
["agents.openAgentSession", PROVIDER_PACED_SECONDS],
|
|
14834
|
+
["agents.openAgentSsh", PROVIDER_PACED_SECONDS],
|
|
14835
|
+
["agents.openAgentWeb", PROVIDER_PACED_SECONDS],
|
|
14836
|
+
["agents.restartAgent", PROVIDER_PACED_SECONDS],
|
|
14837
|
+
["agents.startAgent", PROVIDER_PACED_SECONDS],
|
|
14838
|
+
["agents.stopAgent", PROVIDER_PACED_SECONDS],
|
|
14805
14839
|
["sandboxes.createSandbox", (ttl_seconds ?? 3600) + 60],
|
|
14806
14840
|
["sandboxes.destroySandbox", PROVIDER_PACED_SECONDS],
|
|
14841
|
+
["sandboxes.detachExecSandbox", PROVIDER_PACED_SECONDS],
|
|
14807
14842
|
["sandboxes.downloadFile", PROVIDER_PACED_SECONDS],
|
|
14808
14843
|
["sandboxes.execSandbox", exec],
|
|
14844
|
+
["sandboxes.getPortPreview", PROVIDER_PACED_SECONDS],
|
|
14809
14845
|
["sandboxes.listFiles", PROVIDER_PACED_SECONDS],
|
|
14810
14846
|
["sandboxes.pauseSandbox", PROVIDER_PACED_SECONDS],
|
|
14811
14847
|
["sandboxes.resumeSandbox", PROVIDER_PACED_SECONDS],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { C as SandboxId, Ct as Number$1,
|
|
3
|
-
import { C as clamp, S as RELAY_ENV, _ as servedOrSpawned, f as writePrivateFile, g as servedAt, h as isTerminal, i as launchedRelay, l as startTool, m as READY, n as savedSandboxes, o as DESTROY_TIMEOUT_MS, p as v7, r as RELAY_PORT, s as createdSandbox, t as runningSandbox, v as socketOf, w as noop } from "../saved-sandboxes-
|
|
4
|
-
import { a as terminalOf, d as value, f as when, i as runAttached, l as orElse, m as __require, n as syncCommand, o as uniq, p as __commonJSMin, s as difference, t as quoted } from "../sync-
|
|
2
|
+
import { Aa as reduce, At as Record, Bt as Union, C as SandboxId, Ca as head, Co as toArray, Ct as Number$1, Et as OptionFromOptionalKey, Kt as decodeUnknownOption, Nt as String$1, Oa as matchLeft, Ot as ReadonlyMap, Pt as Struct, Sa as get, So as some, St as NullOr, Vt as Unknown, Wo as isString, Xt as is, Yt as fromJsonString, _o as liftThrowable, ai as succeed, an as withDecodingDefaultKey, ao as flatMap, b as ProcessTerminal, bo as none, bt as Literals, c as ProviderError, co as fromNullishOr, ct as update, do as getOrNull, dt as ArraySchema, eo as all, fo as getOrThrowWith, ft as Boolean$1, go as liftPredicate, ho as isSome, io as firstSomeOf, it as getAndSet, kt as ReadonlySet, lo as fromUndefinedOr, mo as isNone, no as exists, nt as get$1, ot as make, ro as filter, rt as getAndIncrement, so as fromNullOr, st as set, t as Sandcovery, u as NoProviderAvailable, uo as getOrElse, vo as map, wo as zipWith, wt as Option, ya as findFirst, yo as match, zo as isNotNull } from "../src-Cba__VPt.mjs";
|
|
3
|
+
import { C as clamp, S as RELAY_ENV, _ as servedOrSpawned, f as writePrivateFile, g as servedAt, h as isTerminal, i as launchedRelay, l as startTool, m as READY, n as savedSandboxes, o as DESTROY_TIMEOUT_MS, p as v7, r as RELAY_PORT, s as createdSandbox, t as runningSandbox, v as socketOf, w as noop } from "../saved-sandboxes-aG7Z7wiX.mjs";
|
|
4
|
+
import { a as terminalOf, d as value, f as when, i as runAttached, l as orElse, m as __require, n as syncCommand, o as uniq, p as __commonJSMin, s as difference, t as quoted } from "../sync-CZQCyiFK.mjs";
|
|
5
5
|
import { WebSocket } from "node:http";
|
|
6
6
|
import net from "node:net";
|
|
7
7
|
import { randomBytes } from "node:crypto";
|
|
@@ -6686,39 +6686,39 @@ const AdditionalContexts = Union([ContextList, Record(String$1, String$1)]);
|
|
|
6686
6686
|
const MappingList = ArraySchema(Unknown);
|
|
6687
6687
|
const Mapping = Union([MappingList, Record(String$1, Unknown)]);
|
|
6688
6688
|
const Build = Union([String$1, Struct({
|
|
6689
|
-
additional_contexts:
|
|
6690
|
-
args:
|
|
6691
|
-
context:
|
|
6692
|
-
dockerfile:
|
|
6693
|
-
dockerfile_inline:
|
|
6689
|
+
additional_contexts: AdditionalContexts.pipe(withDecodingDefaultKey(succeed([]))),
|
|
6690
|
+
args: Mapping.pipe(withDecodingDefaultKey(succeed([]))),
|
|
6691
|
+
context: String$1.pipe(withDecodingDefaultKey(succeed("."))),
|
|
6692
|
+
dockerfile: String$1.pipe(withDecodingDefaultKey(succeed(DOCKERFILE$1))),
|
|
6693
|
+
dockerfile_inline: OptionFromOptionalKey(String$1)
|
|
6694
6694
|
})]);
|
|
6695
6695
|
const Volume = Union([String$1, Struct({
|
|
6696
|
-
source:
|
|
6697
|
-
type:
|
|
6696
|
+
source: OptionFromOptionalKey(String$1),
|
|
6697
|
+
type: OptionFromOptionalKey(String$1)
|
|
6698
6698
|
})]);
|
|
6699
6699
|
const FileSource = Struct({
|
|
6700
|
-
environment:
|
|
6701
|
-
file:
|
|
6700
|
+
environment: OptionFromOptionalKey(String$1),
|
|
6701
|
+
file: OptionFromOptionalKey(String$1)
|
|
6702
6702
|
});
|
|
6703
6703
|
const Service = Struct({
|
|
6704
|
-
build:
|
|
6705
|
-
env_file:
|
|
6706
|
-
environment:
|
|
6707
|
-
extends:
|
|
6708
|
-
label_file:
|
|
6709
|
-
volumes:
|
|
6704
|
+
build: OptionFromOptionalKey(Build),
|
|
6705
|
+
env_file: Paths.pipe(withDecodingDefaultKey(succeed([]))),
|
|
6706
|
+
environment: Mapping.pipe(withDecodingDefaultKey(succeed([]))),
|
|
6707
|
+
extends: OptionFromOptionalKey(Union([String$1, FileSource])),
|
|
6708
|
+
label_file: Texts.pipe(withDecodingDefaultKey(succeed([]))),
|
|
6709
|
+
volumes: ArraySchema(Volume).pipe(withDecodingDefaultKey(succeed([])))
|
|
6710
6710
|
});
|
|
6711
6711
|
const IncludeOptions = Struct({
|
|
6712
|
-
env_file:
|
|
6712
|
+
env_file: OptionFromOptionalKey(Paths),
|
|
6713
6713
|
path: Texts,
|
|
6714
|
-
project_directory:
|
|
6714
|
+
project_directory: OptionFromOptionalKey(String$1)
|
|
6715
6715
|
});
|
|
6716
6716
|
const Include = Union([String$1, IncludeOptions]);
|
|
6717
6717
|
const Model = Struct({
|
|
6718
|
-
configs:
|
|
6719
|
-
include:
|
|
6720
|
-
secrets:
|
|
6721
|
-
services:
|
|
6718
|
+
configs: Record(String$1, FileSource).pipe(withDecodingDefaultKey(succeed({}))),
|
|
6719
|
+
include: ArraySchema(Include).pipe(withDecodingDefaultKey(succeed([]))),
|
|
6720
|
+
secrets: Record(String$1, FileSource).pipe(withDecodingDefaultKey(succeed({}))),
|
|
6721
|
+
services: Record(String$1, NullOr(Service)).pipe(withDecodingDefaultKey(succeed({})))
|
|
6722
6722
|
});
|
|
6723
6723
|
Struct({
|
|
6724
6724
|
directory: String$1,
|
|
@@ -6946,14 +6946,14 @@ const buildFound = ({ build, location }) => {
|
|
|
6946
6946
|
location
|
|
6947
6947
|
})
|
|
6948
6948
|
};
|
|
6949
|
-
const contexts = build.additional_contexts
|
|
6949
|
+
const contexts = build.additional_contexts;
|
|
6950
6950
|
const extras = isContextList(contexts) ? contexts.map((entry) => entry.slice(entry.indexOf("=") + 1)) : Object.values(contexts);
|
|
6951
6951
|
return {
|
|
6952
6952
|
...NOTHING_FOUND,
|
|
6953
6953
|
contexts: contextsOf({
|
|
6954
|
-
context: build.context
|
|
6955
|
-
dockerfile: match(
|
|
6956
|
-
onNone: () => some(build.dockerfile
|
|
6954
|
+
context: build.context,
|
|
6955
|
+
dockerfile: match(build.dockerfile_inline, {
|
|
6956
|
+
onNone: () => some(build.dockerfile),
|
|
6957
6957
|
onSome: () => none()
|
|
6958
6958
|
}),
|
|
6959
6959
|
location
|
|
@@ -6962,11 +6962,11 @@ const buildFound = ({ build, location }) => {
|
|
|
6962
6962
|
location,
|
|
6963
6963
|
values: extras
|
|
6964
6964
|
}),
|
|
6965
|
-
names: bareNames(build.args
|
|
6965
|
+
names: bareNames(build.args)
|
|
6966
6966
|
};
|
|
6967
6967
|
};
|
|
6968
6968
|
const bindSources = ({ env, volume }) => {
|
|
6969
|
-
if (!isString(volume)) return
|
|
6969
|
+
if (!isString(volume)) return volume.source.pipe(filter(() => exists(volume.type, (type) => type === "bind")), map((source) => interpolated({
|
|
6970
6970
|
env,
|
|
6971
6971
|
text: source
|
|
6972
6972
|
})), toArray);
|
|
@@ -6979,14 +6979,14 @@ const bindSources = ({ env, volume }) => {
|
|
|
6979
6979
|
return colon > 0 && bind ? [text.slice(0, colon)] : [];
|
|
6980
6980
|
};
|
|
6981
6981
|
const serviceFound = ({ found, load, location, service }) => {
|
|
6982
|
-
const built = match(
|
|
6982
|
+
const built = match(service.build, {
|
|
6983
6983
|
onNone: () => NOTHING_FOUND,
|
|
6984
6984
|
onSome: (build) => buildFound({
|
|
6985
6985
|
build,
|
|
6986
6986
|
location
|
|
6987
6987
|
})
|
|
6988
6988
|
});
|
|
6989
|
-
const bound =
|
|
6989
|
+
const bound = service.volumes.flatMap((volume) => bindSources({
|
|
6990
6990
|
env: location.env,
|
|
6991
6991
|
volume
|
|
6992
6992
|
}).flatMap((text) => homeResolved({
|
|
@@ -6995,21 +6995,21 @@ const serviceFound = ({ found, load, location, service }) => {
|
|
|
6995
6995
|
})));
|
|
6996
6996
|
const envFiles = localPaths({
|
|
6997
6997
|
location,
|
|
6998
|
-
values: pathsOf(service.env_file
|
|
6998
|
+
values: pathsOf(service.env_file)
|
|
6999
6999
|
});
|
|
7000
7000
|
const labelFiles = localPaths({
|
|
7001
7001
|
location,
|
|
7002
|
-
values: [service.label_file
|
|
7002
|
+
values: [service.label_file].flat()
|
|
7003
7003
|
});
|
|
7004
7004
|
const parents = localPaths({
|
|
7005
7005
|
location,
|
|
7006
|
-
values:
|
|
7006
|
+
values: service.extends.pipe(filter(isFileSource), flatMap((parent) => parent.file), toArray)
|
|
7007
7007
|
});
|
|
7008
7008
|
return reduce(parents, joined(found, {
|
|
7009
7009
|
...built,
|
|
7010
7010
|
envFiles,
|
|
7011
7011
|
mounted: [...built.mounted, ...bound],
|
|
7012
|
-
names: [...built.names, ...bareNames(service.environment
|
|
7012
|
+
names: [...built.names, ...bareNames(service.environment)],
|
|
7013
7013
|
read: [...envFiles, ...labelFiles]
|
|
7014
7014
|
}), (current, file) => load({
|
|
7015
7015
|
file,
|
|
@@ -7031,9 +7031,9 @@ const includeFound = ({ found, include, load, location }) => {
|
|
|
7031
7031
|
onSome: (first) => {
|
|
7032
7032
|
const directory = head(localPaths({
|
|
7033
7033
|
location,
|
|
7034
|
-
values: toArray(
|
|
7034
|
+
values: toArray(options.pipe(flatMap((named) => named.project_directory)))
|
|
7035
7035
|
})).pipe(getOrElse(() => path.dirname(first)));
|
|
7036
|
-
const envFiles = match(
|
|
7036
|
+
const envFiles = match(options.pipe(flatMap((named) => named.env_file)), {
|
|
7037
7037
|
onNone: () => [path.join(directory, DOT_ENV)],
|
|
7038
7038
|
onSome: (paths) => localPaths({
|
|
7039
7039
|
location,
|
|
@@ -7088,14 +7088,14 @@ const loadFile = ({ file, found, location }) => {
|
|
|
7088
7088
|
}).flatMap(referencedNames)),
|
|
7089
7089
|
read: [file]
|
|
7090
7090
|
}), (current, model) => {
|
|
7091
|
-
const sources = [...Object.values(model.configs
|
|
7092
|
-
const included = reduce(model.include
|
|
7091
|
+
const sources = [...Object.values(model.configs), ...Object.values(model.secrets)];
|
|
7092
|
+
const included = reduce(model.include, current, (before, include) => includeFound({
|
|
7093
7093
|
found: before,
|
|
7094
7094
|
load: loadFile,
|
|
7095
7095
|
include,
|
|
7096
7096
|
location
|
|
7097
7097
|
}));
|
|
7098
|
-
const served = reduce(Object.values(model.services
|
|
7098
|
+
const served = reduce(Object.values(model.services).filter(isNotNull), included, (before, service) => serviceFound({
|
|
7099
7099
|
found: before,
|
|
7100
7100
|
load: loadFile,
|
|
7101
7101
|
location,
|
|
@@ -7105,9 +7105,9 @@ const loadFile = ({ file, found, location }) => {
|
|
|
7105
7105
|
...NOTHING_FOUND,
|
|
7106
7106
|
mounted: localPaths({
|
|
7107
7107
|
location,
|
|
7108
|
-
values: sources.flatMap((source) =>
|
|
7108
|
+
values: sources.flatMap((source) => toArray(source.file))
|
|
7109
7109
|
}),
|
|
7110
|
-
names: sources.flatMap((source) =>
|
|
7110
|
+
names: sources.flatMap((source) => toArray(source.environment))
|
|
7111
7111
|
});
|
|
7112
7112
|
});
|
|
7113
7113
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { a as watchIdle, i as IDLE_WATCHER_ENV, n as kubectlRun } from "../kubectl-
|
|
4
|
-
import { l as startTool } from "../saved-sandboxes-
|
|
2
|
+
import { So as some } from "../src-Cba__VPt.mjs";
|
|
3
|
+
import { a as watchIdle, i as IDLE_WATCHER_ENV, n as kubectlRun } from "../kubectl-BFu8MVmy.mjs";
|
|
4
|
+
import { l as startTool } from "../saved-sandboxes-aG7Z7wiX.mjs";
|
|
5
5
|
// src/cli/sandcovery-kubectl.ts
|
|
6
6
|
await startTool({
|
|
7
7
|
run: kubectlRun,
|