indent 0.0.8__py3-none-any.whl

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.

Potentially problematic release.


This version of indent might be problematic. Click here for more details.

Files changed (56) hide show
  1. exponent/__init__.py +1 -0
  2. exponent/cli.py +112 -0
  3. exponent/commands/cloud_commands.py +85 -0
  4. exponent/commands/common.py +434 -0
  5. exponent/commands/config_commands.py +581 -0
  6. exponent/commands/github_app_commands.py +211 -0
  7. exponent/commands/listen_commands.py +96 -0
  8. exponent/commands/run_commands.py +208 -0
  9. exponent/commands/settings.py +56 -0
  10. exponent/commands/shell_commands.py +2840 -0
  11. exponent/commands/theme.py +246 -0
  12. exponent/commands/types.py +111 -0
  13. exponent/commands/upgrade.py +29 -0
  14. exponent/commands/utils.py +236 -0
  15. exponent/core/config.py +180 -0
  16. exponent/core/graphql/__init__.py +0 -0
  17. exponent/core/graphql/client.py +59 -0
  18. exponent/core/graphql/cloud_config_queries.py +77 -0
  19. exponent/core/graphql/get_chats_query.py +47 -0
  20. exponent/core/graphql/github_config_queries.py +56 -0
  21. exponent/core/graphql/mutations.py +75 -0
  22. exponent/core/graphql/queries.py +110 -0
  23. exponent/core/graphql/subscriptions.py +452 -0
  24. exponent/core/remote_execution/checkpoints.py +212 -0
  25. exponent/core/remote_execution/cli_rpc_types.py +214 -0
  26. exponent/core/remote_execution/client.py +545 -0
  27. exponent/core/remote_execution/code_execution.py +58 -0
  28. exponent/core/remote_execution/command_execution.py +105 -0
  29. exponent/core/remote_execution/error_info.py +45 -0
  30. exponent/core/remote_execution/exceptions.py +10 -0
  31. exponent/core/remote_execution/file_write.py +410 -0
  32. exponent/core/remote_execution/files.py +415 -0
  33. exponent/core/remote_execution/git.py +268 -0
  34. exponent/core/remote_execution/languages/python_execution.py +239 -0
  35. exponent/core/remote_execution/languages/shell_streaming.py +221 -0
  36. exponent/core/remote_execution/languages/types.py +20 -0
  37. exponent/core/remote_execution/session.py +128 -0
  38. exponent/core/remote_execution/system_context.py +54 -0
  39. exponent/core/remote_execution/tool_execution.py +289 -0
  40. exponent/core/remote_execution/truncation.py +284 -0
  41. exponent/core/remote_execution/types.py +670 -0
  42. exponent/core/remote_execution/utils.py +600 -0
  43. exponent/core/types/__init__.py +0 -0
  44. exponent/core/types/command_data.py +206 -0
  45. exponent/core/types/event_types.py +89 -0
  46. exponent/core/types/generated/__init__.py +0 -0
  47. exponent/core/types/generated/strategy_info.py +225 -0
  48. exponent/migration-docs/login.md +112 -0
  49. exponent/py.typed +4 -0
  50. exponent/utils/__init__.py +0 -0
  51. exponent/utils/colors.py +92 -0
  52. exponent/utils/version.py +289 -0
  53. indent-0.0.8.dist-info/METADATA +36 -0
  54. indent-0.0.8.dist-info/RECORD +56 -0
  55. indent-0.0.8.dist-info/WHEEL +4 -0
  56. indent-0.0.8.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,581 @@
1
+ import json
2
+ import sys
3
+
4
+ import click
5
+
6
+ from exponent.commands.common import (
7
+ redirect_to_login,
8
+ refresh_api_key_task,
9
+ run_until_complete,
10
+ set_login_complete,
11
+ )
12
+ from exponent.commands.settings import use_settings
13
+ from exponent.commands.types import exponent_cli_group
14
+ from exponent.core.config import Settings
15
+ from exponent.core.graphql.client import GraphQLClient
16
+ from exponent.core.graphql.cloud_config_queries import (
17
+ CREATE_CLOUD_CONFIG_MUTATION,
18
+ GET_CLOUD_CONFIGS_QUERY,
19
+ UPDATE_CLOUD_CONFIG_MUTATION,
20
+ )
21
+ from exponent.core.graphql.get_chats_query import GET_CHATS_QUERY
22
+ from exponent.core.graphql.github_config_queries import (
23
+ CHECK_GITHUB_CONFIG_VALIDITY_QUERY,
24
+ CREATE_GITHUB_CONFIG_MUTATION,
25
+ REPOS_FOR_GITHUB_CONFIG_QUERY,
26
+ )
27
+ from exponent.core.graphql.subscriptions import AUTHENTICATED_USER_SUBSCRIPTION
28
+ from exponent.utils.version import (
29
+ get_installed_metadata,
30
+ get_installed_version,
31
+ get_installer,
32
+ get_python_path,
33
+ get_sys_executable,
34
+ )
35
+
36
+
37
+ @exponent_cli_group()
38
+ def config_cli() -> None:
39
+ """Manage Exponent configuration settings."""
40
+ pass
41
+
42
+
43
+ @config_cli.command(hidden=True)
44
+ @use_settings
45
+ def debug(
46
+ settings: Settings,
47
+ ) -> None:
48
+ click.echo("Settings:")
49
+ click.echo(settings)
50
+ click.echo("\nInstalled Version:")
51
+ click.echo(get_installed_version())
52
+ click.echo("\nPython Version:")
53
+ click.echo(sys.version)
54
+ click.echo("\nPython Path:")
55
+ click.echo(get_python_path())
56
+ click.echo("\nSys Executable Path:")
57
+ click.echo(get_sys_executable())
58
+ click.echo("\nInstaller:")
59
+ click.echo(get_installer())
60
+ click.echo("\nInstalled Metadata:")
61
+ click.echo(get_installed_metadata())
62
+
63
+
64
+ @config_cli.command(hidden=True)
65
+ @use_settings
66
+ def check_github_config_validity(
67
+ settings: Settings,
68
+ ) -> None:
69
+ if not settings.api_key:
70
+ redirect_to_login(settings)
71
+ return
72
+
73
+ run_until_complete(
74
+ check_github_config_validity_task(
75
+ api_key=settings.api_key,
76
+ base_api_url=settings.get_base_api_url(),
77
+ base_ws_url=settings.get_base_ws_url(),
78
+ )
79
+ )
80
+
81
+
82
+ async def check_github_config_validity_task(
83
+ api_key: str,
84
+ base_api_url: str,
85
+ base_ws_url: str,
86
+ ) -> None:
87
+ graphql_client = GraphQLClient(api_key, base_api_url, base_ws_url)
88
+ result = await graphql_client.execute(CHECK_GITHUB_CONFIG_VALIDITY_QUERY)
89
+ click.echo(result)
90
+
91
+
92
+ @config_cli.command(hidden=True)
93
+ @use_settings
94
+ def repos_for_github_config(
95
+ settings: Settings,
96
+ ) -> None:
97
+ if not settings.api_key:
98
+ redirect_to_login(settings)
99
+ return
100
+
101
+ run_until_complete(
102
+ repos_for_github_config_task(
103
+ api_key=settings.api_key,
104
+ base_api_url=settings.get_base_api_url(),
105
+ base_ws_url=settings.get_base_ws_url(),
106
+ )
107
+ )
108
+
109
+
110
+ async def repos_for_github_config_task(
111
+ api_key: str,
112
+ base_api_url: str,
113
+ base_ws_url: str,
114
+ ) -> None:
115
+ graphql_client = GraphQLClient(api_key, base_api_url, base_ws_url)
116
+ try:
117
+ click.echo("Sending request to fetch repos...")
118
+ result = await graphql_client.execute(
119
+ REPOS_FOR_GITHUB_CONFIG_QUERY, timeout=120
120
+ ) # 120 seconds timeout
121
+ click.echo("Request completed. Result:")
122
+ click.echo(result)
123
+ except Exception as e:
124
+ click.echo(f"An error occurred while fetching repos: {e!s}")
125
+ click.echo(f"Error type: {type(e).__name__}")
126
+ # Add more detailed error information if available
127
+ if hasattr(e, "response"):
128
+ click.echo(f"Response status: {e.response.status_code}")
129
+ click.echo(f"Response content: {e.response.text}")
130
+
131
+
132
+ @config_cli.command(hidden=True)
133
+ @click.option(
134
+ "--set-git-warning-disabled",
135
+ is_flag=True,
136
+ help="Disable the git warning for running Exponent from a non-git repository",
137
+ )
138
+ @click.option(
139
+ "--set-git-warning-enabled",
140
+ is_flag=True,
141
+ help="Enable the git warning for running Exponent from a non-git repository",
142
+ )
143
+ @click.option(
144
+ "--set-auto-upgrade-enabled",
145
+ is_flag=True,
146
+ help="Enable automatic upgrades",
147
+ )
148
+ @click.option(
149
+ "--set-auto-upgrade-disabled",
150
+ is_flag=True,
151
+ help="Disable automatic upgrades",
152
+ )
153
+ @click.option(
154
+ "--set-base-api-url-override",
155
+ required=False,
156
+ hidden=True,
157
+ help="Override base API URL",
158
+ )
159
+ @click.option(
160
+ "--clear-base-api-url-override",
161
+ is_flag=True,
162
+ hidden=True,
163
+ help="Clear base API URL override",
164
+ )
165
+ @click.option(
166
+ "--set-base-ws-url-override",
167
+ required=False,
168
+ hidden=True,
169
+ help="Override base WS URL",
170
+ )
171
+ @click.option(
172
+ "--clear-base-ws-url-override",
173
+ is_flag=True,
174
+ hidden=True,
175
+ help="Clear base WS URL override",
176
+ )
177
+ @click.option(
178
+ "--set-use-default-colors",
179
+ is_flag=True,
180
+ help="Use default colors",
181
+ )
182
+ @click.option(
183
+ "--clear-use-default-colors",
184
+ is_flag=True,
185
+ help="Clear use default colors",
186
+ )
187
+ @use_settings
188
+ def config(
189
+ settings: Settings,
190
+ set_git_warning_disabled: bool,
191
+ set_git_warning_enabled: bool,
192
+ set_auto_upgrade_enabled: bool,
193
+ set_auto_upgrade_disabled: bool,
194
+ clear_base_api_url_override: bool,
195
+ clear_base_ws_url_override: bool,
196
+ set_use_default_colors: bool,
197
+ clear_use_default_colors: bool,
198
+ set_base_api_url_override: str | None = None,
199
+ set_base_ws_url_override: str | None = None,
200
+ ) -> None:
201
+ """Display current Exponent configuration."""
202
+
203
+ num_options_set = sum(
204
+ [
205
+ set_git_warning_disabled,
206
+ set_git_warning_enabled,
207
+ set_auto_upgrade_enabled,
208
+ set_auto_upgrade_disabled,
209
+ clear_base_ws_url_override,
210
+ clear_base_api_url_override,
211
+ set_base_api_url_override is not None,
212
+ set_base_ws_url_override is not None,
213
+ set_use_default_colors,
214
+ clear_use_default_colors,
215
+ ]
216
+ )
217
+ if num_options_set == 0:
218
+ click.secho(
219
+ json.dumps(settings.get_config_file_settings(), indent=2),
220
+ fg="green",
221
+ )
222
+ return
223
+
224
+ if num_options_set > 1:
225
+ click.secho("Cannot set multiple options at the same time.", fg="red")
226
+ return
227
+
228
+ if set_git_warning_enabled:
229
+ settings.options.git_warning_disabled = False
230
+ settings.write_settings_to_config_file()
231
+
232
+ click.secho(
233
+ "Git warning enabled. Exponent will now check for a git repository.\n",
234
+ fg="yellow",
235
+ )
236
+
237
+ if set_git_warning_disabled:
238
+ settings.options.git_warning_disabled = True
239
+ settings.write_settings_to_config_file()
240
+
241
+ click.secho(
242
+ "Git warning disabled. Exponent will no longer check for a git repository.\n",
243
+ fg="yellow",
244
+ )
245
+
246
+ if set_auto_upgrade_enabled:
247
+ settings.options.auto_upgrade = True
248
+ settings.write_settings_to_config_file()
249
+
250
+ click.secho(
251
+ "Automatic upgrades enabled. Exponent will now check for updates.\n",
252
+ fg="yellow",
253
+ )
254
+
255
+ if set_auto_upgrade_disabled:
256
+ settings.options.auto_upgrade = False
257
+ settings.write_settings_to_config_file()
258
+
259
+ click.secho(
260
+ "Automatic upgrades disabled. Exponent will no longer check for updates.\n",
261
+ fg="yellow",
262
+ )
263
+
264
+ if clear_base_api_url_override:
265
+ settings.options.base_api_url_override = None
266
+ settings.write_settings_to_config_file()
267
+
268
+ click.secho(
269
+ "API URL override cleared.",
270
+ fg="yellow",
271
+ )
272
+
273
+ if clear_base_ws_url_override:
274
+ settings.options.base_ws_url_override = None
275
+ settings.write_settings_to_config_file()
276
+
277
+ click.secho(
278
+ "WS URL override cleared.",
279
+ fg="yellow",
280
+ )
281
+
282
+ if set_base_api_url_override:
283
+ settings.options.base_api_url_override = set_base_api_url_override
284
+ settings.write_settings_to_config_file()
285
+
286
+ click.secho(
287
+ "API URL override set.",
288
+ fg="yellow",
289
+ )
290
+
291
+ if set_base_ws_url_override:
292
+ settings.options.base_ws_url_override = set_base_ws_url_override
293
+ settings.write_settings_to_config_file()
294
+
295
+ click.secho(
296
+ "WS URL override set.",
297
+ fg="yellow",
298
+ )
299
+
300
+ if set_use_default_colors:
301
+ settings.options.use_default_colors = True
302
+ settings.write_settings_to_config_file()
303
+
304
+ click.secho(
305
+ "Use default colors set.",
306
+ fg="yellow",
307
+ )
308
+
309
+ if clear_use_default_colors:
310
+ settings.options.use_default_colors = False
311
+ settings.write_settings_to_config_file()
312
+
313
+
314
+ @config_cli.command()
315
+ @click.option("--key", help="Your Exponent API Key")
316
+ @use_settings
317
+ def login(settings: Settings, key: str) -> None:
318
+ """Log in to Exponent."""
319
+
320
+ if not key:
321
+ redirect_to_login(settings, "provided")
322
+ return
323
+
324
+ click.echo("Verifying API key...")
325
+ run_until_complete(
326
+ set_login_complete(key, settings.get_base_api_url(), settings.get_base_ws_url())
327
+ )
328
+ click.secho("Success!", fg="green")
329
+
330
+ click.echo(f"Saving API Key to {settings.config_file_path}")
331
+
332
+ if settings.api_key and settings.api_key != key:
333
+ click.confirm("Detected existing API Key, continue? ", default=True, abort=True)
334
+
335
+ settings.update_api_key(key)
336
+ settings.write_settings_to_config_file()
337
+
338
+ click.echo("API Key saved.")
339
+
340
+
341
+ @config_cli.command(hidden=True)
342
+ @use_settings
343
+ def get_chats(
344
+ settings: Settings,
345
+ ) -> None:
346
+ if not settings.api_key:
347
+ redirect_to_login(settings)
348
+ return
349
+
350
+ run_until_complete(
351
+ get_chats_task(
352
+ api_key=settings.api_key,
353
+ base_api_url=settings.get_base_api_url(),
354
+ base_ws_url=settings.get_base_ws_url(),
355
+ )
356
+ )
357
+
358
+
359
+ @config_cli.command(hidden=True)
360
+ @use_settings
361
+ def get_authenticated_user(
362
+ settings: Settings,
363
+ ) -> None:
364
+ if not settings.api_key:
365
+ redirect_to_login(settings)
366
+ return
367
+
368
+ run_until_complete(
369
+ get_authenticated_user_task(
370
+ api_key=settings.api_key,
371
+ base_api_url=settings.get_base_api_url(),
372
+ base_ws_url=settings.get_base_ws_url(),
373
+ )
374
+ )
375
+
376
+
377
+ async def get_chats_task(
378
+ api_key: str,
379
+ base_api_url: str,
380
+ base_ws_url: str,
381
+ ) -> None:
382
+ graphql_client = GraphQLClient(api_key, base_api_url, base_ws_url)
383
+ result = await graphql_client.execute(GET_CHATS_QUERY)
384
+ click.echo(result)
385
+
386
+
387
+ async def get_authenticated_user_task(
388
+ api_key: str,
389
+ base_api_url: str,
390
+ base_ws_url: str,
391
+ ) -> None:
392
+ graphql_client = GraphQLClient(api_key, base_api_url, base_ws_url)
393
+ async for it in graphql_client.subscribe(AUTHENTICATED_USER_SUBSCRIPTION):
394
+ click.echo(it)
395
+
396
+
397
+ @config_cli.command(hidden=True)
398
+ @use_settings
399
+ def get_cloud_configs(
400
+ settings: Settings,
401
+ ) -> None:
402
+ if not settings.api_key:
403
+ redirect_to_login(settings)
404
+ return
405
+
406
+ run_until_complete(
407
+ get_cloud_configs_task(
408
+ api_key=settings.api_key,
409
+ base_api_url=settings.get_base_api_url(),
410
+ base_ws_url=settings.get_base_ws_url(),
411
+ )
412
+ )
413
+
414
+
415
+ async def get_cloud_configs_task(
416
+ api_key: str,
417
+ base_api_url: str,
418
+ base_ws_url: str,
419
+ ) -> None:
420
+ graphql_client = GraphQLClient(api_key, base_api_url, base_ws_url)
421
+ result = await graphql_client.execute(GET_CLOUD_CONFIGS_QUERY)
422
+ click.echo(result)
423
+
424
+
425
+ async def create_github_config_task(
426
+ api_key: str,
427
+ base_api_url: str,
428
+ base_ws_url: str,
429
+ github_pat: str,
430
+ ) -> None:
431
+ graphql_client = GraphQLClient(api_key, base_api_url, base_ws_url)
432
+ variables = {
433
+ "githubPat": github_pat,
434
+ }
435
+ result = await graphql_client.execute(CREATE_GITHUB_CONFIG_MUTATION, variables)
436
+ click.echo(result)
437
+
438
+
439
+ @config_cli.command(hidden=True)
440
+ @click.option("--github-pat", required=True, help="Github personal access token")
441
+ @use_settings
442
+ def create_github_config(
443
+ settings: Settings,
444
+ github_pat: str,
445
+ ) -> None:
446
+ if not settings.api_key:
447
+ redirect_to_login(settings)
448
+ return
449
+
450
+ run_until_complete(
451
+ create_github_config_task(
452
+ api_key=settings.api_key,
453
+ base_api_url=settings.get_base_api_url(),
454
+ base_ws_url=settings.get_base_ws_url(),
455
+ github_pat=github_pat,
456
+ )
457
+ )
458
+
459
+
460
+ @config_cli.command(hidden=True)
461
+ @click.option("--github-org-name", required=True, help="GitHub organization name")
462
+ @click.option("--github-repo-name", required=True, help="GitHub repository name")
463
+ @click.option(
464
+ "--setup_commands",
465
+ required=False,
466
+ help="List of commands to set up and build your repo",
467
+ multiple=True,
468
+ )
469
+ @use_settings
470
+ def create_cloud_config(
471
+ settings: Settings,
472
+ github_org_name: str,
473
+ github_repo_name: str,
474
+ setup_commands: list[str] | None = None,
475
+ ) -> None:
476
+ if not settings.api_key:
477
+ redirect_to_login(settings)
478
+ return
479
+
480
+ run_until_complete(
481
+ create_cloud_config_task(
482
+ api_key=settings.api_key,
483
+ base_api_url=settings.get_base_api_url(),
484
+ base_ws_url=settings.get_base_ws_url(),
485
+ github_org_name=github_org_name,
486
+ github_repo_name=github_repo_name,
487
+ setup_commands=setup_commands,
488
+ )
489
+ )
490
+
491
+
492
+ async def create_cloud_config_task(
493
+ api_key: str,
494
+ base_api_url: str,
495
+ base_ws_url: str,
496
+ github_org_name: str,
497
+ github_repo_name: str,
498
+ setup_commands: list[str] | None,
499
+ ) -> None:
500
+ graphql_client = GraphQLClient(api_key, base_api_url, base_ws_url)
501
+ variables = {
502
+ "githubOrgName": github_org_name,
503
+ "githubRepoName": github_repo_name,
504
+ "setupCommands": setup_commands,
505
+ }
506
+ result = await graphql_client.execute(CREATE_CLOUD_CONFIG_MUTATION, variables)
507
+ click.echo(result)
508
+
509
+
510
+ @config_cli.command(hidden=True)
511
+ @click.option("--cloud-config-uuid", required=True, help="Cloud config UUID")
512
+ @click.option("--github-org-name", required=True, help="GitHub organization name")
513
+ @click.option("--github-repo-name", required=True, help="GitHub repository name")
514
+ @click.option(
515
+ "--setup_commands",
516
+ required=False,
517
+ help="List of commands to set up and build your repo",
518
+ multiple=True,
519
+ )
520
+ @use_settings
521
+ def update_cloud_config(
522
+ settings: Settings,
523
+ cloud_config_uuid: str,
524
+ github_org_name: str,
525
+ github_repo_name: str,
526
+ setup_commands: list[str] | None = None,
527
+ ) -> None:
528
+ if not settings.api_key:
529
+ redirect_to_login(settings)
530
+ return
531
+
532
+ run_until_complete(
533
+ update_cloud_config_task(
534
+ api_key=settings.api_key,
535
+ base_api_url=settings.get_base_api_url(),
536
+ base_ws_url=settings.get_base_ws_url(),
537
+ cloud_config_uuid=cloud_config_uuid,
538
+ github_org_name=github_org_name,
539
+ github_repo_name=github_repo_name,
540
+ setup_commands=setup_commands,
541
+ )
542
+ )
543
+
544
+
545
+ async def update_cloud_config_task(
546
+ api_key: str,
547
+ base_api_url: str,
548
+ base_ws_url: str,
549
+ cloud_config_uuid: str,
550
+ github_org_name: str,
551
+ github_repo_name: str,
552
+ setup_commands: list[str] | None,
553
+ ) -> None:
554
+ graphql_client = GraphQLClient(api_key, base_api_url, base_ws_url)
555
+ variables = {
556
+ "cloudConfigUuid": cloud_config_uuid,
557
+ "githubOrgName": github_org_name,
558
+ "githubRepoName": github_repo_name,
559
+ "setupCommands": setup_commands,
560
+ }
561
+
562
+ result = await graphql_client.execute(UPDATE_CLOUD_CONFIG_MUTATION, variables)
563
+ click.echo(result)
564
+
565
+
566
+ @config_cli.command(hidden=True)
567
+ @use_settings
568
+ def refresh_key(settings: Settings) -> None:
569
+ """Refresh your API key."""
570
+ if not settings.api_key:
571
+ redirect_to_login(settings)
572
+ return
573
+
574
+ click.echo("Refreshing API key...")
575
+ run_until_complete(
576
+ refresh_api_key_task(
577
+ api_key=settings.api_key,
578
+ base_api_url=settings.get_base_api_url(),
579
+ base_ws_url=settings.get_base_ws_url(),
580
+ )
581
+ )