@glubean/runner 0.2.3 → 0.2.5

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,65 @@
1
+ /**
2
+ * @module runner-input-templating
3
+ *
4
+ * `{{VAR}}` substitution for runner-supplied inputs (attachment-model
5
+ * §8). The runner interpolates string scalars before schema validation;
6
+ * `env` is never read inside bootstrap (§8).
7
+ *
8
+ * Patterns supported (per §8 spec — kept minimal in v0):
9
+ * - `{{VAR}}` — substitute the entire string with the env value
10
+ * (preserves type only when string; numeric envs stay strings)
11
+ * - `prefix-{{VAR}}-suffix` — string interpolation; result is a string
12
+ * - `{{VAR1}}{{VAR2}}` — multiple substitutions in one string
13
+ *
14
+ * Errors:
15
+ * - Missing required var → `Error("Templating: missing env var \"VAR\"")`
16
+ * - Whitespace inside braces is stripped; `{{ VAR }}` works.
17
+ *
18
+ * Scope:
19
+ * - Recursive across plain objects and arrays.
20
+ * - Strings get substitution; numbers / booleans / null pass through.
21
+ * - Functions / class instances / Maps / Sets / etc. are unsupported
22
+ * for v0 (the input is JSON-shaped by the time it reaches us, so
23
+ * this is fine).
24
+ */
25
+ const PATTERN = /\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g;
26
+ /**
27
+ * Apply `{{VAR}}` substitution to all string scalars inside `value`,
28
+ * resolving variables from `env`. Returns a new value (does not mutate
29
+ * the input).
30
+ *
31
+ * @throws when a referenced var is missing in `env`.
32
+ */
33
+ export function applyEnvTemplating(value, env) {
34
+ if (typeof value === "string") {
35
+ return substituteString(value, env);
36
+ }
37
+ if (Array.isArray(value)) {
38
+ return value.map((item) => applyEnvTemplating(item, env));
39
+ }
40
+ if (value !== null && typeof value === "object") {
41
+ const out = {};
42
+ for (const [k, v] of Object.entries(value)) {
43
+ out[k] = applyEnvTemplating(v, env);
44
+ }
45
+ return out;
46
+ }
47
+ return value;
48
+ }
49
+ function substituteString(s, env) {
50
+ // Reset stateful regex.
51
+ PATTERN.lastIndex = 0;
52
+ // Fast-path: no braces present → nothing to do (preserves identity-
53
+ // sensitive string equality on hot paths).
54
+ if (!s.includes("{{"))
55
+ return s;
56
+ return s.replace(PATTERN, (_match, varName) => {
57
+ const v = env[varName];
58
+ if (v === undefined) {
59
+ throw new Error(`Templating: missing env var "${varName}" referenced in runner input. ` +
60
+ `Set it in your environment or .env file (CLI / MCP read both).`);
61
+ }
62
+ return v;
63
+ });
64
+ }
65
+ //# sourceMappingURL=runner-input-templating.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner-input-templating.js","sourceRoot":"","sources":["../src/runner-input-templating.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,OAAO,GAAG,yCAAyC,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAc,EACd,GAAuC;IAEvC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YACtE,GAAG,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,gBAAgB,CACvB,CAAS,EACT,GAAuC;IAEvC,wBAAwB;IACxB,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC;IAEtB,oEAAoE;IACpE,2CAA2C;IAC3C,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAEhC,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,OAAe,EAAE,EAAE;QACpD,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;QACvB,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACb,gCAAgC,OAAO,gCAAgC;gBACrE,gEAAgE,CACnE,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glubean/runner",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -16,10 +16,12 @@
16
16
  "access": "public"
17
17
  },
18
18
  "dependencies": {
19
+ "dotenv": "^16.4.0",
19
20
  "ky": "^1.14.0",
20
21
  "p-queue": "^9.1.0",
21
22
  "tsx": "^4.19.0",
22
- "@glubean/sdk": "0.2.1"
23
+ "@glubean/sdk": "0.2.3",
24
+ "@glubean/scanner": "0.2.3"
23
25
  },
24
26
  "devDependencies": {
25
27
  "@types/node": "^22.0.0",