@gapi/gcli 1.8.252 → 1.8.254

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,29 @@
1
+ ## 2026-11-02 - lambforge-agent-skill: gcli build reads lambforge.yaml and works without tsconfig; environment flags sent as numbers without --spec; unset lambda scale values left to the plan
2
+
3
+ **Feature:** lambforge-agent-skill · **Type:** fix
4
+
5
+ From the static-hosting handover (an agent needed 9 attempts; graphql-server
6
+ plan 16 C5-C8):
7
+
8
+ - `commands/build/index.ts`: no commander defaults for files / bundle /
9
+ minify / target / outfile, so `build.ts`'s fallback runs: flag ->
10
+ `lambforge.yaml` (`function.file`, `options.bundler.*`) -> index.ts /
11
+ bundle / `node24` / index.js. The `-t node14.4` default used to win over the
12
+ yaml every time. `build.ts`: the decorators plugin only when a
13
+ `tsconfig.json` exists (`[plugin: tsc] failed to open 'undefined'`).
14
+ - `commands/environment/environment-payload.ts`: create/update send numeric
15
+ flags as numbers (`--poolSize 0` was `"0"` -> `Expected type Int`), drop
16
+ the CLI-only `spec` / `project` / `clusterName` (`Field "spec" is not
17
+ defined`), and refuse a non-number with the flag name.
18
+ - `commands/lambda/helpers/index.ts`: unset `concurrency`,
19
+ `functionTimeout`, `specializationTimeout` are sent as 0 - the server fills
20
+ them in within the plan. The fixed 500 / 60 / 120 were refused on plans
21
+ with lower maxima.
22
+ - **Test:** `npx jest --coverage=false test/environment-payload.spec.ts`;
23
+ manual: a project with only `src/main.ts` + `lambforge.yaml`
24
+ (`file: ./src/main.ts`, `outfile: out.js`) -> `gcli build` writes `out.js`.
25
+ - **Debug:** `gcli build` bundling the wrong file = a flag or yaml field
26
+ overrides it (`--files` wins); `Expected type Int` from environment
27
+ commands = an old gcli.
28
+ - **Verification:** 133/133 tests, `tsc --noEmit` + eslint clean; the manual
29
+ build above ran on the rebuilt `release/index.js`.
@@ -0,0 +1,17 @@
1
+ ## 2026-11-02 - mcp-proxy: mcp:start refreshes the login token per request instead of failing every call with 401 after an hour
2
+
3
+ **Feature:** mcp-proxy · **Type:** fix
4
+
5
+ - `src/commands/proxy/start.ts`: `performFetch` sets `Authorization` from
6
+ `currentToken()` (via `GraphqlClienAPI.getConfig()`, refreshed after
7
+ 30 min; concurrent requests share one refresh) on every forwarded request.
8
+ The token used to be fixed in the transport's `requestInit` at startup, and
9
+ the 401 retry only fixed that one request - and never ran anyway, because
10
+ the upstream returns 200 with the subgraph's 401 inside the tool result.
11
+ - New feature doc `docs/features/mcp-proxy.md` (plan 16 C4 in graphql-server).
12
+ - **Test:** `npx jest --coverage=false test/mcp-proxy-token.spec.ts` - token
13
+ read per request, one shared refresh, forced refresh + retry on 401.
14
+ - **Debug:** gateway log `auth/id-token-expired`; proxy stderr `[DEBUG]
15
+ Request failed with 401. Refreshing token...`.
16
+ - **Verification:** 129/129 gcli tests, `tsc --noEmit` clean, eslint clean;
17
+ live check pending (needs an MCP session running > 1 h on the new build).
@@ -38,3 +38,4 @@ Outline (drop sections that don't apply):
38
38
  | `workflows` | [workflows.md](workflows.md) | `workflow:*` commands incl. AI drafts (`workflow:generate`); canonical doc in graphql-server-lambdas |
39
39
  | `virtual-clusters` | [virtual-clusters.md](virtual-clusters.md) | cluster:create --virtual, provider: vcluster (slice; canonical in graphql-server-functions) |
40
40
  | `self-managed-nodes` | [self-managed-nodes.md](self-managed-nodes.md) | `cluster:attach/nodes/detach` - your own machine as a Talos worker (slice; canonical in graphql-server-functions) |
41
+ | `mcp-proxy` | [mcp-proxy.md](mcp-proxy.md) | `gcli mcp:start` - local stdio MCP server forwarding to the platform MCP endpoint; token refreshed per request |
@@ -0,0 +1,30 @@
1
+ # MCP proxy (`gcli mcp:start`)
2
+
3
+ **Feature slug:** `mcp-proxy` · history: `node scripts/changelog.mjs render --feature mcp-proxy`.
4
+
5
+ `gcli mcp:start` is a stdio MCP server that Claude Code / other clients run
6
+ locally (`claude mcp add --scope user lambforge -- gcli mcp:start`). It
7
+ forwards every request to the platform's MCP endpoint
8
+ (`<login url without /graphql>/mcp`, or `--url`) over streamable HTTP, as the
9
+ `gcli login` user. Code: `src/commands/proxy/start.ts`.
10
+
11
+ ## Auth
12
+
13
+ The login token is a Firebase ID token (1 h). Every forwarded request reads
14
+ it through `GraphqlClienAPI.getConfig()`, which refreshes it after 30 min
15
+ (`currentToken()`, one shared refresh for concurrent requests). An HTTP
16
+ 401/403 forces a refresh and one retry.
17
+
18
+ Until 2026-11-02 the token was fixed at startup: after an hour every tool
19
+ call failed with `401: Unauthorized`. The upstream answers HTTP 200 with the
20
+ subgraph's 401 inside the tool result, so the 401 retry never fired - the
21
+ gateway logs `auth/id-token-expired`.
22
+
23
+ ## How to debug
24
+
25
+ - All tools 401 at once: the gateway's `[GATEWAY][ERROR]` log names the
26
+ reason (`auth/id-token-expired` = token). `gcli project:list` refreshes
27
+ the stored token; a proxy older than this fix needs a reconnect (`/mcp`).
28
+ - Tools missing from the list: the proxy forwards whatever the deployed
29
+ `mcp` lambda serves - compare with
30
+ `graphql-server-functions/packages/mcp/lambforge.yaml` (plan 16 D3).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gapi/gcli",
3
- "version": "1.8.252",
3
+ "version": "1.8.254",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Stradivario/gapi.git"
package/release/index.js CHANGED
@@ -29867,7 +29867,7 @@ var require_buffer_list = __commonJS({
29867
29867
  }
29868
29868
  }, {
29869
29869
  key: "join",
29870
- value: function join6(s2) {
29870
+ value: function join7(s2) {
29871
29871
  if (this.length === 0) return "";
29872
29872
  var p = this.head;
29873
29873
  var ret = "" + p.data;
@@ -32885,7 +32885,7 @@ var require_buffer_list2 = __commonJS({
32885
32885
  }
32886
32886
  }, {
32887
32887
  key: "join",
32888
- value: function join6(s2) {
32888
+ value: function join7(s2) {
32889
32889
  if (this.length === 0) return "";
32890
32890
  var p = this.head;
32891
32891
  var ret = "" + p.data;
@@ -38710,7 +38710,7 @@ var require_util = __commonJS({
38710
38710
  return path2;
38711
38711
  }
38712
38712
  exports2.normalize = normalize2;
38713
- function join6(aRoot, aPath) {
38713
+ function join7(aRoot, aPath) {
38714
38714
  if (aRoot === "") {
38715
38715
  aRoot = ".";
38716
38716
  }
@@ -38742,7 +38742,7 @@ var require_util = __commonJS({
38742
38742
  }
38743
38743
  return joined;
38744
38744
  }
38745
- exports2.join = join6;
38745
+ exports2.join = join7;
38746
38746
  exports2.isAbsolute = function(aPath) {
38747
38747
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
38748
38748
  };
@@ -38915,7 +38915,7 @@ var require_util = __commonJS({
38915
38915
  parsed.path = parsed.path.substring(0, index + 1);
38916
38916
  }
38917
38917
  }
38918
- sourceURL = join6(urlGenerate(parsed), sourceURL);
38918
+ sourceURL = join7(urlGenerate(parsed), sourceURL);
38919
38919
  }
38920
38920
  return normalize2(sourceURL);
38921
38921
  }
@@ -76037,7 +76037,7 @@ ${lanes.join("\n")}
76037
76037
  var parseDiagnostics;
76038
76038
  var jsDocDiagnostics;
76039
76039
  var syntaxCursor;
76040
- var currentToken;
76040
+ var currentToken2;
76041
76041
  var nodeCount;
76042
76042
  var identifiers;
76043
76043
  var identifierCount;
@@ -76584,60 +76584,60 @@ ${lanes.join("\n")}
76584
76584
  return scanner2.hasPrecedingJSDocComment();
76585
76585
  }
76586
76586
  function token() {
76587
- return currentToken;
76587
+ return currentToken2;
76588
76588
  }
76589
76589
  function nextTokenWithoutCheck() {
76590
- return currentToken = scanner2.scan();
76590
+ return currentToken2 = scanner2.scan();
76591
76591
  }
76592
76592
  function nextTokenAnd(func) {
76593
76593
  nextToken();
76594
76594
  return func();
76595
76595
  }
76596
76596
  function nextToken() {
76597
- if (isKeyword(currentToken) && (scanner2.hasUnicodeEscape() || scanner2.hasExtendedUnicodeEscape())) {
76597
+ if (isKeyword(currentToken2) && (scanner2.hasUnicodeEscape() || scanner2.hasExtendedUnicodeEscape())) {
76598
76598
  parseErrorAt(scanner2.getTokenStart(), scanner2.getTokenEnd(), Diagnostics.Keywords_cannot_contain_escape_characters);
76599
76599
  }
76600
76600
  return nextTokenWithoutCheck();
76601
76601
  }
76602
76602
  function nextTokenJSDoc() {
76603
- return currentToken = scanner2.scanJsDocToken();
76603
+ return currentToken2 = scanner2.scanJsDocToken();
76604
76604
  }
76605
76605
  function nextJSDocCommentTextToken(inBackticks) {
76606
- return currentToken = scanner2.scanJSDocCommentTextToken(inBackticks);
76606
+ return currentToken2 = scanner2.scanJSDocCommentTextToken(inBackticks);
76607
76607
  }
76608
76608
  function reScanGreaterToken() {
76609
- return currentToken = scanner2.reScanGreaterToken();
76609
+ return currentToken2 = scanner2.reScanGreaterToken();
76610
76610
  }
76611
76611
  function reScanSlashToken() {
76612
- return currentToken = scanner2.reScanSlashToken();
76612
+ return currentToken2 = scanner2.reScanSlashToken();
76613
76613
  }
76614
76614
  function reScanTemplateToken(isTaggedTemplate) {
76615
- return currentToken = scanner2.reScanTemplateToken(isTaggedTemplate);
76615
+ return currentToken2 = scanner2.reScanTemplateToken(isTaggedTemplate);
76616
76616
  }
76617
76617
  function reScanLessThanToken() {
76618
- return currentToken = scanner2.reScanLessThanToken();
76618
+ return currentToken2 = scanner2.reScanLessThanToken();
76619
76619
  }
76620
76620
  function reScanHashToken() {
76621
- return currentToken = scanner2.reScanHashToken();
76621
+ return currentToken2 = scanner2.reScanHashToken();
76622
76622
  }
76623
76623
  function scanJsxIdentifier() {
76624
- return currentToken = scanner2.scanJsxIdentifier();
76624
+ return currentToken2 = scanner2.scanJsxIdentifier();
76625
76625
  }
76626
76626
  function scanJsxText() {
76627
- return currentToken = scanner2.scanJsxToken();
76627
+ return currentToken2 = scanner2.scanJsxToken();
76628
76628
  }
76629
76629
  function scanJsxAttributeValue() {
76630
- return currentToken = scanner2.scanJsxAttributeValue();
76630
+ return currentToken2 = scanner2.scanJsxAttributeValue();
76631
76631
  }
76632
76632
  function speculationHelper(callback, speculationKind) {
76633
- const saveToken = currentToken;
76633
+ const saveToken = currentToken2;
76634
76634
  const saveParseDiagnosticsLength = parseDiagnostics.length;
76635
76635
  const saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
76636
76636
  const saveContextFlags = contextFlags;
76637
76637
  const result = speculationKind !== 0 ? scanner2.lookAhead(callback) : scanner2.tryScan(callback);
76638
76638
  Debug.assert(saveContextFlags === contextFlags);
76639
76639
  if (!result || speculationKind !== 0) {
76640
- currentToken = saveToken;
76640
+ currentToken2 = saveToken;
76641
76641
  if (speculationKind !== 2) {
76642
76642
  parseDiagnostics.length = saveParseDiagnosticsLength;
76643
76643
  }
@@ -78634,8 +78634,8 @@ ${lanes.join("\n")}
78634
78634
  19
78635
78635
  /* OpenBraceToken */
78636
78636
  );
78637
- const currentToken2 = token();
78638
- if (currentToken2 === 118 || currentToken2 === 132) {
78637
+ const currentToken22 = token();
78638
+ if (currentToken22 === 118 || currentToken22 === 132) {
78639
78639
  nextToken();
78640
78640
  } else {
78641
78641
  parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(
@@ -78648,7 +78648,7 @@ ${lanes.join("\n")}
78648
78648
  /* ColonToken */
78649
78649
  );
78650
78650
  attributes = parseImportAttributes(
78651
- currentToken2,
78651
+ currentToken22,
78652
78652
  /*skipKeyword*/
78653
78653
  true
78654
78654
  );
@@ -79838,10 +79838,10 @@ ${lanes.join("\n")}
79838
79838
  const pos = getNodePos();
79839
79839
  const node = factory2.createJsxText(
79840
79840
  scanner2.getTokenValue(),
79841
- currentToken === 13
79841
+ currentToken2 === 13
79842
79842
  /* JsxTextAllWhiteSpaces */
79843
79843
  );
79844
- currentToken = scanner2.scanJsxToken();
79844
+ currentToken2 = scanner2.scanJsxToken();
79845
79845
  return finishNode(node, pos);
79846
79846
  }
79847
79847
  function parseJsxChild(openingTag, token2) {
@@ -79884,7 +79884,7 @@ ${lanes.join("\n")}
79884
79884
  const saveParsingContext = parsingContext;
79885
79885
  parsingContext |= 1 << 14;
79886
79886
  while (true) {
79887
- const child = parseJsxChild(openingTag, currentToken = scanner2.reScanJsxToken());
79887
+ const child = parseJsxChild(openingTag, currentToken2 = scanner2.reScanJsxToken());
79888
79888
  if (!child) break;
79889
79889
  list.push(child);
79890
79890
  if (isJsxOpeningElement(openingTag) && (child == null ? void 0 : child.kind) === 285 && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) {
@@ -81114,11 +81114,11 @@ ${lanes.join("\n")}
81114
81114
  nextToken();
81115
81115
  return token() === 166 || token() === 11 || token() === 42 || token() === 19 || tokenIsIdentifierOrKeyword(token());
81116
81116
  case 95:
81117
- let currentToken2 = nextToken();
81118
- if (currentToken2 === 156) {
81119
- currentToken2 = lookAhead(nextToken);
81117
+ let currentToken22 = nextToken();
81118
+ if (currentToken22 === 156) {
81119
+ currentToken22 = lookAhead(nextToken);
81120
81120
  }
81121
- if (currentToken2 === 64 || currentToken2 === 42 || currentToken2 === 19 || currentToken2 === 90 || currentToken2 === 130 || currentToken2 === 60) {
81121
+ if (currentToken22 === 64 || currentToken22 === 42 || currentToken22 === 19 || currentToken22 === 90 || currentToken22 === 130 || currentToken22 === 60) {
81122
81122
  return true;
81123
81123
  }
81124
81124
  continue;
@@ -82319,9 +82319,9 @@ ${lanes.join("\n")}
82319
82319
  return importClause;
82320
82320
  }
82321
82321
  function tryParseImportAttributes() {
82322
- const currentToken2 = token();
82323
- if ((currentToken2 === 118 || currentToken2 === 132) && !scanner2.hasPrecedingLineBreak()) {
82324
- return parseImportAttributes(currentToken2);
82322
+ const currentToken22 = token();
82323
+ if ((currentToken22 === 118 || currentToken22 === 132) && !scanner2.hasPrecedingLineBreak()) {
82324
+ return parseImportAttributes(currentToken22);
82325
82325
  }
82326
82326
  }
82327
82327
  function parseImportAttribute() {
@@ -82615,9 +82615,9 @@ ${lanes.join("\n")}
82615
82615
  moduleSpecifier = parseModuleSpecifier();
82616
82616
  }
82617
82617
  }
82618
- const currentToken2 = token();
82619
- if (moduleSpecifier && (currentToken2 === 118 || currentToken2 === 132) && !scanner2.hasPrecedingLineBreak()) {
82620
- attributes = parseImportAttributes(currentToken2);
82618
+ const currentToken22 = token();
82619
+ if (moduleSpecifier && (currentToken22 === 118 || currentToken22 === 132) && !scanner2.hasPrecedingLineBreak()) {
82620
+ attributes = parseImportAttributes(currentToken22);
82621
82621
  }
82622
82622
  parseSemicolon();
82623
82623
  setAwaitContext(savedAwaitContext);
@@ -82701,7 +82701,7 @@ ${lanes.join("\n")}
82701
82701
  /* ParseAll */
82702
82702
  );
82703
82703
  scanner2.setText(content, start3, length2);
82704
- currentToken = scanner2.scan();
82704
+ currentToken2 = scanner2.scan();
82705
82705
  const jsDocTypeExpression = parseJSDocTypeExpression();
82706
82706
  const sourceFile = createSourceFile2(
82707
82707
  "file.js",
@@ -82789,7 +82789,7 @@ ${lanes.join("\n")}
82789
82789
  }
82790
82790
  JSDocParser2.parseIsolatedJSDocComment = parseIsolatedJSDocComment2;
82791
82791
  function parseJSDocComment(parent2, start3, length2) {
82792
- const saveToken = currentToken;
82792
+ const saveToken = currentToken2;
82793
82793
  const saveParseDiagnosticsLength = parseDiagnostics.length;
82794
82794
  const saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
82795
82795
  const comment = doInsideOfContext(16777216, () => parseJSDocCommentWorker(start3, length2));
@@ -82800,7 +82800,7 @@ ${lanes.join("\n")}
82800
82800
  }
82801
82801
  addRange(jsDocDiagnostics, parseDiagnostics, saveParseDiagnosticsLength);
82802
82802
  }
82803
- currentToken = saveToken;
82803
+ currentToken2 = saveToken;
82804
82804
  parseDiagnostics.length = saveParseDiagnosticsLength;
82805
82805
  parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
82806
82806
  return comment;
@@ -195179,18 +195179,18 @@ ${lanes.join("\n")}
195179
195179
  const importedFiles = [];
195180
195180
  let ambientExternalModules;
195181
195181
  let lastToken;
195182
- let currentToken;
195182
+ let currentToken2;
195183
195183
  let braceNesting = 0;
195184
195184
  let externalModule = false;
195185
195185
  function nextToken() {
195186
- lastToken = currentToken;
195187
- currentToken = scanner.scan();
195188
- if (currentToken === 19) {
195186
+ lastToken = currentToken2;
195187
+ currentToken2 = scanner.scan();
195188
+ if (currentToken2 === 19) {
195189
195189
  braceNesting++;
195190
- } else if (currentToken === 20) {
195190
+ } else if (currentToken2 === 20) {
195191
195191
  braceNesting--;
195192
195192
  }
195193
- return currentToken;
195193
+ return currentToken2;
195194
195194
  }
195195
195195
  function getFileReference() {
195196
195196
  const fileName = scanner.getTokenValue();
@@ -218276,11 +218276,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
218276
218276
  };
218277
218277
  }
218278
218278
  function getJSDocParameterCompletions(sourceFile, position, checker, options, preferences, tagNameOnly) {
218279
- const currentToken = getTokenAtPosition(sourceFile, position);
218280
- if (!isJSDocTag(currentToken) && !isJSDoc(currentToken)) {
218279
+ const currentToken2 = getTokenAtPosition(sourceFile, position);
218280
+ if (!isJSDocTag(currentToken2) && !isJSDoc(currentToken2)) {
218281
218281
  return [];
218282
218282
  }
218283
- const jsDoc = isJSDoc(currentToken) ? currentToken : currentToken.parent;
218283
+ const jsDoc = isJSDoc(currentToken2) ? currentToken2 : currentToken2.parent;
218284
218284
  if (!isJSDoc(jsDoc)) {
218285
218285
  return [];
218286
218286
  }
@@ -220132,10 +220132,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
220132
220132
  const typeChecker = program2.getTypeChecker();
220133
220133
  const inCheckedFile = isCheckedFile(sourceFile, compilerOptions);
220134
220134
  let start3 = timestamp();
220135
- let currentToken = getTokenAtPosition(sourceFile, position);
220135
+ let currentToken2 = getTokenAtPosition(sourceFile, position);
220136
220136
  log("getCompletionData: Get current token: " + (timestamp() - start3));
220137
220137
  start3 = timestamp();
220138
- const insideComment = isInComment(sourceFile, position, currentToken);
220138
+ const insideComment = isInComment(sourceFile, position, currentToken2);
220139
220139
  log("getCompletionData: Is inside comment: " + (timestamp() - start3));
220140
220140
  let insideJsDocTagTypeExpression = false;
220141
220141
  let insideJsDocImportTag = false;
@@ -220157,7 +220157,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
220157
220157
  }
220158
220158
  }
220159
220159
  }
220160
- const tag = getJsDocTagAtPosition(currentToken, position);
220160
+ const tag = getJsDocTagAtPosition(currentToken2, position);
220161
220161
  if (tag) {
220162
220162
  if (tag.tagName.pos <= position && position <= tag.tagName.end) {
220163
220163
  return {
@@ -220170,8 +220170,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
220170
220170
  } else {
220171
220171
  const typeExpression = tryGetTypeExpressionFromTag(tag);
220172
220172
  if (typeExpression) {
220173
- currentToken = getTokenAtPosition(sourceFile, position);
220174
- if (!currentToken || !isDeclarationName(currentToken) && (currentToken.parent.kind !== 349 || currentToken.parent.name !== currentToken)) {
220173
+ currentToken2 = getTokenAtPosition(sourceFile, position);
220174
+ if (!currentToken2 || !isDeclarationName(currentToken2) && (currentToken2.parent.kind !== 349 || currentToken2.parent.name !== currentToken2)) {
220175
220175
  insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression);
220176
220176
  }
220177
220177
  }
@@ -220191,7 +220191,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
220191
220191
  const previousToken = tokens.previousToken;
220192
220192
  let contextToken = tokens.contextToken;
220193
220193
  log("getCompletionData: Get previous token: " + (timestamp() - start3));
220194
- let node = currentToken;
220194
+ let node = currentToken2;
220195
220195
  let propertyAccessToConvert;
220196
220196
  let isRightOfDot = false;
220197
220197
  let isRightOfQuestionDot = false;
@@ -220263,16 +220263,16 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
220263
220263
  contextToken = parent2;
220264
220264
  parent2 = parent2.parent;
220265
220265
  }
220266
- if (currentToken.parent === location) {
220267
- switch (currentToken.kind) {
220266
+ if (currentToken2.parent === location) {
220267
+ switch (currentToken2.kind) {
220268
220268
  case 32:
220269
- if (currentToken.parent.kind === 285 || currentToken.parent.kind === 287) {
220270
- location = currentToken;
220269
+ if (currentToken2.parent.kind === 285 || currentToken2.parent.kind === 287) {
220270
+ location = currentToken2;
220271
220271
  }
220272
220272
  break;
220273
220273
  case 44:
220274
- if (currentToken.parent.kind === 286) {
220275
- location = currentToken;
220274
+ if (currentToken2.parent.kind === 286) {
220275
+ location = currentToken2;
220276
220276
  }
220277
220277
  break;
220278
220278
  }
@@ -232469,30 +232469,30 @@ ${options.prefix}` : "\n" : options.prefix
232469
232469
  scanner2.resetTokenState(savedPos);
232470
232470
  scanner2.scan();
232471
232471
  }
232472
- let currentToken = getNextToken(n, expectedScanAction);
232472
+ let currentToken2 = getNextToken(n, expectedScanAction);
232473
232473
  const token = createTextRangeWithKind(
232474
232474
  scanner2.getTokenFullStart(),
232475
232475
  scanner2.getTokenEnd(),
232476
- currentToken
232476
+ currentToken2
232477
232477
  );
232478
232478
  if (trailingTrivia) {
232479
232479
  trailingTrivia = void 0;
232480
232480
  }
232481
232481
  while (scanner2.getTokenFullStart() < endPos) {
232482
- currentToken = scanner2.scan();
232483
- if (!isTrivia(currentToken)) {
232482
+ currentToken2 = scanner2.scan();
232483
+ if (!isTrivia(currentToken2)) {
232484
232484
  break;
232485
232485
  }
232486
232486
  const trivia = createTextRangeWithKind(
232487
232487
  scanner2.getTokenFullStart(),
232488
232488
  scanner2.getTokenEnd(),
232489
- currentToken
232489
+ currentToken2
232490
232490
  );
232491
232491
  if (!trailingTrivia) {
232492
232492
  trailingTrivia = [];
232493
232493
  }
232494
232494
  trailingTrivia.push(trivia);
232495
- if (currentToken === 4) {
232495
+ if (currentToken2 === 4) {
232496
232496
  scanner2.scan();
232497
232497
  break;
232498
232498
  }
@@ -235660,8 +235660,8 @@ ${options.prefix}` : "\n" : options.prefix
235660
235660
  return 0;
235661
235661
  }
235662
235662
  const lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
235663
- const currentToken = getTokenAtPosition(sourceFile, position);
235664
- const isObjectLiteral = currentToken.kind === 19 && currentToken.parent.kind === 211;
235663
+ const currentToken2 = getTokenAtPosition(sourceFile, position);
235664
+ const isObjectLiteral = currentToken2.kind === 19 && currentToken2.parent.kind === 211;
235665
235665
  if (options.indentStyle === 1 || isObjectLiteral) {
235666
235666
  return getBlockIndent(sourceFile, position, options);
235667
235667
  }
@@ -235677,7 +235677,7 @@ ${options.prefix}` : "\n" : options.prefix
235677
235677
  219,
235678
235678
  220
235679
235679
  /* ArrowFunction */
235680
- ].includes(currentToken.parent.kind);
235680
+ ].includes(currentToken2.parent.kind);
235681
235681
  const indentSize = useTheSameBaseIndentation ? 0 : options.indentSize;
235682
235682
  return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize;
235683
235683
  }
@@ -254783,11 +254783,13 @@ var build_exports = {};
254783
254783
  __export(build_exports, {
254784
254784
  default: () => build_default
254785
254785
  });
254786
- var import_esbuild_decorators, import_esbuild, import_rxjs6, import_operators5, build_default;
254786
+ var import_esbuild_decorators, import_esbuild, import_fs3, import_path, import_rxjs6, import_operators5, build_default;
254787
254787
  var init_build = __esm({
254788
254788
  "src/commands/build/build.ts"() {
254789
254789
  import_esbuild_decorators = __toESM(require_src());
254790
254790
  import_esbuild = __toESM(require("esbuild"));
254791
+ import_fs3 = require("fs");
254792
+ import_path = require("path");
254791
254793
  import_rxjs6 = __toESM(require_cjs());
254792
254794
  import_operators5 = __toESM(require_operators());
254793
254795
  init_log();
@@ -254818,12 +254820,15 @@ var init_build = __esm({
254818
254820
  (0, import_operators5.switchMap)(
254819
254821
  ({ esbuild: esbuild2, options }) => esbuild2.build({
254820
254822
  ...options,
254821
- plugins: [
254823
+ // Decorator metadata needs the project's tsconfig; without one
254824
+ // the plugin failed with "[plugin: tsc] failed to open
254825
+ // 'undefined'" - plain esbuild handles a project without it.
254826
+ plugins: (0, import_fs3.existsSync)((0, import_path.join)(process.cwd(), "tsconfig.json")) ? [
254822
254827
  (0, import_esbuild_decorators.esbuildDecorators)({
254823
254828
  tsconfig: "./tsconfig.json",
254824
254829
  cwd: process.cwd()
254825
254830
  })
254826
- ]
254831
+ ] : []
254827
254832
  })
254828
254833
  ),
254829
254834
  (0, import_operators5.tap)((data) => {
@@ -255726,12 +255731,12 @@ async function ensureTalosctl(version2) {
255726
255731
  return "talosctl";
255727
255732
  }
255728
255733
  const asset = talosctlAssetName();
255729
- const dir = (0, import_path.join)(mainDirectory, "bin");
255730
- const binary = (0, import_path.join)(
255734
+ const dir = (0, import_path2.join)(mainDirectory, "bin");
255735
+ const binary = (0, import_path2.join)(
255731
255736
  dir,
255732
255737
  `talosctl-${version2}${asset.endsWith(".exe") ? ".exe" : ""}`
255733
255738
  );
255734
- if ((0, import_fs3.existsSync)(binary)) {
255739
+ if ((0, import_fs4.existsSync)(binary)) {
255735
255740
  return binary;
255736
255741
  }
255737
255742
  Logger.info(
@@ -255757,14 +255762,14 @@ async function ensureTalosctl(version2) {
255757
255762
  Logger.info(`talosctl ${version2} saved to ${binary}`);
255758
255763
  return binary;
255759
255764
  }
255760
- var import_child_process, import_crypto, import_fs3, import_promises, import_path, RELEASES, VERSION_RE, clientVersionOf, runBinary;
255765
+ var import_child_process, import_crypto, import_fs4, import_promises, import_path2, RELEASES, VERSION_RE, clientVersionOf, runBinary;
255761
255766
  var init_talosctl = __esm({
255762
255767
  "src/commands/cluster/helpers/talosctl.ts"() {
255763
255768
  import_child_process = require("child_process");
255764
255769
  import_crypto = require("crypto");
255765
- import_fs3 = require("fs");
255770
+ import_fs4 = require("fs");
255766
255771
  import_promises = require("fs/promises");
255767
- import_path = require("path");
255772
+ import_path2 = require("path");
255768
255773
  init_log();
255769
255774
  init_types();
255770
255775
  RELEASES = "https://github.com/siderolabs/talos/releases/download";
@@ -255790,12 +255795,12 @@ var attach_exports = {};
255790
255795
  __export(attach_exports, {
255791
255796
  default: () => attach_default
255792
255797
  });
255793
- var import_promises2, import_os2, import_path2, import_readline, import_rxjs17, sleep, ask, attach_default;
255798
+ var import_promises2, import_os2, import_path3, import_readline, import_rxjs17, sleep, ask, attach_default;
255794
255799
  var init_attach2 = __esm({
255795
255800
  "src/commands/cluster/attach.ts"() {
255796
255801
  import_promises2 = require("fs/promises");
255797
255802
  import_os2 = require("os");
255798
- import_path2 = require("path");
255803
+ import_path3 = require("path");
255799
255804
  import_readline = require("readline");
255800
255805
  import_rxjs17 = __toESM(require_cjs());
255801
255806
  init_gql_client();
@@ -255889,8 +255894,8 @@ var init_attach2 = __esm({
255889
255894
  `The cluster runs Talos ${join_.talosVersion}, the machine booted ${version2}. It installs ${join_.talosVersion} anyway; if the join fails, boot ${join_.isoUrl}.`
255890
255895
  );
255891
255896
  }
255892
- const dir = await (0, import_promises2.mkdtemp)((0, import_path2.join)((0, import_os2.tmpdir)(), "gcli-attach-"));
255893
- const file2 = (0, import_path2.join)(dir, "machine.yaml");
255897
+ const dir = await (0, import_promises2.mkdtemp)((0, import_path3.join)((0, import_os2.tmpdir)(), "gcli-attach-"));
255898
+ const file2 = (0, import_path3.join)(dir, "machine.yaml");
255894
255899
  try {
255895
255900
  await (0, import_promises2.writeFile)(file2, join_.config, { mode: 384 });
255896
255901
  const applied = await talosctl(
@@ -256002,12 +256007,12 @@ __export(reset_machine_exports, {
256002
256007
  default: () => reset_machine_default,
256003
256008
  hostnameOf: () => hostnameOf
256004
256009
  });
256005
- var import_promises3, import_os3, import_path3, import_readline2, import_rxjs20, hostnameOf, reset_machine_default;
256010
+ var import_promises3, import_os3, import_path4, import_readline2, import_rxjs20, hostnameOf, reset_machine_default;
256006
256011
  var init_reset_machine = __esm({
256007
256012
  "src/commands/cluster/reset-machine.ts"() {
256008
256013
  import_promises3 = require("fs/promises");
256009
256014
  import_os3 = require("os");
256010
- import_path3 = require("path");
256015
+ import_path4 = require("path");
256011
256016
  import_readline2 = require("readline");
256012
256017
  import_rxjs20 = __toESM(require_cjs());
256013
256018
  init_gql_client();
@@ -256045,8 +256050,8 @@ var init_reset_machine = __esm({
256045
256050
  GraphqlClienAPI.clusterTalosconfig(clusterId, 15)
256046
256051
  );
256047
256052
  const binary = access.talosVersion ? await ensureTalosctl(access.talosVersion) : "talosctl";
256048
- const dir = await (0, import_promises3.mkdtemp)((0, import_path3.join)((0, import_os3.tmpdir)(), "gcli-reset-"));
256049
- const config2 = (0, import_path3.join)(dir, "talosconfig");
256053
+ const dir = await (0, import_promises3.mkdtemp)((0, import_path4.join)((0, import_os3.tmpdir)(), "gcli-reset-"));
256054
+ const config2 = (0, import_path4.join)(dir, "talosconfig");
256050
256055
  try {
256051
256056
  await (0, import_promises3.writeFile)(config2, access.talosconfig, { mode: 384 });
256052
256057
  const talos = (args, timeoutMs = 3e4) => runBinary(
@@ -256588,6 +256593,45 @@ var init_list_environments = __esm({
256588
256593
  }
256589
256594
  });
256590
256595
 
256596
+ // src/commands/environment/environment-payload.ts
256597
+ var NUMERIC_FIELDS, CLI_ONLY, environmentPayload;
256598
+ var init_environment_payload = __esm({
256599
+ "src/commands/environment/environment-payload.ts"() {
256600
+ NUMERIC_FIELDS = [
256601
+ "minCpu",
256602
+ "maxCpu",
256603
+ "minMemory",
256604
+ "maxMemory",
256605
+ "poolSize",
256606
+ "maxPods",
256607
+ "builderPoolSize",
256608
+ "builderMaxParallelBuilds",
256609
+ "builderIdleTimeout",
256610
+ "terminationGracePeriod"
256611
+ ];
256612
+ CLI_ONLY = ["spec", "project", "clusterName"];
256613
+ environmentPayload = (spec, flags) => {
256614
+ const merged = { ...spec };
256615
+ for (const [key, value] of Object.entries(flags)) {
256616
+ if (value !== void 0) merged[key] = value;
256617
+ }
256618
+ for (const key of CLI_ONLY) delete merged[key];
256619
+ for (const key of NUMERIC_FIELDS) {
256620
+ const value = merged[key];
256621
+ if (value === void 0 || value === null || typeof value === "number") {
256622
+ continue;
256623
+ }
256624
+ const n = Number(value);
256625
+ if (!Number.isInteger(n)) {
256626
+ throw new Error(`--${key} must be a whole number, got "${value}"`);
256627
+ }
256628
+ merged[key] = n;
256629
+ }
256630
+ return merged;
256631
+ };
256632
+ }
256633
+ });
256634
+
256591
256635
  // src/commands/environment/create-environment.ts
256592
256636
  var create_environment_exports = {};
256593
256637
  __export(create_environment_exports, {
@@ -256602,6 +256646,7 @@ var init_create_environment = __esm({
256602
256646
  init_gql_client();
256603
256647
  init_log();
256604
256648
  init_load_spec();
256649
+ init_environment_payload();
256605
256650
  create_environment_default = (cmd) => {
256606
256651
  const { clusterName: cmdClusterName, ...cmdRest } = cmd;
256607
256652
  return (0, import_rxjs28.lastValueFrom)(
@@ -256621,8 +256666,7 @@ var init_create_environment = __esm({
256621
256666
  }).pipe(
256622
256667
  (0, import_operators13.switchMap)(
256623
256668
  (clusterId) => GraphqlClienAPI.createEnvironment(projectId, {
256624
- ...data,
256625
- ...cmdRest,
256669
+ ...environmentPayload(data, cmdRest),
256626
256670
  clusterId
256627
256671
  })
256628
256672
  )
@@ -256668,6 +256712,7 @@ var init_update_environment = __esm({
256668
256712
  init_gql_client();
256669
256713
  init_log();
256670
256714
  init_load_spec();
256715
+ init_environment_payload();
256671
256716
  update_environment_default = (cmd) => {
256672
256717
  const { clusterName: cmdClusterName, ...cmdRest } = cmd;
256673
256718
  return (0, import_rxjs29.lastValueFrom)(
@@ -256688,8 +256733,7 @@ var init_update_environment = __esm({
256688
256733
  }).pipe(
256689
256734
  (0, import_operators14.switchMap)(
256690
256735
  (clusterId) => GraphqlClienAPI.updateEnvironment(projectId, {
256691
- ...data,
256692
- ...cmdRest,
256736
+ ...environmentPayload(data, cmdRest),
256693
256737
  clusterId
256694
256738
  })
256695
256739
  )
@@ -270956,7 +271000,7 @@ var require_BufferList2 = __commonJS({
270956
271000
  this.head = this.tail = null;
270957
271001
  this.length = 0;
270958
271002
  };
270959
- BufferList.prototype.join = function join6(s2) {
271003
+ BufferList.prototype.join = function join7(s2) {
270960
271004
  if (this.length === 0) return "";
270961
271005
  var p = this.head;
270962
271006
  var ret = "" + p.data;
@@ -275756,7 +275800,7 @@ var require_buffer_list3 = __commonJS({
275756
275800
  }
275757
275801
  }, {
275758
275802
  key: "join",
275759
- value: function join6(s2) {
275803
+ value: function join7(s2) {
275760
275804
  if (this.length === 0) return "";
275761
275805
  var p = this.head;
275762
275806
  var ret = "" + p.data;
@@ -279098,7 +279142,7 @@ var require_buffer_list4 = __commonJS({
279098
279142
  }
279099
279143
  }, {
279100
279144
  key: "join",
279101
- value: function join6(s2) {
279145
+ value: function join7(s2) {
279102
279146
  if (this.length === 0) return "";
279103
279147
  var p = this.head;
279104
279148
  var ret = "" + p.data;
@@ -281870,7 +281914,7 @@ var require_buffer_list5 = __commonJS({
281870
281914
  }
281871
281915
  }, {
281872
281916
  key: "join",
281873
- value: function join6(s2) {
281917
+ value: function join7(s2) {
281874
281918
  if (this.length === 0) return "";
281875
281919
  var p = this.head;
281876
281920
  var ret = "" + p.data;
@@ -285107,7 +285151,7 @@ var require_buffer_list6 = __commonJS({
285107
285151
  }
285108
285152
  }, {
285109
285153
  key: "join",
285110
- value: function join6(s2) {
285154
+ value: function join7(s2) {
285111
285155
  if (this.length === 0) return "";
285112
285156
  var p = this.head;
285113
285157
  var ret = "" + p.data;
@@ -288055,12 +288099,12 @@ var package_exports = {};
288055
288099
  __export(package_exports, {
288056
288100
  default: () => package_default
288057
288101
  });
288058
- var import_archiver, import_child_process2, import_fs4, import_rxjs32, import_operators17, import_util3, ReadFile, package_default;
288102
+ var import_archiver, import_child_process2, import_fs5, import_rxjs32, import_operators17, import_util3, ReadFile, package_default;
288059
288103
  var init_package = __esm({
288060
288104
  "src/commands/lambda/package.ts"() {
288061
288105
  import_archiver = __toESM(require_archiver());
288062
288106
  import_child_process2 = require("child_process");
288063
- import_fs4 = require("fs");
288107
+ import_fs5 = require("fs");
288064
288108
  import_rxjs32 = __toESM(require_cjs());
288065
288109
  import_operators17 = __toESM(require_operators());
288066
288110
  import_util3 = require("util");
@@ -288091,10 +288135,10 @@ var init_package = __esm({
288091
288135
  return (0, import_rxjs32.lastValueFrom)(
288092
288136
  (0, import_rxjs32.from)(streamToBufferPromise(archive)).pipe(
288093
288137
  (0, import_operators17.switchMap)(
288094
- (buffer) => (0, import_rxjs32.from)((0, import_util3.promisify)(import_fs4.mkdir)(".gcache")).pipe(
288138
+ (buffer) => (0, import_rxjs32.from)((0, import_util3.promisify)(import_fs5.mkdir)(".gcache")).pipe(
288095
288139
  (0, import_operators17.catchError)(() => (0, import_rxjs32.of)(true)),
288096
288140
  (0, import_operators17.switchMap)(
288097
- () => (0, import_util3.promisify)(import_fs4.writeFile)(`.gcache/${data.name}.zip`, buffer)
288141
+ () => (0, import_util3.promisify)(import_fs5.writeFile)(`.gcache/${data.name}.zip`, buffer)
288098
288142
  )
288099
288143
  )
288100
288144
  )
@@ -288118,11 +288162,11 @@ function streamToBufferPromise(file2) {
288118
288162
  });
288119
288163
  });
288120
288164
  }
288121
- var import_form_data, import_fs5, import_rxjs33, import_operators18, import_stream_to_buffer, ReadFile2, createOrUpdateLambda, createCommand;
288165
+ var import_form_data, import_fs6, import_rxjs33, import_operators18, import_stream_to_buffer, ReadFile2, createOrUpdateLambda, createCommand;
288122
288166
  var init_helpers2 = __esm({
288123
288167
  "src/commands/lambda/helpers/index.ts"() {
288124
288168
  import_form_data = __toESM(require_form_data());
288125
- import_fs5 = require("fs");
288169
+ import_fs6 = require("fs");
288126
288170
  init_src();
288127
288171
  import_rxjs33 = __toESM(require_cjs());
288128
288172
  import_operators18 = __toESM(require_operators());
@@ -288154,7 +288198,7 @@ var init_helpers2 = __esm({
288154
288198
  }
288155
288199
  await package_default(cmd);
288156
288200
  const body = new import_form_data.default();
288157
- body.append("file[]", (0, import_fs5.createReadStream)(`.gcache/${data.name}.zip`));
288201
+ body.append("file[]", (0, import_fs6.createReadStream)(`.gcache/${data.name}.zip`));
288158
288202
  const config2 = await (0, import_rxjs33.lastValueFrom)(GraphqlClienAPI.getConfig());
288159
288203
  return (0, import_rxjs33.lastValueFrom)(
288160
288204
  (0, import_rxjs33.from)(
@@ -288223,9 +288267,12 @@ var init_helpers2 = __esm({
288223
288267
  minScale: cmd.minScale || payload.scaleOptions?.minScale || 0,
288224
288268
  targetCpu: cmd.targetCpu || payload.scaleOptions?.targetCpu || 0,
288225
288269
  idleTimeout: cmd.idleTimeout || payload.scaleOptions?.idleTimeout || 120,
288226
- concurrency: cmd.concurrency || payload.scaleOptions?.concurrency || 500,
288227
- functionTimeout: cmd.functionTimeout || payload.scaleOptions?.functionTimeout || 60,
288228
- specializationTimeout: cmd.specializationTimeout || payload.scaleOptions?.specializationTimeout || 120
288270
+ // 0 = not set: the server fills these in within the project's
288271
+ // plan (concurrency <= 3, timeouts 60/120 s capped). A fixed
288272
+ // 500 / 60 / 120 here was refused on plans with lower maxima.
288273
+ concurrency: cmd.concurrency || payload.scaleOptions?.concurrency || 0,
288274
+ functionTimeout: cmd.functionTimeout || payload.scaleOptions?.functionTimeout || 0,
288275
+ specializationTimeout: cmd.specializationTimeout || payload.scaleOptions?.specializationTimeout || 0
288229
288276
  }
288230
288277
  })
288231
288278
  );
@@ -288821,10 +288868,10 @@ var use_exports = {};
288821
288868
  __export(use_exports, {
288822
288869
  default: () => use_default
288823
288870
  });
288824
- var import_fs6, import_rxjs45, import_operators30, import_util4, use_default;
288871
+ var import_fs7, import_rxjs45, import_operators30, import_util4, use_default;
288825
288872
  var init_use = __esm({
288826
288873
  "src/commands/project/use.ts"() {
288827
- import_fs6 = require("fs");
288874
+ import_fs7 = require("fs");
288828
288875
  import_rxjs45 = __toESM(require_cjs());
288829
288876
  import_operators30 = __toESM(require_operators());
288830
288877
  import_util4 = require("util");
@@ -288839,7 +288886,7 @@ var init_use = __esm({
288839
288886
  ),
288840
288887
  (0, import_operators30.switchMap)(
288841
288888
  (projectId) => (0, import_rxjs45.from)(
288842
- (0, import_util4.promisify)(import_fs6.writeFile)(projectDirectory, projectId, {
288889
+ (0, import_util4.promisify)(import_fs7.writeFile)(projectDirectory, projectId, {
288843
288890
  encoding: "utf-8"
288844
288891
  })
288845
288892
  )
@@ -288855,13 +288902,13 @@ var clear_exports = {};
288855
288902
  __export(clear_exports, {
288856
288903
  default: () => clear_default
288857
288904
  });
288858
- var import_fs7, import_util5, clear_default;
288905
+ var import_fs8, import_util5, clear_default;
288859
288906
  var init_clear = __esm({
288860
288907
  "src/commands/project/clear.ts"() {
288861
- import_fs7 = require("fs");
288908
+ import_fs8 = require("fs");
288862
288909
  import_util5 = require("util");
288863
288910
  init_types();
288864
- clear_default = async () => (0, import_util5.promisify)(import_fs7.unlink)(projectDirectory);
288911
+ clear_default = async () => (0, import_util5.promisify)(import_fs8.unlink)(projectDirectory);
288865
288912
  }
288866
288913
  });
288867
288914
 
@@ -319672,7 +319719,9 @@ var init_zod = __esm({
319672
319719
  // src/commands/proxy/start.ts
319673
319720
  var start_exports = {};
319674
319721
  __export(start_exports, {
319675
- default: () => startProxy
319722
+ currentToken: () => currentToken,
319723
+ default: () => startProxy,
319724
+ performFetch: () => performFetch
319676
319725
  });
319677
319726
  async function startProxy(cmd) {
319678
319727
  return (0, import_rxjs46.lastValueFrom)(
@@ -319784,7 +319833,7 @@ async function startProxy(cmd) {
319784
319833
  )
319785
319834
  );
319786
319835
  }
319787
- var import_rxjs46, import_operators31, import_stream2, performFetch;
319836
+ var import_rxjs46, import_operators31, import_stream2, pendingToken, currentToken, withToken, performFetch;
319788
319837
  var init_start = __esm({
319789
319838
  "src/commands/proxy/start.ts"() {
319790
319839
  init_client2();
@@ -319796,26 +319845,40 @@ var init_start = __esm({
319796
319845
  import_stream2 = require("stream");
319797
319846
  init_zod();
319798
319847
  init_gql_client();
319848
+ pendingToken = null;
319849
+ currentToken = (force = false) => {
319850
+ if (!pendingToken || force) {
319851
+ pendingToken = (0, import_rxjs46.lastValueFrom)(
319852
+ GraphqlClienAPI.getConfig(force).pipe(
319853
+ (0, import_operators31.take)(1),
319854
+ (0, import_operators31.map)((config2) => config2.token)
319855
+ )
319856
+ ).finally(() => {
319857
+ pendingToken = null;
319858
+ });
319859
+ }
319860
+ return pendingToken;
319861
+ };
319862
+ withToken = (init, token) => {
319863
+ const headers = new Headers(init?.headers);
319864
+ headers.set("Authorization", token);
319865
+ return { ...init, headers };
319866
+ };
319799
319867
  performFetch = (input, init) => {
319800
- return (0, import_rxjs46.from)(fetch(input, init)).pipe(
319868
+ return (0, import_rxjs46.from)(currentToken()).pipe(
319869
+ (0, import_operators31.switchMap)((token) => fetch(input, withToken(init, token))),
319801
319870
  (0, import_operators31.switchMap)((res) => {
319802
319871
  if (res.status === 401 || res.status === 403) {
319803
319872
  process.stderr.write(
319804
319873
  `[DEBUG] Request failed with ${res.status}. Refreshing token...
319805
319874
  `
319806
319875
  );
319807
- return GraphqlClienAPI.getConfig(true).pipe(
319808
- (0, import_operators31.take)(1),
319809
- (0, import_operators31.switchMap)((config2) => {
319876
+ return (0, import_rxjs46.from)(currentToken(true)).pipe(
319877
+ (0, import_operators31.switchMap)((token) => {
319810
319878
  process.stderr.write(
319811
319879
  "[DEBUG] Token refreshed. Retrying request...\n"
319812
319880
  );
319813
- const headers = new Headers(init?.headers);
319814
- headers.set("Authorization", config2.token);
319815
- return fetch(input, {
319816
- ...init,
319817
- headers
319818
- });
319881
+ return fetch(input, withToken(init, token));
319819
319882
  })
319820
319883
  );
319821
319884
  }
@@ -320521,19 +320584,19 @@ var init_connection = __esm({
320521
320584
  });
320522
320585
 
320523
320586
  // src/commands/runner/daemon.ts
320524
- var import_child_process3, import_fs8, import_promises6, import_os4, import_path4, import_util11, DEFAULT_SERVICE_NAME, RUNNER_AUTH_EXIT_CODE, systemdQuote, unitPath, buildUnit, resolveGcliCommand, defaultExec, SystemdUserService, assertSystemdAvailable;
320587
+ var import_child_process3, import_fs9, import_promises6, import_os4, import_path5, import_util11, DEFAULT_SERVICE_NAME, RUNNER_AUTH_EXIT_CODE, systemdQuote, unitPath, buildUnit, resolveGcliCommand, defaultExec, SystemdUserService, assertSystemdAvailable;
320525
320588
  var init_daemon = __esm({
320526
320589
  "src/commands/runner/daemon.ts"() {
320527
320590
  import_child_process3 = require("child_process");
320528
- import_fs8 = require("fs");
320591
+ import_fs9 = require("fs");
320529
320592
  import_promises6 = require("fs/promises");
320530
320593
  import_os4 = require("os");
320531
- import_path4 = require("path");
320594
+ import_path5 = require("path");
320532
320595
  import_util11 = require("util");
320533
320596
  DEFAULT_SERVICE_NAME = "lambforge-runner";
320534
320597
  RUNNER_AUTH_EXIT_CODE = 78;
320535
320598
  systemdQuote = (word) => /^[A-Za-z0-9_@%+=:,./-]+$/.test(word) ? word : `"${word.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
320536
- unitPath = (serviceName, home = (0, import_os4.homedir)()) => (0, import_path4.join)(home, ".config", "systemd", "user", `${serviceName}.service`);
320599
+ unitPath = (serviceName, home = (0, import_os4.homedir)()) => (0, import_path5.join)(home, ".config", "systemd", "user", `${serviceName}.service`);
320537
320600
  buildUnit = ({
320538
320601
  serviceName,
320539
320602
  execStart,
@@ -320572,7 +320635,7 @@ var init_daemon = __esm({
320572
320635
  }
320573
320636
  let script = argv[1];
320574
320637
  try {
320575
- script = (0, import_fs8.realpathSync)(script);
320638
+ script = (0, import_fs9.realpathSync)(script);
320576
320639
  } catch {
320577
320640
  }
320578
320641
  const ephemeral = /[/\\]_npx[/\\]|[/\\]\.npm[/\\]_cacache/.test(script);
@@ -320594,7 +320657,7 @@ var init_daemon = __esm({
320594
320657
  /** install -> daemon-reload -> enable -> restart (picks up a changed unit). */
320595
320658
  async install(unitContent) {
320596
320659
  const path2 = unitPath(this.serviceName, this.home);
320597
- await (0, import_promises6.mkdir)((0, import_path4.join)(path2, ".."), { recursive: true });
320660
+ await (0, import_promises6.mkdir)((0, import_path5.join)(path2, ".."), { recursive: true });
320598
320661
  await (0, import_promises6.writeFile)(path2, unitContent, "utf-8");
320599
320662
  await this.systemctl("daemon-reload");
320600
320663
  await this.systemctl("enable", this.unit);
@@ -320610,7 +320673,7 @@ var init_daemon = __esm({
320610
320673
  }
320611
320674
  /** Whether `runner:daemon:install` wrote the unit. */
320612
320675
  installed() {
320613
- return (0, import_fs8.existsSync)(unitPath(this.serviceName, this.home));
320676
+ return (0, import_fs9.existsSync)(unitPath(this.serviceName, this.home));
320614
320677
  }
320615
320678
  start() {
320616
320679
  return this.systemctl("start", this.unit);
@@ -322396,13 +322459,13 @@ var init_config2 = __esm({
322396
322459
  });
322397
322460
 
322398
322461
  // src/commands/workspace/files.ts
322399
- var import_child_process5, import_crypto2, import_fs9, import_path5, import_util12, run, WorkspaceError, MAX_READ_BYTES, MAX_WRITE_BYTES, DEFAULT_LIST_LIMIT, MAX_LIST_LIMIT, DEFAULT_SEARCH_RESULTS, MAX_SEARCH_RESULTS, MAX_MATCH_TEXT, SKIP_DIRS, SECRET_FILE, SECRET_TEMPLATE, isSecretFile, contentHash, toPosix, WorkspaceFiles;
322462
+ var import_child_process5, import_crypto2, import_fs10, import_path6, import_util12, run, WorkspaceError, MAX_READ_BYTES, MAX_WRITE_BYTES, DEFAULT_LIST_LIMIT, MAX_LIST_LIMIT, DEFAULT_SEARCH_RESULTS, MAX_SEARCH_RESULTS, MAX_MATCH_TEXT, SKIP_DIRS, SECRET_FILE, SECRET_TEMPLATE, isSecretFile, contentHash, toPosix, WorkspaceFiles;
322400
322463
  var init_files = __esm({
322401
322464
  "src/commands/workspace/files.ts"() {
322402
322465
  import_child_process5 = require("child_process");
322403
322466
  import_crypto2 = require("crypto");
322404
- import_fs9 = require("fs");
322405
- import_path5 = require("path");
322467
+ import_fs10 = require("fs");
322468
+ import_path6 = require("path");
322406
322469
  import_util12 = require("util");
322407
322470
  run = (0, import_util12.promisify)(import_child_process5.execFile);
322408
322471
  WorkspaceError = class extends Error {
@@ -322422,11 +322485,11 @@ var init_files = __esm({
322422
322485
  SECRET_FILE = /^(\.env(\..+)?|.*\.(pem|key|p12|pfx|keystore|jks)|id_(rsa|dsa|ecdsa|ed25519)(\.pub)?|\.npmrc|\.pypirc|\.netrc|credentials(\.json)?)$/i;
322423
322486
  SECRET_TEMPLATE = /\.(example|sample|template|dist|defaults)$/i;
322424
322487
  isSecretFile = (path2) => {
322425
- const name2 = (0, import_path5.basename)(path2);
322488
+ const name2 = (0, import_path6.basename)(path2);
322426
322489
  return SECRET_FILE.test(name2) && !SECRET_TEMPLATE.test(name2);
322427
322490
  };
322428
322491
  contentHash = (content) => (0, import_crypto2.createHash)("sha256").update(content).digest("hex").slice(0, 16);
322429
- toPosix = (p) => p.split(import_path5.sep).join("/");
322492
+ toPosix = (p) => p.split(import_path6.sep).join("/");
322430
322493
  WorkspaceFiles = class {
322431
322494
  constructor(root, options = {}) {
322432
322495
  this.root = root;
@@ -322435,9 +322498,9 @@ var init_files = __esm({
322435
322498
  /** Absolute path for a workspace-relative one, or a WorkspaceError. */
322436
322499
  async resolvePath(input, { forWrite = false } = {}) {
322437
322500
  const rel = (input ?? ".").trim() || ".";
322438
- const abs = (0, import_path5.resolve)(this.root, rel);
322439
- const fromRoot = (0, import_path5.relative)(this.root, abs);
322440
- if (fromRoot.startsWith("..") || (0, import_path5.isAbsolute)(fromRoot)) {
322501
+ const abs = (0, import_path6.resolve)(this.root, rel);
322502
+ const fromRoot = (0, import_path6.relative)(this.root, abs);
322503
+ if (fromRoot.startsWith("..") || (0, import_path6.isAbsolute)(fromRoot)) {
322441
322504
  throw new WorkspaceError(
322442
322505
  `${input} is outside the workspace root - paths are relative to ${this.root}`,
322443
322506
  403
@@ -322446,9 +322509,9 @@ var init_files = __esm({
322446
322509
  let existing = abs;
322447
322510
  for (; ; ) {
322448
322511
  try {
322449
- const real = await import_fs9.promises.realpath(existing);
322450
- const realFromRoot = (0, import_path5.relative)(this.root, real);
322451
- if (realFromRoot.startsWith("..") || (0, import_path5.isAbsolute)(realFromRoot)) {
322512
+ const real = await import_fs10.promises.realpath(existing);
322513
+ const realFromRoot = (0, import_path6.relative)(this.root, real);
322514
+ if (realFromRoot.startsWith("..") || (0, import_path6.isAbsolute)(realFromRoot)) {
322452
322515
  throw new WorkspaceError(
322453
322516
  `${input} resolves outside the workspace root (symlink)`,
322454
322517
  403
@@ -322457,7 +322520,7 @@ var init_files = __esm({
322457
322520
  break;
322458
322521
  } catch (e2) {
322459
322522
  if (e2 instanceof WorkspaceError) throw e2;
322460
- const parent = (0, import_path5.dirname)(existing);
322523
+ const parent = (0, import_path6.dirname)(existing);
322461
322524
  if (parent === existing) break;
322462
322525
  existing = parent;
322463
322526
  }
@@ -322505,7 +322568,7 @@ var init_files = __esm({
322505
322568
  const out = [];
322506
322569
  const walk = async (relDir) => {
322507
322570
  if (out.length > limit) return;
322508
- const entries = await import_fs9.promises.readdir((0, import_path5.join)(this.root, relDir), { withFileTypes: true }).catch(() => []);
322571
+ const entries = await import_fs10.promises.readdir((0, import_path6.join)(this.root, relDir), { withFileTypes: true }).catch(() => []);
322509
322572
  for (const entry of entries) {
322510
322573
  if (SKIP_DIRS.has(entry.name)) continue;
322511
322574
  const rel = relDir === "." ? entry.name : `${relDir}/${entry.name}`;
@@ -322548,7 +322611,7 @@ var init_files = __esm({
322548
322611
  entries = entries.slice(0, limit);
322549
322612
  await Promise.all(
322550
322613
  entries.filter((e2) => e2.type === "file").map(async (e2) => {
322551
- e2.size = await import_fs9.promises.stat((0, import_path5.join)(this.root, e2.path)).then((s2) => s2.size).catch(() => void 0);
322614
+ e2.size = await import_fs10.promises.stat((0, import_path6.join)(this.root, e2.path)).then((s2) => s2.size).catch(() => void 0);
322552
322615
  })
322553
322616
  );
322554
322617
  return {
@@ -322559,12 +322622,12 @@ var init_files = __esm({
322559
322622
  async read(args) {
322560
322623
  if (!args.path) throw new WorkspaceError("path is required");
322561
322624
  const { abs, rel } = await this.resolvePath(args.path);
322562
- const stat2 = await import_fs9.promises.stat(abs).catch(() => null);
322625
+ const stat2 = await import_fs10.promises.stat(abs).catch(() => null);
322563
322626
  if (!stat2) throw new WorkspaceError(`${rel} does not exist`, 404);
322564
322627
  if (stat2.isDirectory()) {
322565
322628
  throw new WorkspaceError(`${rel} is a directory - use LocalListFiles`);
322566
322629
  }
322567
- const buffer = await import_fs9.promises.readFile(abs);
322630
+ const buffer = await import_fs10.promises.readFile(abs);
322568
322631
  if (buffer.subarray(0, 8e3).includes(0)) {
322569
322632
  return { path: rel, size: stat2.size, binary: true, content: "" };
322570
322633
  }
@@ -322593,7 +322656,7 @@ var init_files = __esm({
322593
322656
  };
322594
322657
  }
322595
322658
  async currentText(abs) {
322596
- return import_fs9.promises.readFile(abs, "utf-8").catch((e2) => {
322659
+ return import_fs10.promises.readFile(abs, "utf-8").catch((e2) => {
322597
322660
  if (e2?.code === "ENOENT") return null;
322598
322661
  throw e2;
322599
322662
  });
@@ -322614,8 +322677,8 @@ var init_files = __esm({
322614
322677
  );
322615
322678
  }
322616
322679
  }
322617
- await import_fs9.promises.mkdir((0, import_path5.dirname)(abs), { recursive: true });
322618
- await import_fs9.promises.writeFile(abs, content, "utf-8");
322680
+ await import_fs10.promises.mkdir((0, import_path6.dirname)(abs), { recursive: true });
322681
+ await import_fs10.promises.writeFile(abs, content, "utf-8");
322619
322682
  return {
322620
322683
  path: rel,
322621
322684
  size: Buffer.byteLength(content),
@@ -322647,7 +322710,7 @@ var init_files = __esm({
322647
322710
  );
322648
322711
  }
322649
322712
  const after = args.replaceAll ? before.split(args.oldText).join(args.newText ?? "") : before.replace(args.oldText, () => args.newText ?? "");
322650
- await import_fs9.promises.writeFile(abs, after, "utf-8");
322713
+ await import_fs10.promises.writeFile(abs, after, "utf-8");
322651
322714
  return {
322652
322715
  path: rel,
322653
322716
  replacements: args.replaceAll ? count : 1,
@@ -322658,14 +322721,14 @@ var init_files = __esm({
322658
322721
  async delete(args) {
322659
322722
  if (!args.path) throw new WorkspaceError("path is required");
322660
322723
  const { abs, rel } = await this.resolvePath(args.path, { forWrite: true });
322661
- const stat2 = await import_fs9.promises.lstat(abs).catch(() => null);
322724
+ const stat2 = await import_fs10.promises.lstat(abs).catch(() => null);
322662
322725
  if (!stat2) return { path: rel, deleted: false };
322663
322726
  if (stat2.isDirectory()) {
322664
322727
  throw new WorkspaceError(
322665
322728
  `${rel} is a directory - only files can be deleted (use RunCommand for more)`
322666
322729
  );
322667
322730
  }
322668
- await import_fs9.promises.unlink(abs);
322731
+ await import_fs10.promises.unlink(abs);
322669
322732
  return { path: rel, deleted: true };
322670
322733
  }
322671
322734
  async search(args) {
@@ -322717,7 +322780,7 @@ var init_files = __esm({
322717
322780
  raw = [];
322718
322781
  for (const file2 of await this.allFiles(rel, 2e4)) {
322719
322782
  if (globRe && !globRe.test(file2)) continue;
322720
- const text = await import_fs9.promises.readFile((0, import_path5.join)(this.root, file2)).catch(() => null);
322783
+ const text = await import_fs10.promises.readFile((0, import_path6.join)(this.root, file2)).catch(() => null);
322721
322784
  if (!text || text.subarray(0, 8e3).includes(0)) continue;
322722
322785
  text.toString("utf-8").split("\n").forEach((line, i2) => {
322723
322786
  if (raw.length <= max && re.test(line)) {
@@ -323510,11 +323573,11 @@ __export(start_exports4, {
323510
323573
  WORKSPACE_VERSION: () => WORKSPACE_VERSION,
323511
323574
  default: () => start_default2
323512
323575
  });
323513
- var import_promises12, import_path6, import_rxjs66, WORKSPACE_VERSION, csv, resolveWorkspace, start_default2;
323576
+ var import_promises12, import_path7, import_rxjs66, WORKSPACE_VERSION, csv, resolveWorkspace, start_default2;
323514
323577
  var init_start4 = __esm({
323515
323578
  "src/commands/workspace/start.ts"() {
323516
323579
  import_promises12 = require("fs/promises");
323517
- import_path6 = require("path");
323580
+ import_path7 = require("path");
323518
323581
  import_rxjs66 = __toESM(require_cjs());
323519
323582
  init_helpers();
323520
323583
  init_gql_client();
@@ -323532,7 +323595,7 @@ var init_start4 = __esm({
323532
323595
  if (cmd.token) {
323533
323596
  return {
323534
323597
  id: "(from --token)",
323535
- name: cmd.name ?? (0, import_path6.basename)(root),
323598
+ name: cmd.name ?? (0, import_path7.basename)(root),
323536
323599
  token: cmd.token,
323537
323600
  projectId: cmd.project ?? "",
323538
323601
  root
@@ -323552,7 +323615,7 @@ var init_start4 = __esm({
323552
323615
  );
323553
323616
  }
323554
323617
  );
323555
- const name2 = cmd.name || (0, import_path6.basename)(root);
323618
+ const name2 = cmd.name || (0, import_path7.basename)(root);
323556
323619
  Logger.info(`Registering ${root} as local workspace "${name2}"...`);
323557
323620
  const { workspace, token } = await (0, import_rxjs66.lastValueFrom)(
323558
323621
  GraphqlClienAPI.createLocalWorkspace(projectId, name2)
@@ -323740,8 +323803,20 @@ init_helpers();
323740
323803
  function buildCommands(program2) {
323741
323804
  program2.command("build").description("Build bundle using esbuild https://esbuild.github.io ").option(
323742
323805
  "-f, --files <files...>",
323743
- "File or files to bundle defaults to index.ts"
323744
- ).option("-b, --bundle", "Bundle code", true).option("-m, --minify", "Minify code", false).option("-p, --platform <char>", "Platform ", "node").option("-t, --target <char>", "Target ", "node14.4").option("-o, --outfile <char>", "Outfile name").option("-e, --external <external...>", "External libraries").action(lazy(() => Promise.resolve().then(() => (init_build(), build_exports)).then((m2) => m2.default)));
323806
+ "File or files to bundle (default: function.file from lambforge.yaml, else index.ts)"
323807
+ ).option(
323808
+ "-b, --bundle",
323809
+ "Bundle code (default: options.bundler.bundle, else true)"
323810
+ ).option(
323811
+ "-m, --minify",
323812
+ "Minify code (default: options.bundler.minify, else false)"
323813
+ ).option("-p, --platform <char>", "Platform ", "node").option(
323814
+ "-t, --target <char>",
323815
+ "Target (default: options.bundler.target, else node24)"
323816
+ ).option(
323817
+ "-o, --outfile <char>",
323818
+ "Outfile name (default: options.bundler.outfile, else index.js)"
323819
+ ).option("-e, --external <external...>", "External libraries").action(lazy(() => Promise.resolve().then(() => (init_build(), build_exports)).then((m2) => m2.default)));
323745
323820
  }
323746
323821
 
323747
323822
  // src/commands/cluster/index.ts