@gapi/gcli 1.8.251 → 1.8.253

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,24 @@
1
+ ## 2026-10-31 - self-managed-nodes: Cluster commands call the API by cluster id; reset-machine works on platform clusters
2
+
3
+ **Feature:** self-managed-nodes · **Type:** feat
4
+
5
+ - `clusterKubeconfig`, `clusterTalosconfig`, `teardownProjectCluster` are
6
+ sent with `clusterId` only - the server checks the cluster's own project
7
+ (one API for users and admins). `cluster:reset-machine` and
8
+ `cluster:talosconfig` no longer depend on the current project (free-host
9
+ failed with missing-cluster).
10
+ - `cluster:teardown --wait`: a cluster that left the project list is
11
+ deleted, not "not found".
12
+ - Needs cluster-provisioner with the optional `projectId` deployed first.
13
+ - **Test:** `npx jest --coverage=false` (126/126); `npm run esbuild`.
14
+ - **Debug:** "This is a platform cluster - only Lambforge admins can
15
+ manage it" = the logged-in user is not an admin.
16
+ - **Verification:**
17
+ - **Real run (local stack, home-1 on the LAN, real Hetzner):** free-host
18
+ (platform): reset-machine (the command that failed with missing-cluster),
19
+ attach, detach, reset, attach again. A new single-node Talos cluster in
20
+ the owner's `test` project: attach (KubeSpan from the LAN), kubeconfig +
21
+ talosconfig by cluster id, detach, reset - home-1 left in maintenance
22
+ mode; the test cluster torn down (status deleted, machine records gone).
23
+ A plan-team USER: refused on free-host (also when sending its own
24
+ projectId) and on the test project's cluster; its own project works.
@@ -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.251",
3
+ "version": "1.8.253",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Stradivario/gapi.git"
package/release/index.js CHANGED
@@ -37092,29 +37092,29 @@ var init_gql_client = __esm({
37092
37092
  variables: { projectId }
37093
37093
  }).pipe((0, import_operators.map)((res) => res.projectClusters));
37094
37094
  }
37095
- static teardownProjectCluster(projectId, clusterId) {
37095
+ // Cluster operations are keyed by the cluster alone: the server checks the
37096
+ // cluster's own project (one API for users and admins - a platform cluster
37097
+ // has no project).
37098
+ static teardownProjectCluster(clusterId) {
37096
37099
  return this.query({
37097
37100
  query: gql`
37098
- mutation teardownProjectCluster(
37099
- $projectId: String!
37100
- $clusterId: String!
37101
- ) {
37102
- teardownProjectCluster(projectId: $projectId, clusterId: $clusterId) {
37101
+ mutation teardownProjectCluster($clusterId: String!) {
37102
+ teardownProjectCluster(clusterId: $clusterId) {
37103
37103
  ${ClusterFragment}
37104
37104
  }
37105
37105
  }
37106
37106
  `,
37107
- variables: { projectId, clusterId }
37107
+ variables: { clusterId }
37108
37108
  }).pipe((0, import_operators.map)((res) => res.teardownProjectCluster));
37109
37109
  }
37110
- static clusterKubeconfig(projectId, clusterId) {
37110
+ static clusterKubeconfig(clusterId) {
37111
37111
  return this.query({
37112
37112
  query: gql`
37113
- query clusterKubeconfig($projectId: String!, $clusterId: String!) {
37114
- clusterKubeconfig(projectId: $projectId, clusterId: $clusterId)
37113
+ query clusterKubeconfig($clusterId: String!) {
37114
+ clusterKubeconfig(clusterId: $clusterId)
37115
37115
  }
37116
37116
  `,
37117
- variables: { projectId, clusterId }
37117
+ variables: { clusterId }
37118
37118
  }).pipe((0, import_operators.map)((res) => res.clusterKubeconfig));
37119
37119
  }
37120
37120
  // Cluster scaling, topology, load balancer and health (cluster-provisioner;
@@ -37294,19 +37294,11 @@ var init_gql_client = __esm({
37294
37294
  variables: { clusterId, includeCloud }
37295
37295
  }).pipe((0, import_operators.map)((res) => res.clusterNodes ?? []));
37296
37296
  }
37297
- static clusterTalosconfig(projectId, clusterId, ttlMinutes) {
37297
+ static clusterTalosconfig(clusterId, ttlMinutes) {
37298
37298
  return this.query({
37299
37299
  query: gql`
37300
- query clusterTalosconfig(
37301
- $projectId: String!
37302
- $clusterId: String!
37303
- $ttlMinutes: Int
37304
- ) {
37305
- clusterTalosconfig(
37306
- projectId: $projectId
37307
- clusterId: $clusterId
37308
- ttlMinutes: $ttlMinutes
37309
- ) {
37300
+ query clusterTalosconfig($clusterId: String!, $ttlMinutes: Int) {
37301
+ clusterTalosconfig(clusterId: $clusterId, ttlMinutes: $ttlMinutes) {
37310
37302
  talosconfig
37311
37303
  expiresAt
37312
37304
  endpoint
@@ -37314,7 +37306,7 @@ var init_gql_client = __esm({
37314
37306
  }
37315
37307
  }
37316
37308
  `,
37317
- variables: { projectId, clusterId, ttlMinutes }
37309
+ variables: { clusterId, ttlMinutes }
37318
37310
  }).pipe((0, import_operators.map)((res) => res.clusterTalosconfig));
37319
37311
  }
37320
37312
  static setClusterNodePaused(clusterId, name2, paused) {
@@ -76045,7 +76037,7 @@ ${lanes.join("\n")}
76045
76037
  var parseDiagnostics;
76046
76038
  var jsDocDiagnostics;
76047
76039
  var syntaxCursor;
76048
- var currentToken;
76040
+ var currentToken2;
76049
76041
  var nodeCount;
76050
76042
  var identifiers;
76051
76043
  var identifierCount;
@@ -76592,60 +76584,60 @@ ${lanes.join("\n")}
76592
76584
  return scanner2.hasPrecedingJSDocComment();
76593
76585
  }
76594
76586
  function token() {
76595
- return currentToken;
76587
+ return currentToken2;
76596
76588
  }
76597
76589
  function nextTokenWithoutCheck() {
76598
- return currentToken = scanner2.scan();
76590
+ return currentToken2 = scanner2.scan();
76599
76591
  }
76600
76592
  function nextTokenAnd(func) {
76601
76593
  nextToken();
76602
76594
  return func();
76603
76595
  }
76604
76596
  function nextToken() {
76605
- if (isKeyword(currentToken) && (scanner2.hasUnicodeEscape() || scanner2.hasExtendedUnicodeEscape())) {
76597
+ if (isKeyword(currentToken2) && (scanner2.hasUnicodeEscape() || scanner2.hasExtendedUnicodeEscape())) {
76606
76598
  parseErrorAt(scanner2.getTokenStart(), scanner2.getTokenEnd(), Diagnostics.Keywords_cannot_contain_escape_characters);
76607
76599
  }
76608
76600
  return nextTokenWithoutCheck();
76609
76601
  }
76610
76602
  function nextTokenJSDoc() {
76611
- return currentToken = scanner2.scanJsDocToken();
76603
+ return currentToken2 = scanner2.scanJsDocToken();
76612
76604
  }
76613
76605
  function nextJSDocCommentTextToken(inBackticks) {
76614
- return currentToken = scanner2.scanJSDocCommentTextToken(inBackticks);
76606
+ return currentToken2 = scanner2.scanJSDocCommentTextToken(inBackticks);
76615
76607
  }
76616
76608
  function reScanGreaterToken() {
76617
- return currentToken = scanner2.reScanGreaterToken();
76609
+ return currentToken2 = scanner2.reScanGreaterToken();
76618
76610
  }
76619
76611
  function reScanSlashToken() {
76620
- return currentToken = scanner2.reScanSlashToken();
76612
+ return currentToken2 = scanner2.reScanSlashToken();
76621
76613
  }
76622
76614
  function reScanTemplateToken(isTaggedTemplate) {
76623
- return currentToken = scanner2.reScanTemplateToken(isTaggedTemplate);
76615
+ return currentToken2 = scanner2.reScanTemplateToken(isTaggedTemplate);
76624
76616
  }
76625
76617
  function reScanLessThanToken() {
76626
- return currentToken = scanner2.reScanLessThanToken();
76618
+ return currentToken2 = scanner2.reScanLessThanToken();
76627
76619
  }
76628
76620
  function reScanHashToken() {
76629
- return currentToken = scanner2.reScanHashToken();
76621
+ return currentToken2 = scanner2.reScanHashToken();
76630
76622
  }
76631
76623
  function scanJsxIdentifier() {
76632
- return currentToken = scanner2.scanJsxIdentifier();
76624
+ return currentToken2 = scanner2.scanJsxIdentifier();
76633
76625
  }
76634
76626
  function scanJsxText() {
76635
- return currentToken = scanner2.scanJsxToken();
76627
+ return currentToken2 = scanner2.scanJsxToken();
76636
76628
  }
76637
76629
  function scanJsxAttributeValue() {
76638
- return currentToken = scanner2.scanJsxAttributeValue();
76630
+ return currentToken2 = scanner2.scanJsxAttributeValue();
76639
76631
  }
76640
76632
  function speculationHelper(callback, speculationKind) {
76641
- const saveToken = currentToken;
76633
+ const saveToken = currentToken2;
76642
76634
  const saveParseDiagnosticsLength = parseDiagnostics.length;
76643
76635
  const saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
76644
76636
  const saveContextFlags = contextFlags;
76645
76637
  const result = speculationKind !== 0 ? scanner2.lookAhead(callback) : scanner2.tryScan(callback);
76646
76638
  Debug.assert(saveContextFlags === contextFlags);
76647
76639
  if (!result || speculationKind !== 0) {
76648
- currentToken = saveToken;
76640
+ currentToken2 = saveToken;
76649
76641
  if (speculationKind !== 2) {
76650
76642
  parseDiagnostics.length = saveParseDiagnosticsLength;
76651
76643
  }
@@ -78642,8 +78634,8 @@ ${lanes.join("\n")}
78642
78634
  19
78643
78635
  /* OpenBraceToken */
78644
78636
  );
78645
- const currentToken2 = token();
78646
- if (currentToken2 === 118 || currentToken2 === 132) {
78637
+ const currentToken22 = token();
78638
+ if (currentToken22 === 118 || currentToken22 === 132) {
78647
78639
  nextToken();
78648
78640
  } else {
78649
78641
  parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(
@@ -78656,7 +78648,7 @@ ${lanes.join("\n")}
78656
78648
  /* ColonToken */
78657
78649
  );
78658
78650
  attributes = parseImportAttributes(
78659
- currentToken2,
78651
+ currentToken22,
78660
78652
  /*skipKeyword*/
78661
78653
  true
78662
78654
  );
@@ -79846,10 +79838,10 @@ ${lanes.join("\n")}
79846
79838
  const pos = getNodePos();
79847
79839
  const node = factory2.createJsxText(
79848
79840
  scanner2.getTokenValue(),
79849
- currentToken === 13
79841
+ currentToken2 === 13
79850
79842
  /* JsxTextAllWhiteSpaces */
79851
79843
  );
79852
- currentToken = scanner2.scanJsxToken();
79844
+ currentToken2 = scanner2.scanJsxToken();
79853
79845
  return finishNode(node, pos);
79854
79846
  }
79855
79847
  function parseJsxChild(openingTag, token2) {
@@ -79892,7 +79884,7 @@ ${lanes.join("\n")}
79892
79884
  const saveParsingContext = parsingContext;
79893
79885
  parsingContext |= 1 << 14;
79894
79886
  while (true) {
79895
- const child = parseJsxChild(openingTag, currentToken = scanner2.reScanJsxToken());
79887
+ const child = parseJsxChild(openingTag, currentToken2 = scanner2.reScanJsxToken());
79896
79888
  if (!child) break;
79897
79889
  list.push(child);
79898
79890
  if (isJsxOpeningElement(openingTag) && (child == null ? void 0 : child.kind) === 285 && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) {
@@ -81122,11 +81114,11 @@ ${lanes.join("\n")}
81122
81114
  nextToken();
81123
81115
  return token() === 166 || token() === 11 || token() === 42 || token() === 19 || tokenIsIdentifierOrKeyword(token());
81124
81116
  case 95:
81125
- let currentToken2 = nextToken();
81126
- if (currentToken2 === 156) {
81127
- currentToken2 = lookAhead(nextToken);
81117
+ let currentToken22 = nextToken();
81118
+ if (currentToken22 === 156) {
81119
+ currentToken22 = lookAhead(nextToken);
81128
81120
  }
81129
- 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) {
81130
81122
  return true;
81131
81123
  }
81132
81124
  continue;
@@ -82327,9 +82319,9 @@ ${lanes.join("\n")}
82327
82319
  return importClause;
82328
82320
  }
82329
82321
  function tryParseImportAttributes() {
82330
- const currentToken2 = token();
82331
- if ((currentToken2 === 118 || currentToken2 === 132) && !scanner2.hasPrecedingLineBreak()) {
82332
- return parseImportAttributes(currentToken2);
82322
+ const currentToken22 = token();
82323
+ if ((currentToken22 === 118 || currentToken22 === 132) && !scanner2.hasPrecedingLineBreak()) {
82324
+ return parseImportAttributes(currentToken22);
82333
82325
  }
82334
82326
  }
82335
82327
  function parseImportAttribute() {
@@ -82623,9 +82615,9 @@ ${lanes.join("\n")}
82623
82615
  moduleSpecifier = parseModuleSpecifier();
82624
82616
  }
82625
82617
  }
82626
- const currentToken2 = token();
82627
- if (moduleSpecifier && (currentToken2 === 118 || currentToken2 === 132) && !scanner2.hasPrecedingLineBreak()) {
82628
- attributes = parseImportAttributes(currentToken2);
82618
+ const currentToken22 = token();
82619
+ if (moduleSpecifier && (currentToken22 === 118 || currentToken22 === 132) && !scanner2.hasPrecedingLineBreak()) {
82620
+ attributes = parseImportAttributes(currentToken22);
82629
82621
  }
82630
82622
  parseSemicolon();
82631
82623
  setAwaitContext(savedAwaitContext);
@@ -82709,7 +82701,7 @@ ${lanes.join("\n")}
82709
82701
  /* ParseAll */
82710
82702
  );
82711
82703
  scanner2.setText(content, start3, length2);
82712
- currentToken = scanner2.scan();
82704
+ currentToken2 = scanner2.scan();
82713
82705
  const jsDocTypeExpression = parseJSDocTypeExpression();
82714
82706
  const sourceFile = createSourceFile2(
82715
82707
  "file.js",
@@ -82797,7 +82789,7 @@ ${lanes.join("\n")}
82797
82789
  }
82798
82790
  JSDocParser2.parseIsolatedJSDocComment = parseIsolatedJSDocComment2;
82799
82791
  function parseJSDocComment(parent2, start3, length2) {
82800
- const saveToken = currentToken;
82792
+ const saveToken = currentToken2;
82801
82793
  const saveParseDiagnosticsLength = parseDiagnostics.length;
82802
82794
  const saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
82803
82795
  const comment = doInsideOfContext(16777216, () => parseJSDocCommentWorker(start3, length2));
@@ -82808,7 +82800,7 @@ ${lanes.join("\n")}
82808
82800
  }
82809
82801
  addRange(jsDocDiagnostics, parseDiagnostics, saveParseDiagnosticsLength);
82810
82802
  }
82811
- currentToken = saveToken;
82803
+ currentToken2 = saveToken;
82812
82804
  parseDiagnostics.length = saveParseDiagnosticsLength;
82813
82805
  parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
82814
82806
  return comment;
@@ -195187,18 +195179,18 @@ ${lanes.join("\n")}
195187
195179
  const importedFiles = [];
195188
195180
  let ambientExternalModules;
195189
195181
  let lastToken;
195190
- let currentToken;
195182
+ let currentToken2;
195191
195183
  let braceNesting = 0;
195192
195184
  let externalModule = false;
195193
195185
  function nextToken() {
195194
- lastToken = currentToken;
195195
- currentToken = scanner.scan();
195196
- if (currentToken === 19) {
195186
+ lastToken = currentToken2;
195187
+ currentToken2 = scanner.scan();
195188
+ if (currentToken2 === 19) {
195197
195189
  braceNesting++;
195198
- } else if (currentToken === 20) {
195190
+ } else if (currentToken2 === 20) {
195199
195191
  braceNesting--;
195200
195192
  }
195201
- return currentToken;
195193
+ return currentToken2;
195202
195194
  }
195203
195195
  function getFileReference() {
195204
195196
  const fileName = scanner.getTokenValue();
@@ -218284,11 +218276,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
218284
218276
  };
218285
218277
  }
218286
218278
  function getJSDocParameterCompletions(sourceFile, position, checker, options, preferences, tagNameOnly) {
218287
- const currentToken = getTokenAtPosition(sourceFile, position);
218288
- if (!isJSDocTag(currentToken) && !isJSDoc(currentToken)) {
218279
+ const currentToken2 = getTokenAtPosition(sourceFile, position);
218280
+ if (!isJSDocTag(currentToken2) && !isJSDoc(currentToken2)) {
218289
218281
  return [];
218290
218282
  }
218291
- const jsDoc = isJSDoc(currentToken) ? currentToken : currentToken.parent;
218283
+ const jsDoc = isJSDoc(currentToken2) ? currentToken2 : currentToken2.parent;
218292
218284
  if (!isJSDoc(jsDoc)) {
218293
218285
  return [];
218294
218286
  }
@@ -220140,10 +220132,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
220140
220132
  const typeChecker = program2.getTypeChecker();
220141
220133
  const inCheckedFile = isCheckedFile(sourceFile, compilerOptions);
220142
220134
  let start3 = timestamp();
220143
- let currentToken = getTokenAtPosition(sourceFile, position);
220135
+ let currentToken2 = getTokenAtPosition(sourceFile, position);
220144
220136
  log("getCompletionData: Get current token: " + (timestamp() - start3));
220145
220137
  start3 = timestamp();
220146
- const insideComment = isInComment(sourceFile, position, currentToken);
220138
+ const insideComment = isInComment(sourceFile, position, currentToken2);
220147
220139
  log("getCompletionData: Is inside comment: " + (timestamp() - start3));
220148
220140
  let insideJsDocTagTypeExpression = false;
220149
220141
  let insideJsDocImportTag = false;
@@ -220165,7 +220157,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
220165
220157
  }
220166
220158
  }
220167
220159
  }
220168
- const tag = getJsDocTagAtPosition(currentToken, position);
220160
+ const tag = getJsDocTagAtPosition(currentToken2, position);
220169
220161
  if (tag) {
220170
220162
  if (tag.tagName.pos <= position && position <= tag.tagName.end) {
220171
220163
  return {
@@ -220178,8 +220170,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
220178
220170
  } else {
220179
220171
  const typeExpression = tryGetTypeExpressionFromTag(tag);
220180
220172
  if (typeExpression) {
220181
- currentToken = getTokenAtPosition(sourceFile, position);
220182
- 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)) {
220183
220175
  insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression);
220184
220176
  }
220185
220177
  }
@@ -220199,7 +220191,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
220199
220191
  const previousToken = tokens.previousToken;
220200
220192
  let contextToken = tokens.contextToken;
220201
220193
  log("getCompletionData: Get previous token: " + (timestamp() - start3));
220202
- let node = currentToken;
220194
+ let node = currentToken2;
220203
220195
  let propertyAccessToConvert;
220204
220196
  let isRightOfDot = false;
220205
220197
  let isRightOfQuestionDot = false;
@@ -220271,16 +220263,16 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
220271
220263
  contextToken = parent2;
220272
220264
  parent2 = parent2.parent;
220273
220265
  }
220274
- if (currentToken.parent === location) {
220275
- switch (currentToken.kind) {
220266
+ if (currentToken2.parent === location) {
220267
+ switch (currentToken2.kind) {
220276
220268
  case 32:
220277
- if (currentToken.parent.kind === 285 || currentToken.parent.kind === 287) {
220278
- location = currentToken;
220269
+ if (currentToken2.parent.kind === 285 || currentToken2.parent.kind === 287) {
220270
+ location = currentToken2;
220279
220271
  }
220280
220272
  break;
220281
220273
  case 44:
220282
- if (currentToken.parent.kind === 286) {
220283
- location = currentToken;
220274
+ if (currentToken2.parent.kind === 286) {
220275
+ location = currentToken2;
220284
220276
  }
220285
220277
  break;
220286
220278
  }
@@ -232477,30 +232469,30 @@ ${options.prefix}` : "\n" : options.prefix
232477
232469
  scanner2.resetTokenState(savedPos);
232478
232470
  scanner2.scan();
232479
232471
  }
232480
- let currentToken = getNextToken(n, expectedScanAction);
232472
+ let currentToken2 = getNextToken(n, expectedScanAction);
232481
232473
  const token = createTextRangeWithKind(
232482
232474
  scanner2.getTokenFullStart(),
232483
232475
  scanner2.getTokenEnd(),
232484
- currentToken
232476
+ currentToken2
232485
232477
  );
232486
232478
  if (trailingTrivia) {
232487
232479
  trailingTrivia = void 0;
232488
232480
  }
232489
232481
  while (scanner2.getTokenFullStart() < endPos) {
232490
- currentToken = scanner2.scan();
232491
- if (!isTrivia(currentToken)) {
232482
+ currentToken2 = scanner2.scan();
232483
+ if (!isTrivia(currentToken2)) {
232492
232484
  break;
232493
232485
  }
232494
232486
  const trivia = createTextRangeWithKind(
232495
232487
  scanner2.getTokenFullStart(),
232496
232488
  scanner2.getTokenEnd(),
232497
- currentToken
232489
+ currentToken2
232498
232490
  );
232499
232491
  if (!trailingTrivia) {
232500
232492
  trailingTrivia = [];
232501
232493
  }
232502
232494
  trailingTrivia.push(trivia);
232503
- if (currentToken === 4) {
232495
+ if (currentToken2 === 4) {
232504
232496
  scanner2.scan();
232505
232497
  break;
232506
232498
  }
@@ -235668,8 +235660,8 @@ ${options.prefix}` : "\n" : options.prefix
235668
235660
  return 0;
235669
235661
  }
235670
235662
  const lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
235671
- const currentToken = getTokenAtPosition(sourceFile, position);
235672
- 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;
235673
235665
  if (options.indentStyle === 1 || isObjectLiteral) {
235674
235666
  return getBlockIndent(sourceFile, position, options);
235675
235667
  }
@@ -235685,7 +235677,7 @@ ${options.prefix}` : "\n" : options.prefix
235685
235677
  219,
235686
235678
  220
235687
235679
  /* ArrowFunction */
235688
- ].includes(currentToken.parent.kind);
235680
+ ].includes(currentToken2.parent.kind);
235689
235681
  const indentSize = useTheSameBaseIndentation ? 0 : options.indentSize;
235690
235682
  return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize;
235691
235683
  }
@@ -254858,12 +254850,21 @@ var init_build = __esm({
254858
254850
  });
254859
254851
 
254860
254852
  // src/commands/cluster/helpers/poll-until-ready.ts
254861
- function pollUntilReady(projectId, clusterId, { intervalMs = 5e3, timeoutMs = 20 * 60 * 1e3 } = {}) {
254853
+ function pollUntilReady(projectId, clusterId, {
254854
+ intervalMs = 5e3,
254855
+ timeoutMs = 20 * 60 * 1e3,
254856
+ /** watching a teardown: a cluster no longer listed is deleted (the
254857
+ project's list leaves deleted clusters out) */
254858
+ goneMeansDeleted = false
254859
+ } = {}) {
254862
254860
  return (0, import_rxjs7.firstValueFrom)(
254863
254861
  (0, import_rxjs7.timer)(0, intervalMs).pipe(
254864
254862
  (0, import_operators6.switchMap)(() => GraphqlClienAPI.projectClusters(projectId)),
254865
254863
  (0, import_operators6.switchMap)((clusters) => {
254866
254864
  const cluster = (clusters || []).find((c) => c.id === clusterId);
254865
+ if (!cluster && goneMeansDeleted) {
254866
+ return [{ id: clusterId, status: "deleted" }];
254867
+ }
254867
254868
  if (!cluster) {
254868
254869
  throw new Error(`cluster ${clusterId} not found`);
254869
254870
  }
@@ -255494,7 +255495,7 @@ var init_teardown = __esm({
255494
255495
  const { projectId, cluster } = await (0, import_rxjs14.lastValueFrom)(
255495
255496
  parseProjectId(cmd.project).pipe(
255496
255497
  (0, import_operators10.switchMap)(
255497
- (projectId2) => GraphqlClienAPI.teardownProjectCluster(projectId2, cmd.cluster).pipe(
255498
+ (projectId2) => GraphqlClienAPI.teardownProjectCluster(cmd.cluster).pipe(
255498
255499
  (0, import_operators10.map)((cluster2) => ({ projectId: projectId2, cluster: cluster2 }))
255499
255500
  )
255500
255501
  ),
@@ -255515,7 +255516,9 @@ var init_teardown = __esm({
255515
255516
  return cluster;
255516
255517
  }
255517
255518
  Logger.info(`Waiting for cluster ${cluster.id} to finish tearing down...`);
255518
- const finalCluster = await pollUntilReady(projectId, cluster.id);
255519
+ const finalCluster = await pollUntilReady(projectId, cluster.id, {
255520
+ goneMeansDeleted: true
255521
+ });
255519
255522
  Logger.log(
255520
255523
  `[Action][teardownProjectCluster] final status: ${finalCluster.status}`
255521
255524
  );
@@ -255534,15 +255537,11 @@ var init_kubeconfig = __esm({
255534
255537
  "src/commands/cluster/kubeconfig.ts"() {
255535
255538
  import_rxjs15 = __toESM(require_cjs());
255536
255539
  import_operators11 = __toESM(require_operators());
255537
- init_helpers();
255538
255540
  init_gql_client();
255539
255541
  init_log();
255540
255542
  init_read_file();
255541
255543
  kubeconfig_default = (cmd) => (0, import_rxjs15.lastValueFrom)(
255542
- parseProjectId(cmd.project).pipe(
255543
- (0, import_operators11.switchMap)(
255544
- (projectId) => GraphqlClienAPI.clusterKubeconfig(projectId, cmd.cluster)
255545
- ),
255544
+ GraphqlClienAPI.clusterKubeconfig(cmd.cluster).pipe(
255546
255545
  (0, import_operators11.switchMap)(
255547
255546
  (kubeconfig) => cmd.output ? writeFileAsObservable(cmd.output, kubeconfig).pipe(
255548
255547
  (0, import_operators11.tap)(() => Logger.info(`Wrote kubeconfig to ${cmd.output}`))
@@ -256030,7 +256029,7 @@ var init_reset_machine = __esm({
256030
256029
  "--node-ip is required: the machine's address on your network"
256031
256030
  );
256032
256031
  }
256033
- const { projectId, clusterId } = await resolveClusterTarget(cmd);
256032
+ const { clusterId } = await resolveClusterTarget(cmd);
256034
256033
  const node = (await (0, import_rxjs20.lastValueFrom)(GraphqlClienAPI.clusterNodes(clusterId, true))).find((n) => n.name === name2);
256035
256034
  if (node?.source === "hetzner") {
256036
256035
  throw new Error(
@@ -256043,7 +256042,7 @@ var init_reset_machine = __esm({
256043
256042
  );
256044
256043
  }
256045
256044
  const access = await (0, import_rxjs20.lastValueFrom)(
256046
- GraphqlClienAPI.clusterTalosconfig(projectId, clusterId, 15)
256045
+ GraphqlClienAPI.clusterTalosconfig(clusterId, 15)
256047
256046
  );
256048
256047
  const binary = access.talosVersion ? await ensureTalosctl(access.talosVersion) : "talosctl";
256049
256048
  const dir = await (0, import_promises3.mkdtemp)((0, import_path3.join)((0, import_os3.tmpdir)(), "gcli-reset-"));
@@ -256132,9 +256131,9 @@ var init_talosconfig = __esm({
256132
256131
  if (ttl !== void 0 && (!Number.isInteger(ttl) || ttl < 5 || ttl > 1440)) {
256133
256132
  throw new Error("--ttl is in minutes, 5 to 1440");
256134
256133
  }
256135
- const { projectId, clusterId } = await resolveClusterTarget(cmd);
256134
+ const { clusterId } = await resolveClusterTarget(cmd);
256136
256135
  const res = await (0, import_rxjs21.lastValueFrom)(
256137
- GraphqlClienAPI.clusterTalosconfig(projectId, clusterId, ttl)
256136
+ GraphqlClienAPI.clusterTalosconfig(clusterId, ttl)
256138
256137
  );
256139
256138
  if (!cmd.output) {
256140
256139
  process.stdout.write(res.talosconfig);
@@ -319673,7 +319672,9 @@ var init_zod = __esm({
319673
319672
  // src/commands/proxy/start.ts
319674
319673
  var start_exports = {};
319675
319674
  __export(start_exports, {
319676
- default: () => startProxy
319675
+ currentToken: () => currentToken,
319676
+ default: () => startProxy,
319677
+ performFetch: () => performFetch
319677
319678
  });
319678
319679
  async function startProxy(cmd) {
319679
319680
  return (0, import_rxjs46.lastValueFrom)(
@@ -319785,7 +319786,7 @@ async function startProxy(cmd) {
319785
319786
  )
319786
319787
  );
319787
319788
  }
319788
- var import_rxjs46, import_operators31, import_stream2, performFetch;
319789
+ var import_rxjs46, import_operators31, import_stream2, pendingToken, currentToken, withToken, performFetch;
319789
319790
  var init_start = __esm({
319790
319791
  "src/commands/proxy/start.ts"() {
319791
319792
  init_client2();
@@ -319797,26 +319798,40 @@ var init_start = __esm({
319797
319798
  import_stream2 = require("stream");
319798
319799
  init_zod();
319799
319800
  init_gql_client();
319801
+ pendingToken = null;
319802
+ currentToken = (force = false) => {
319803
+ if (!pendingToken || force) {
319804
+ pendingToken = (0, import_rxjs46.lastValueFrom)(
319805
+ GraphqlClienAPI.getConfig(force).pipe(
319806
+ (0, import_operators31.take)(1),
319807
+ (0, import_operators31.map)((config2) => config2.token)
319808
+ )
319809
+ ).finally(() => {
319810
+ pendingToken = null;
319811
+ });
319812
+ }
319813
+ return pendingToken;
319814
+ };
319815
+ withToken = (init, token) => {
319816
+ const headers = new Headers(init?.headers);
319817
+ headers.set("Authorization", token);
319818
+ return { ...init, headers };
319819
+ };
319800
319820
  performFetch = (input, init) => {
319801
- return (0, import_rxjs46.from)(fetch(input, init)).pipe(
319821
+ return (0, import_rxjs46.from)(currentToken()).pipe(
319822
+ (0, import_operators31.switchMap)((token) => fetch(input, withToken(init, token))),
319802
319823
  (0, import_operators31.switchMap)((res) => {
319803
319824
  if (res.status === 401 || res.status === 403) {
319804
319825
  process.stderr.write(
319805
319826
  `[DEBUG] Request failed with ${res.status}. Refreshing token...
319806
319827
  `
319807
319828
  );
319808
- return GraphqlClienAPI.getConfig(true).pipe(
319809
- (0, import_operators31.take)(1),
319810
- (0, import_operators31.switchMap)((config2) => {
319829
+ return (0, import_rxjs46.from)(currentToken(true)).pipe(
319830
+ (0, import_operators31.switchMap)((token) => {
319811
319831
  process.stderr.write(
319812
319832
  "[DEBUG] Token refreshed. Retrying request...\n"
319813
319833
  );
319814
- const headers = new Headers(init?.headers);
319815
- headers.set("Authorization", config2.token);
319816
- return fetch(input, {
319817
- ...init,
319818
- headers
319819
- });
319834
+ return fetch(input, withToken(init, token));
319820
319835
  })
319821
319836
  );
319822
319837
  }