@intentius/chant-lexicon-e2b 0.0.0-stage → 0.124.32
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 +147 -2
- package/dist/catalog.d.ts +19 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +58 -0
- package/dist/codegen/docs-cli.d.ts +3 -0
- package/dist/codegen/docs-cli.d.ts.map +1 -0
- package/dist/codegen/docs-cli.js +6 -0
- package/dist/codegen/docs.d.ts +15 -0
- package/dist/codegen/docs.d.ts.map +1 -0
- package/dist/codegen/docs.js +123 -0
- package/dist/codegen/generate-cli.d.ts +3 -0
- package/dist/codegen/generate-cli.d.ts.map +1 -0
- package/dist/codegen/generate-cli.js +4 -0
- package/dist/codegen/generate.d.ts +11 -0
- package/dist/codegen/generate.d.ts.map +1 -0
- package/dist/codegen/generate.js +20 -0
- package/dist/codegen/package.d.ts +10 -0
- package/dist/codegen/package.d.ts.map +1 -0
- package/dist/codegen/package.js +34 -0
- package/dist/config.d.ts +113 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +82 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/integrity.json +15 -0
- package/dist/lint/audit-catalog.d.ts +11 -0
- package/dist/lint/audit-catalog.d.ts.map +1 -0
- package/dist/lint/audit-catalog.js +15 -0
- package/dist/lint/post-synth/e2b011-template-name.d.ts +12 -0
- package/dist/lint/post-synth/e2b011-template-name.d.ts.map +1 -0
- package/dist/lint/post-synth/e2b011-template-name.js +48 -0
- package/dist/lint/post-synth/e2b012-steward-tools.d.ts +20 -0
- package/dist/lint/post-synth/e2b012-steward-tools.d.ts.map +1 -0
- package/dist/lint/post-synth/e2b012-steward-tools.js +53 -0
- package/dist/lint/post-synth/index.d.ts +3 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -0
- package/dist/lint/post-synth/index.js +6 -0
- package/dist/lint/rules/index.d.ts +6 -0
- package/dist/lint/rules/index.d.ts.map +1 -0
- package/dist/lint/rules/index.js +6 -0
- package/dist/lint/rules/pinned-image.d.ts +14 -0
- package/dist/lint/rules/pinned-image.d.ts.map +1 -0
- package/dist/lint/rules/pinned-image.js +36 -0
- package/dist/lint/rules/template-literal.d.ts +11 -0
- package/dist/lint/rules/template-literal.d.ts.map +1 -0
- package/dist/lint/rules/template-literal.js +39 -0
- package/dist/lint/rules/template-size.d.ts +10 -0
- package/dist/lint/rules/template-size.d.ts.map +1 -0
- package/dist/lint/rules/template-size.js +31 -0
- package/dist/lsp/completions.d.ts +7 -0
- package/dist/lsp/completions.d.ts.map +1 -0
- package/dist/lsp/completions.js +10 -0
- package/dist/lsp/hover.d.ts +7 -0
- package/dist/lsp/hover.d.ts.map +1 -0
- package/dist/lsp/hover.js +30 -0
- package/dist/manifest.json +6 -0
- package/dist/meta.json +45 -0
- package/dist/okf/index.md +14 -0
- package/dist/okf/rules/E2B001.md +15 -0
- package/dist/okf/rules/E2B002.md +15 -0
- package/dist/okf/rules/E2B011.md +15 -0
- package/dist/okf/rules/E2B012.md +15 -0
- package/dist/okf/types/Template.md +16 -0
- package/dist/op/runtime.d.ts +119 -0
- package/dist/op/runtime.d.ts.map +1 -0
- package/dist/op/runtime.js +522 -0
- package/dist/op/sandbox.d.ts +67 -0
- package/dist/op/sandbox.d.ts.map +1 -0
- package/dist/op/sandbox.js +87 -0
- package/dist/package-cli.d.ts +3 -0
- package/dist/package-cli.d.ts.map +1 -0
- package/dist/package-cli.js +14 -0
- package/dist/plugin.d.ts +12 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +66 -0
- package/dist/resources.d.ts +38 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +21 -0
- package/dist/rules/e2b011-template-name.ts +51 -0
- package/dist/rules/e2b012-steward-tools.ts +58 -0
- package/dist/rules/pinned-image.ts +41 -0
- package/dist/rules/template-literal.ts +42 -0
- package/dist/rules/template-size.ts +36 -0
- package/dist/serializer.d.ts +18 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/serializer.js +70 -0
- package/dist/skills/chant-e2b-ops.md +69 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +67 -4
- package/src/catalog.ts +72 -0
- package/src/codegen/docs-cli.ts +7 -0
- package/src/codegen/docs.ts +130 -0
- package/src/codegen/generate-cli.ts +5 -0
- package/src/codegen/generate.ts +22 -0
- package/src/codegen/package.ts +39 -0
- package/src/config.ts +102 -0
- package/src/index.ts +6 -0
- package/src/lint/audit-catalog.ts +29 -0
- package/src/lint/post-synth/e2b011-template-name.ts +51 -0
- package/src/lint/post-synth/e2b012-steward-tools.ts +58 -0
- package/src/lint/post-synth/index.ts +9 -0
- package/src/lint/post-synth/post-synth.test.ts +59 -0
- package/src/lint/rules/index.ts +9 -0
- package/src/lint/rules/pinned-image.ts +41 -0
- package/src/lint/rules/rules.test.ts +46 -0
- package/src/lint/rules/template-literal.ts +42 -0
- package/src/lint/rules/template-size.ts +36 -0
- package/src/lsp/completions.test.ts +23 -0
- package/src/lsp/completions.ts +13 -0
- package/src/lsp/hover.test.ts +29 -0
- package/src/lsp/hover.ts +35 -0
- package/src/op/ledger-sync.test.ts +136 -0
- package/src/op/runtime.test.ts +394 -0
- package/src/op/runtime.ts +573 -0
- package/src/op/sandbox.ts +138 -0
- package/src/package-cli.ts +16 -0
- package/src/plugin.test.ts +39 -0
- package/src/plugin.ts +79 -0
- package/src/resources.ts +50 -0
- package/src/serializer.test.ts +88 -0
- package/src/serializer.ts +73 -0
- package/src/skills/chant-e2b-ops.md +69 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: lint-rule
|
|
3
|
+
title: E2B001
|
|
4
|
+
description: A template's CPU and memory are sizes E2B accepts.
|
|
5
|
+
id: E2B001
|
|
6
|
+
severity: error
|
|
7
|
+
category: correctness
|
|
8
|
+
lexicon: e2b
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/e2b/rules/
|
|
10
|
+
---
|
|
11
|
+
A template's CPU and memory are sizes E2B accepts.
|
|
12
|
+
|
|
13
|
+
## Applies to
|
|
14
|
+
|
|
15
|
+
- [Template](/types/Template.md)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: lint-rule
|
|
3
|
+
title: E2B002
|
|
4
|
+
description: A template's base image is pinned.
|
|
5
|
+
id: E2B002
|
|
6
|
+
severity: warning
|
|
7
|
+
category: correctness
|
|
8
|
+
lexicon: e2b
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/e2b/rules/
|
|
10
|
+
---
|
|
11
|
+
A template's base image is pinned.
|
|
12
|
+
|
|
13
|
+
## Applies to
|
|
14
|
+
|
|
15
|
+
- [Template](/types/Template.md)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: E2B011
|
|
4
|
+
description: A Template's name must be lowercase letters, digits, dashes and underscores, and unique
|
|
5
|
+
id: E2B011
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: e2b
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/e2b/rules/
|
|
10
|
+
---
|
|
11
|
+
A Template's name must be lowercase letters, digits, dashes and underscores, and unique
|
|
12
|
+
|
|
13
|
+
## Applies to
|
|
14
|
+
|
|
15
|
+
- [Template](/types/Template.md)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: E2B012
|
|
4
|
+
description: A Template a steward runs on needs git and Node
|
|
5
|
+
id: E2B012
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: e2b
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/e2b/rules/
|
|
10
|
+
---
|
|
11
|
+
A Template a steward runs on needs git and Node
|
|
12
|
+
|
|
13
|
+
## Applies to
|
|
14
|
+
|
|
15
|
+
- [Template](/types/Template.md)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: resource-type
|
|
3
|
+
title: Template
|
|
4
|
+
description: e2b resource type E2B::Template
|
|
5
|
+
name: Template
|
|
6
|
+
lexicon: e2b
|
|
7
|
+
resource_type: E2B::Template
|
|
8
|
+
---
|
|
9
|
+
`E2B::Template`, a resource type of the e2b lexicon.
|
|
10
|
+
|
|
11
|
+
## Governed by
|
|
12
|
+
|
|
13
|
+
- [E2B001](/rules/E2B001.md): A template's CPU and memory are sizes E2B accepts.
|
|
14
|
+
- [E2B002](/rules/E2B002.md): A template's base image is pinned.
|
|
15
|
+
- [E2B011](/rules/E2B011.md): A Template's name must be lowercase letters, digits, dashes and underscores, and unique
|
|
16
|
+
- [E2B012](/rules/E2B012.md): A Template a steward runs on needs git and Node
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The e2b `opRuntime` provider: `chant run <op> --on e2b`.
|
|
3
|
+
*
|
|
4
|
+
* A steward is one sandbox that outlives every run: it keeps a clone of the
|
|
5
|
+
* project and its installed tools on its disk, runs one op at a time, and
|
|
6
|
+
* sleeps paused between runs, which costs nothing and survives anything that
|
|
7
|
+
* doesn't delete it. Any API that speaks E2B's hosts one: hosted E2B, or a
|
|
8
|
+
* platform of your own that serves the same API (loam does).
|
|
9
|
+
*
|
|
10
|
+
* A run here is the run a person would have typed in that clone:
|
|
11
|
+
*
|
|
12
|
+
* 1. Find the steward's sandbox by its `chant/steward` metadata, or make it.
|
|
13
|
+
* A sandbox already running an op is busy, and the run is refused rather
|
|
14
|
+
* than queued, as fountain refuses a busy steward conversation.
|
|
15
|
+
* 2. Bring the clone to the commit this checkout is at (fetched from the
|
|
16
|
+
* repository, so the commit must be pushed) and install the project's
|
|
17
|
+
* dependencies when its lockfile changed.
|
|
18
|
+
* 3. Run `chant run <op> --on local --json --progress-json` there, streaming
|
|
19
|
+
* each settled step back through `progress` and its stderr to ours. Gates,
|
|
20
|
+
* leases and the run ledger are the local runtime's, unchanged: they live on
|
|
21
|
+
* the repository's `chant/lifecycle` branch, which chant in the sandbox
|
|
22
|
+
* fetches and pushes with the git token the profile names, so `chant
|
|
23
|
+
* approve` on any checkout answers a gate a steward reached.
|
|
24
|
+
* 4. Pause the sandbox.
|
|
25
|
+
*
|
|
26
|
+
* `status`, `log` and `list` read the run ledger in the steward's clone, and
|
|
27
|
+
* report a run still in progress from the sandbox's process list. They wake
|
|
28
|
+
* the sandbox to do it and leave it to pause itself a few minutes later.
|
|
29
|
+
*
|
|
30
|
+
* Nothing here remembers anything between processes: the sandbox's metadata
|
|
31
|
+
* finds it, the ledger is the history, and the process list is what is running.
|
|
32
|
+
*/
|
|
33
|
+
import { type ChantConfig } from "@intentius/chant/config";
|
|
34
|
+
import type { OpRunRecord, OpRunStartOptions, OpRunStatus, OpRuntimeProvider, StepRecord } from "@intentius/chant/op";
|
|
35
|
+
import { type StewardSandboxes } from "./sandbox.js";
|
|
36
|
+
/** How long a sandbox is held awake at a time while a run is going. Renewed at a third of it. */
|
|
37
|
+
export declare const RUN_AWAKE_MS: number;
|
|
38
|
+
/** How long a read (`status`, `log`, `list`) leaves a woken sandbox awake before it pauses itself. */
|
|
39
|
+
export declare const READ_AWAKE_MS: number;
|
|
40
|
+
/** The template a steward is made from when the profile names none. */
|
|
41
|
+
export declare const DEFAULT_TEMPLATE = "base";
|
|
42
|
+
/** Where the steward keeps its clone, under the sandbox user's home. */
|
|
43
|
+
export declare const CLONE_DIR = "chant-steward";
|
|
44
|
+
export interface E2bOpRuntimeOptions {
|
|
45
|
+
/** The project directory. Default `process.cwd()`. */
|
|
46
|
+
cwd?: string;
|
|
47
|
+
/** The project's chant config, when the caller already has it. */
|
|
48
|
+
config?: ChantConfig;
|
|
49
|
+
/** The sandbox provider. Default: the `e2b` SDK, connected per the profile. */
|
|
50
|
+
sandboxes?: StewardSandboxes;
|
|
51
|
+
/** Read the local checkout. Injectable so a test needs no repository. */
|
|
52
|
+
git?: (args: string[]) => Promise<string>;
|
|
53
|
+
/** Where the sandbox's stderr goes. Default `process.stderr`. */
|
|
54
|
+
stderr?: (chunk: string) => void;
|
|
55
|
+
env?: NodeJS.ProcessEnv;
|
|
56
|
+
now?: () => Date;
|
|
57
|
+
}
|
|
58
|
+
/** An ssh remote as the https URL a sandbox can fetch with a token. Anything else is returned as it is. */
|
|
59
|
+
export declare function httpsRemote(url: string): string;
|
|
60
|
+
/** The repository's name, from its URL: the steward's default name. */
|
|
61
|
+
export declare function repoName(url: string): string;
|
|
62
|
+
/** A word as one shell argument. */
|
|
63
|
+
export declare function shellQuote(value: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* A bash function, `ledger_sync`, that leaves the clone's `chant/lifecycle`
|
|
66
|
+
* branch and the repository's the same, run in the clone after a fetch.
|
|
67
|
+
*
|
|
68
|
+
* chant pushes the facts other checkouts have to see (a gate's pending fact,
|
|
69
|
+
* an approval, a lease) as it writes them, but keeps each run record on the
|
|
70
|
+
* local branch only. A checkout that lives on, as a steward's does, therefore
|
|
71
|
+
* holds commits the repository lacks, and the first approval pushed from
|
|
72
|
+
* anywhere else leaves the two branches diverged; chant then refuses to read
|
|
73
|
+
* the ledger at all. So the steward reconciles before and after every run:
|
|
74
|
+
*
|
|
75
|
+
* - behind, or the same: nothing to do (chant fetches it itself);
|
|
76
|
+
* - ahead: push;
|
|
77
|
+
* - diverged: merge, then push. Every ledger file is append-only, so the
|
|
78
|
+
* merge keeps the repository's tree and adds, for each `.jsonl` file, the
|
|
79
|
+
* local lines it lacks after its own, and any file only the clone has. The
|
|
80
|
+
* merge commit has both tips as parents, so neither side loses a commit.
|
|
81
|
+
*
|
|
82
|
+
* A push that fails (the repository moved again in between, or there is no
|
|
83
|
+
* token) is reported and left for the next run.
|
|
84
|
+
*/
|
|
85
|
+
export declare const LEDGER_SYNC_FN: string;
|
|
86
|
+
/**
|
|
87
|
+
* The script that brings the steward's clone to `commit`: clone it the first
|
|
88
|
+
* time, fetch every branch after that, reconcile the ledger branch
|
|
89
|
+
* ({@link LEDGER_SYNC_FN}), check the commit out over whatever is there, and
|
|
90
|
+
* install dependencies when the lockfile changed. Ignored files
|
|
91
|
+
* (`node_modules`, tool caches) are kept, which is the point of a steward.
|
|
92
|
+
* The token, when there is one, reaches git through a credential helper that
|
|
93
|
+
* reads it from the environment, so it is never written to the sandbox's disk.
|
|
94
|
+
*/
|
|
95
|
+
export declare function prepareScript(repo: string, commit: string): string;
|
|
96
|
+
/** Seconds a stopped run is given to end on SIGTERM before it is killed. */
|
|
97
|
+
export declare const STOP_GRACE_S = 10;
|
|
98
|
+
/** SIGTERM `pid`, wait for it to go, and exit non-zero if it is still there after the grace period. */
|
|
99
|
+
export declare function stopScript(pid: number): string;
|
|
100
|
+
/** After a run: fetch and reconcile the ledger branch, so the run's record reaches the repository. */
|
|
101
|
+
export declare function finishScript(): string;
|
|
102
|
+
/** The command line one run is, in the clone. `exec` so the process the sandbox lists is chant itself. */
|
|
103
|
+
export declare function runScript(op: string, opts: Pick<OpRunStartOptions, "env" | "params" | "work">): string;
|
|
104
|
+
/**
|
|
105
|
+
* The script that prints every run record the clone's ledger holds for `ops`
|
|
106
|
+
* (all of them when empty), one JSON line each, from every environment
|
|
107
|
+
* directory on `chant/lifecycle`. Root-level ledgers only: a workspace
|
|
108
|
+
* member's runs (`_members/<m>/...`) are not read.
|
|
109
|
+
*/
|
|
110
|
+
export declare function ledgerScript(ops: string[]): string;
|
|
111
|
+
/** A ledger line, or a run's final `--json` line, as an {@link OpRunRecord}; anything else `undefined`. */
|
|
112
|
+
export declare function asRunRecord(v: unknown): OpRunRecord | undefined;
|
|
113
|
+
/** A `--progress-json` line as a {@link StepRecord}; anything else `undefined`. */
|
|
114
|
+
export declare function asStepRecord(v: unknown): StepRecord | undefined;
|
|
115
|
+
/** Every record in `text`, one JSON object per line, newest first. */
|
|
116
|
+
export declare function parseLedger(text: string): OpRunRecord[];
|
|
117
|
+
export declare function statusFromRecord(record: OpRunRecord): OpRunStatus;
|
|
118
|
+
export declare function createE2bOpRuntime(opts?: E2bOpRuntimeOptions): OpRuntimeProvider;
|
|
119
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/op/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAyB,WAAW,EAAE,iBAAiB,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG7I,OAAO,EAOL,KAAK,gBAAgB,EACtB,MAAM,WAAW,CAAC;AAEnB,iGAAiG;AACjG,eAAO,MAAM,YAAY,QAAc,CAAC;AAExC,sGAAsG;AACtG,eAAO,MAAM,aAAa,QAAa,CAAC;AAExC,uEAAuE;AACvE,eAAO,MAAM,gBAAgB,SAAS,CAAC;AAEvC,wEAAwE;AACxE,eAAO,MAAM,SAAS,kBAAkB,CAAC;AAEzC,MAAM,WAAW,mBAAmB;IAClC,sDAAsD;IACtD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,yEAAyE;IACzE,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,iEAAiE;IACjE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAWD,2GAA2G;AAC3G,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,uEAAuE;AACvE,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,oCAAoC;AACpC,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,QA4Bf,CAAC;AAEb;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CA0BlE;AAED,4EAA4E;AAC5E,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,uGAAuG;AACvG,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG9C;AAED,sGAAsG;AACtG,wBAAgB,YAAY,IAAI,MAAM,CAQrC;AAED,0GAA0G;AAC1G,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,iBAAiB,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC,GAAG,MAAM,CAUtG;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,CAWlD;AAMD,2GAA2G;AAC3G,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAI/D;AAED,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAI/D;AAED,sEAAsE;AACtE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAYvD;AAwBD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAWjE;AAeD,wBAAgB,kBAAkB,CAAC,IAAI,GAAE,mBAAwB,GAAG,iBAAiB,CAwPpF"}
|