runtime-sdk 0.4.49__py3-none-win_amd64.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.
@@ -0,0 +1,348 @@
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+
5
+ from runtime_sdk import output as cli_output
6
+
7
+
8
+ _COMPLETION_BASH = r"""# bash completion for runtime
9
+ _runtime_complete() {
10
+ local cur sub
11
+ COMPREPLY=()
12
+ cur="${COMP_WORDS[COMP_CWORD]}"
13
+ if [[ ${COMP_CWORD} -eq 1 ]]; then
14
+ COMPREPLY=( $(compgen -W "create list ls info url start enter ssh run exec files fs file publish delete rm share network service goal proxy switch checkout github integrate secrets codex claude grok xai api-keys login whoami logout completion help" -- "$cur") )
15
+ return
16
+ fi
17
+ sub="${COMP_WORDS[1]}"
18
+ case "$sub" in
19
+ list|ls)
20
+ COMPREPLY=( $(compgen -W "--json --watch -w" -- "$cur") )
21
+ ;;
22
+ info|url|start|enter|ssh|run|exec|publish|delete|rm)
23
+ local ids
24
+ ids=$(runtime _slugs 2>/dev/null)
25
+ COMPREPLY=( $(compgen -W "$ids" -- "$cur") )
26
+ ;;
27
+ files|fs|file)
28
+ if [[ ${COMP_CWORD} -eq 2 ]]; then
29
+ COMPREPLY=( $(compgen -W "read write list ls stat mkdir rm delete upload download" -- "$cur") )
30
+ else
31
+ local ids
32
+ ids=$(runtime _slugs 2>/dev/null)
33
+ COMPREPLY=( $(compgen -W "$ids" -- "$cur") )
34
+ fi
35
+ ;;
36
+ service)
37
+ if [[ ${COMP_CWORD} -eq 2 ]]; then
38
+ COMPREPLY=( $(compgen -W "run show status logs restart stop clear" -- "$cur") )
39
+ else
40
+ local ids
41
+ ids=$(runtime _slugs 2>/dev/null)
42
+ COMPREPLY=( $(compgen -W "$ids" -- "$cur") )
43
+ fi
44
+ ;;
45
+ goal)
46
+ if [[ ${COMP_CWORD} -eq 2 ]]; then
47
+ COMPREPLY=( $(compgen -W "watch" -- "$cur") )
48
+ else
49
+ local ids
50
+ ids=$(runtime _slugs 2>/dev/null)
51
+ COMPREPLY=( $(compgen -W "$ids" -- "$cur") )
52
+ fi
53
+ ;;
54
+ proxy)
55
+ COMPREPLY=( $(compgen -W "start ls stop" -- "$cur") )
56
+ ;;
57
+ github)
58
+ COMPREPLY=( $(compgen -W "list ls disconnect rm" -- "$cur") )
59
+ ;;
60
+ api-keys)
61
+ COMPREPLY=( $(compgen -W "list ls create revoke" -- "$cur") )
62
+ ;;
63
+ secrets)
64
+ COMPREPLY=( $(compgen -W "list ls show set import delete rm" -- "$cur") )
65
+ ;;
66
+ integrate)
67
+ COMPREPLY=( $(compgen -W "github" -- "$cur") )
68
+ ;;
69
+ completion)
70
+ COMPREPLY=( $(compgen -W "bash zsh fish powershell" -- "$cur") )
71
+ ;;
72
+ codex)
73
+ COMPREPLY=( $(compgen -W "login status logout" -- "$cur") )
74
+ ;;
75
+ claude)
76
+ COMPREPLY=( $(compgen -W "login status logout" -- "$cur") )
77
+ ;;
78
+ grok)
79
+ COMPREPLY=( $(compgen -W "login status logout" -- "$cur") )
80
+ ;;
81
+ xai)
82
+ COMPREPLY=( $(compgen -W "login status logout" -- "$cur") )
83
+ ;;
84
+ share)
85
+ if [[ ${COMP_CWORD} -eq 2 ]]; then
86
+ COMPREPLY=( $(compgen -W "public private" -- "$cur") )
87
+ else
88
+ local ids
89
+ ids=$(runtime _slugs 2>/dev/null)
90
+ COMPREPLY=( $(compgen -W "$ids" -- "$cur") )
91
+ fi
92
+ ;;
93
+ network)
94
+ if [[ ${COMP_CWORD} -eq 2 ]]; then
95
+ COMPREPLY=( $(compgen -W "default show set denials" -- "$cur") )
96
+ fi
97
+ ;;
98
+ esac
99
+ }
100
+ complete -F _runtime_complete runtime
101
+ """
102
+
103
+
104
+ _COMPLETION_ZSH = r"""#compdef runtime
105
+ _runtime() {
106
+ local -a _runtime_commands
107
+ _runtime_commands=(
108
+ 'create:Create a new computer'
109
+ 'list:List computers'
110
+ 'ls:List computers'
111
+ 'info:Show details'
112
+ 'url:Show public URL'
113
+ 'start:Wake a cold computer'
114
+ 'enter:Enter console'
115
+ 'ssh:SSH through Runtime'
116
+ 'run:Run a command'
117
+ 'exec:Stream a command'
118
+ 'files:Manage files'
119
+ 'fs:Manage files'
120
+ 'file:Manage files'
121
+ 'publish:Publish a port'
122
+ 'delete:Delete a computer'
123
+ 'rm:Delete a computer'
124
+ 'share:Set visibility'
125
+ 'network:Manage outbound network access'
126
+ 'service:Service config'
127
+ 'goal:Watch goal runs'
128
+ 'proxy:Port proxies'
129
+ 'switch:Open a GitHub branch workspace'
130
+ 'checkout:Open a GitHub branch workspace'
131
+ 'github:GitHub connections'
132
+ 'integrate:Connect GitHub'
133
+ 'secrets:Secret sets'
134
+ 'codex:Codex login'
135
+ 'claude:Claude login'
136
+ 'grok:Grok login'
137
+ 'xai:xAI login'
138
+ 'api-keys:API keys'
139
+ 'login:Sign in with WorkOS'
140
+ 'whoami:Show account'
141
+ 'logout:Log out'
142
+ 'completion:Shell completion'
143
+ 'help:Extended help'
144
+ )
145
+ local state
146
+ _arguments -C '1: :->cmd' '*:: :->args'
147
+ case $state in
148
+ cmd)
149
+ _describe -t commands 'runtime command' _runtime_commands
150
+ ;;
151
+ args)
152
+ case ${words[1]} in
153
+ list|ls)
154
+ _arguments '--json[write machine-readable JSON]' '-w[refresh every N seconds]' '--watch[refresh every N seconds]'
155
+ ;;
156
+ info|url|start|enter|ssh|run|exec|publish|delete|rm)
157
+ local -a ids
158
+ ids=(${(f)"$(runtime _slugs 2>/dev/null)"})
159
+ _describe -t slugs 'computer' ids
160
+ ;;
161
+ files|fs|file)
162
+ if (( CURRENT == 2 )); then
163
+ _values 'file action' read write list ls stat mkdir rm delete upload download
164
+ else
165
+ local -a ids
166
+ ids=(${(f)"$(runtime _slugs 2>/dev/null)"})
167
+ _describe -t slugs 'computer' ids
168
+ fi
169
+ ;;
170
+ service)
171
+ if (( CURRENT == 2 )); then
172
+ _values 'service action' run show status logs restart stop clear
173
+ else
174
+ local -a ids
175
+ ids=(${(f)"$(runtime _slugs 2>/dev/null)"})
176
+ _describe -t slugs 'computer' ids
177
+ fi
178
+ ;;
179
+ goal)
180
+ if (( CURRENT == 2 )); then
181
+ _values 'goal action' watch
182
+ else
183
+ local -a ids
184
+ ids=(${(f)"$(runtime _slugs 2>/dev/null)"})
185
+ _describe -t slugs 'computer' ids
186
+ fi
187
+ ;;
188
+ proxy)
189
+ _values 'proxy action' start ls stop
190
+ ;;
191
+ github)
192
+ _values 'github action' list ls disconnect rm
193
+ ;;
194
+ api-keys)
195
+ _values 'api key action' list ls create revoke
196
+ ;;
197
+ secrets)
198
+ _values 'secret action' list ls show set import delete rm
199
+ ;;
200
+ integrate)
201
+ _values 'provider' github
202
+ ;;
203
+ share)
204
+ if (( CURRENT == 2 )); then
205
+ _values 'visibility' public private
206
+ else
207
+ local -a ids
208
+ ids=(${(f)"$(runtime _slugs 2>/dev/null)"})
209
+ _describe -t slugs 'computer' ids
210
+ fi
211
+ ;;
212
+ network)
213
+ _values 'network action' default show set denials
214
+ ;;
215
+ completion)
216
+ _values 'shell' bash zsh fish powershell
217
+ ;;
218
+ codex)
219
+ _values 'codex action' login status logout
220
+ ;;
221
+ claude)
222
+ _values 'claude action' login status logout
223
+ ;;
224
+ grok)
225
+ _values 'grok action' login status logout
226
+ ;;
227
+ xai)
228
+ _values 'xai action' login status logout
229
+ ;;
230
+ esac
231
+ ;;
232
+ esac
233
+ }
234
+ _runtime "$@"
235
+ """
236
+
237
+
238
+ _COMPLETION_FISH = r"""# fish completion for runtime
239
+ function __runtime_slugs
240
+ runtime _slugs 2>/dev/null
241
+ end
242
+
243
+ function __runtime_is_command
244
+ set -l tokens (commandline -opc)
245
+ test (count $tokens) -ge 2; and contains -- $tokens[2] $argv
246
+ end
247
+
248
+ complete -c runtime -f
249
+ complete -c runtime -n '__fish_use_subcommand' -a create -d 'Create'
250
+ complete -c runtime -n '__fish_use_subcommand' -a list -d 'List'
251
+ complete -c runtime -n '__fish_use_subcommand' -a ls -d 'List'
252
+ complete -c runtime -n '__fish_use_subcommand' -a info -d 'Show details'
253
+ complete -c runtime -n '__fish_use_subcommand' -a url -d 'Show URL'
254
+ complete -c runtime -n '__fish_use_subcommand' -a start -d 'Wake'
255
+ complete -c runtime -n '__fish_use_subcommand' -a enter -d 'Console'
256
+ complete -c runtime -n '__fish_use_subcommand' -a ssh -d 'SSH'
257
+ complete -c runtime -n '__fish_use_subcommand' -a run -d 'Run command'
258
+ complete -c runtime -n '__fish_use_subcommand' -a exec -d 'Stream command'
259
+ complete -c runtime -n '__fish_use_subcommand' -a files -d 'Manage files'
260
+ complete -c runtime -n '__fish_use_subcommand' -a fs -d 'Manage files'
261
+ complete -c runtime -n '__fish_use_subcommand' -a file -d 'Manage files'
262
+ complete -c runtime -n '__fish_use_subcommand' -a publish -d 'Publish port'
263
+ complete -c runtime -n '__fish_use_subcommand' -a delete -d 'Delete'
264
+ complete -c runtime -n '__fish_use_subcommand' -a rm -d 'Delete'
265
+ complete -c runtime -n '__fish_use_subcommand' -a share -d 'Set visibility'
266
+ complete -c runtime -n '__fish_use_subcommand' -a network -d 'Manage outbound network access'
267
+ complete -c runtime -n '__fish_use_subcommand' -a service -d 'Service config'
268
+ complete -c runtime -n '__fish_use_subcommand' -a goal -d 'Watch goal runs'
269
+ complete -c runtime -n '__fish_use_subcommand' -a proxy -d 'Port proxies'
270
+ complete -c runtime -n '__fish_use_subcommand' -a switch -d 'Open branch workspace'
271
+ complete -c runtime -n '__fish_use_subcommand' -a checkout -d 'Open branch workspace'
272
+ complete -c runtime -n '__fish_use_subcommand' -a github -d 'GitHub connections'
273
+ complete -c runtime -n '__fish_use_subcommand' -a integrate -d 'Connect GitHub'
274
+ complete -c runtime -n '__fish_use_subcommand' -a secrets -d 'Secret sets'
275
+ complete -c runtime -n '__fish_use_subcommand' -a codex -d 'Codex login'
276
+ complete -c runtime -n '__fish_use_subcommand' -a claude -d 'Claude login'
277
+ complete -c runtime -n '__fish_use_subcommand' -a grok -d 'Grok login'
278
+ complete -c runtime -n '__fish_use_subcommand' -a xai -d 'xAI login'
279
+ complete -c runtime -n '__fish_use_subcommand' -a api-keys -d 'API keys'
280
+ complete -c runtime -n '__fish_use_subcommand' -a login -d 'Sign in with WorkOS'
281
+ complete -c runtime -n '__fish_use_subcommand' -a whoami -d 'Show account'
282
+ complete -c runtime -n '__fish_use_subcommand' -a logout -d 'Log out'
283
+ complete -c runtime -n '__fish_use_subcommand' -a help -d 'Extended help'
284
+ complete -c runtime -n '__fish_use_subcommand' -a completion -d 'Completion'
285
+
286
+ complete -c runtime -n '__runtime_is_command info url start enter ssh run exec publish delete rm' -a '(__runtime_slugs)'
287
+ complete -c runtime -n '__runtime_is_command list ls' -l json -d 'Write machine-readable JSON'
288
+ complete -c runtime -n '__runtime_is_command list ls' -s w -l watch -d 'Refresh every N seconds'
289
+ complete -c runtime -n '__runtime_is_command files fs file; and not __fish_seen_subcommand_from read write list ls stat mkdir rm delete upload download' -a 'read write list ls stat mkdir rm delete upload download'
290
+ complete -c runtime -n '__runtime_is_command service; and not __fish_seen_subcommand_from run show status logs restart stop clear' -a 'run show status logs restart stop clear'
291
+ complete -c runtime -n '__runtime_is_command goal; and not __fish_seen_subcommand_from watch' -a watch
292
+ complete -c runtime -n '__runtime_is_command proxy; and not __fish_seen_subcommand_from start ls stop' -a 'start ls stop'
293
+ complete -c runtime -n '__runtime_is_command github; and not __fish_seen_subcommand_from list ls disconnect rm' -a 'list ls disconnect rm'
294
+ complete -c runtime -n '__runtime_is_command api-keys; and not __fish_seen_subcommand_from list ls create revoke' -a 'list ls create revoke'
295
+ complete -c runtime -n '__runtime_is_command secrets; and not __fish_seen_subcommand_from list ls show set import delete rm' -a 'list ls show set import delete rm'
296
+ complete -c runtime -n '__runtime_is_command integrate' -a github
297
+ complete -c runtime -n '__fish_seen_subcommand_from completion' -a 'bash zsh fish powershell'
298
+ complete -c runtime -n '__fish_seen_subcommand_from share' -a 'public private'
299
+ complete -c runtime -n '__runtime_is_command network; and not __fish_seen_subcommand_from default show set denials' -a 'default show set denials'
300
+ complete -c runtime -n '__fish_seen_subcommand_from codex' -a 'login status logout'
301
+ complete -c runtime -n '__fish_seen_subcommand_from claude' -a 'login status logout'
302
+ complete -c runtime -n '__fish_seen_subcommand_from grok' -a 'login status logout'
303
+ complete -c runtime -n '__fish_seen_subcommand_from xai' -a 'login status logout'
304
+ """
305
+
306
+
307
+ _COMPLETION_POWERSHELL = r"""Register-ArgumentCompleter -Native -CommandName runtime -ScriptBlock {
308
+ param($wordToComplete, $commandAst, $cursorPosition)
309
+ $commands = 'create list ls info url start enter ssh run exec files fs file publish delete rm share network service goal proxy switch checkout github integrate secrets codex claude grok xai api-keys login whoami logout completion help'
310
+ $tokens = @($commandAst.CommandElements | ForEach-Object { $_.ToString() })
311
+ if ($tokens.Count -le 2) {
312
+ $candidates = $commands -split ' '
313
+ } else {
314
+ $candidates = switch ($tokens[1]) {
315
+ { $_ -in 'list', 'ls' } { '--json --watch -w' -split ' ' }
316
+ 'service' { 'run show status logs restart stop clear' -split ' ' }
317
+ 'network' { 'default show set denials' -split ' ' }
318
+ 'goal' { 'watch' }
319
+ 'proxy' { 'start ls stop' -split ' ' }
320
+ 'github' { 'list ls disconnect rm' -split ' ' }
321
+ 'api-keys' { 'list ls create revoke' -split ' ' }
322
+ 'secrets' { 'list ls show set import delete rm' -split ' ' }
323
+ 'integrate' { 'github' }
324
+ 'share' { 'public private' -split ' ' }
325
+ 'completion' { 'bash zsh fish powershell' -split ' ' }
326
+ { $_ -in 'codex', 'claude', 'grok', 'xai' } { 'login status logout' -split ' ' }
327
+ default { @() }
328
+ }
329
+ }
330
+ $candidates | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
331
+ [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
332
+ }
333
+ }
334
+ """
335
+
336
+
337
+ def handle_completion(shell: str) -> int:
338
+ scripts = {
339
+ "bash": _COMPLETION_BASH,
340
+ "zsh": _COMPLETION_ZSH,
341
+ "fish": _COMPLETION_FISH,
342
+ "powershell": _COMPLETION_POWERSHELL,
343
+ }
344
+ script = scripts.get(shell)
345
+ if script is None:
346
+ return cli_output.report_error(f"unsupported shell: {shell}")
347
+ sys.stdout.write(script)
348
+ return 0