|
366 | 366 | [nil "--url OPENAI_COMPATIBLE_ENDPOINT" "OpenAI compatible endpoint url"] |
367 | 367 | ;; required if not using positional args |
368 | 368 | [nil "--user USER" "The hub user"] |
369 | | - ;; required if not using positional args |
| 369 | + ;; optional |
| 370 | + [nil "--pat PAT" "personal access token"] |
370 | 371 | ;; can not validate this without a host helper |
371 | 372 | [nil "--host-dir DIR" "Project directory (on host filesystem)"] |
372 | 373 | ;; required if not using positional args |
|
426 | 427 | (s/def ::platform (fn [s] (#{:darwin :linux :windows} (keyword (string/lower-case s))))) |
427 | 428 | (s/def ::user string?) |
428 | 429 | (s/def ::jwt string?) |
| 430 | +(s/def ::pat string?) |
429 | 431 | (s/def ::prompts #(fs/exists? %)) |
430 | 432 | (s/def ::host-dir string?) |
431 | 433 | (s/def ::offline boolean?) |
432 | 434 | (s/def ::thread-id string?) |
433 | 435 | (s/def ::save-thread-volume boolean?) |
434 | 436 | (s/def ::url string?) |
435 | 437 | (s/def ::run-args (s/keys :req-un [::platform ::prompts ::host-dir] |
436 | | - :opt-un [::offline ::thread-id ::save-thread-volume ::user ::jwt ::url])) |
| 438 | + :opt-un [::offline ::thread-id ::save-thread-volume ::user ::pat ::jwt ::url])) |
437 | 439 |
|
438 | 440 | (defn validate [k] |
439 | 441 | (fn [opts] |
|
454 | 456 | (git/prompt-file dir-or-ref))})))) |
455 | 457 |
|
456 | 458 | (defn login-info [] |
457 | | - (if-let [{:keys [token id]} (docker/get-login-info-from-desktop-backend)] |
458 | | - {:jwt token |
459 | | - :user id} |
460 | | - (warn "Docker Desktop not logged in" {}))) |
| 459 | + (if-let [{:keys [token id is-logged-in?]} (docker/get-login-info-from-desktop-backend)] |
| 460 | + (cond |
| 461 | + (and is-logged-in? token id) |
| 462 | + {:jwt token |
| 463 | + :user id} |
| 464 | + is-logged-in? |
| 465 | + (warn "Docker Desktop logged in but creds not available" {}) |
| 466 | + :else |
| 467 | + (warn "Docker Desktop not logged in" {})) |
| 468 | + (warn "unable to check Docker Desktop for login" {}))) |
461 | 469 |
|
462 | 470 | (defn command [opts & [c :as args]] |
463 | 471 | (case c |
|
486 | 494 | (async/<!! ((comp conversation-loop (validate ::run-args)) |
487 | 495 | (-> opts |
488 | 496 | (assoc :thread-id thread-id) |
489 | | - ((fn [opts] (merge |
490 | | - (apply merge-deprecated opts (rest args)) |
491 | | - (login-info)))))))) |
| 497 | + ((fn [opts] (merge |
| 498 | + (apply merge-deprecated opts (rest args)) |
| 499 | + (login-info)))))))) |
492 | 500 |
|
493 | 501 | opts)) |
494 | 502 | (fn [] |
495 | | - ((comp get-prompts (validate ::run-args)) (merge |
496 | | - (apply merge-deprecated opts args) |
497 | | - (login-info)))))) |
| 503 | + ((comp get-prompts (validate ::run-args)) (merge |
| 504 | + (apply merge-deprecated opts args) |
| 505 | + (login-info)))))) |
498 | 506 |
|
499 | 507 | (defn -main [& args] |
500 | 508 | (try |
|
0 commit comments