From 45d239055c54be56bc6d4961558d340bc5b0b246 Mon Sep 17 00:00:00 2001 From: Harsh panwar Date: Fri, 20 Mar 2026 19:37:31 +0530 Subject: [PATCH 1/6] fix: add --type flag and decode ARGS in start_script --- registry/coder-labs/modules/gemini/README.md | 13 +++++ registry/coder-labs/modules/gemini/main.tf | 51 ++++++++++-------- .../coder-labs/modules/gemini/main.tftest.hcl | 53 +++++++++++++++++++ .../modules/gemini/scripts/start.sh | 17 ++++-- 4 files changed, 109 insertions(+), 25 deletions(-) create mode 100644 registry/coder-labs/modules/gemini/main.tftest.hcl diff --git a/registry/coder-labs/modules/gemini/README.md b/registry/coder-labs/modules/gemini/README.md index d0a113a02..e31028c75 100644 --- a/registry/coder-labs/modules/gemini/README.md +++ b/registry/coder-labs/modules/gemini/README.md @@ -111,6 +111,19 @@ module "gemini" { > [!WARNING] > YOLO mode automatically approves all tool calls without user confirmation. The agent has access to your machine's file system and terminal. Only enable in trusted, isolated environments. +## State Persistence + +AgentAPI can save and restore its conversation state to disk across workspace restarts. This complements `continue` (which resumes the Gemini CLI session) by also preserving the AgentAPI-level context. Enabled by default, requires agentapi >= v0.12.0 (older versions skip it with a warning). + +To disable: + +```tf +module "gemini" { + # ... other config + enable_state_persistence = false +} +``` + ### Using Vertex AI (Enterprise) For enterprise users who prefer Google's Vertex AI platform: diff --git a/registry/coder-labs/modules/gemini/main.tf b/registry/coder-labs/modules/gemini/main.tf index dbc81bc79..4fd74fbf8 100644 --- a/registry/coder-labs/modules/gemini/main.tf +++ b/registry/coder-labs/modules/gemini/main.tf @@ -126,6 +126,12 @@ variable "enable_yolo_mode" { default = false } +# variable "enable_state_persistence" { +# type = bool +# description = "Enable AgentAPI conversation state persistence across restarts." +# default = true +# } + resource "coder_env" "gemini_api_key" { agent_id = var.agent_id name = "GEMINI_API_KEY" @@ -179,21 +185,22 @@ module "agentapi" { source = "registry.coder.com/coder/agentapi/coder" version = "2.0.0" - agent_id = var.agent_id - folder = local.folder - web_app_slug = local.app_slug - web_app_order = var.order - web_app_group = var.group - web_app_icon = var.icon - web_app_display_name = "Gemini" - cli_app_slug = "${local.app_slug}-cli" - cli_app_display_name = "Gemini CLI" - module_dir_name = local.module_dir_name - install_agentapi = var.install_agentapi - agentapi_version = var.agentapi_version - pre_install_script = var.pre_install_script - post_install_script = var.post_install_script - install_script = <<-EOT + agent_id = var.agent_id + folder = local.folder + web_app_slug = local.app_slug + web_app_order = var.order + web_app_group = var.group + web_app_icon = var.icon + web_app_display_name = "Gemini" + cli_app_slug = "${local.app_slug}-cli" + cli_app_display_name = "Gemini CLI" + module_dir_name = local.module_dir_name + install_agentapi = var.install_agentapi + agentapi_version = var.agentapi_version + # enable_state_persistence = var.enable_state_persistence + pre_install_script = var.pre_install_script + post_install_script = var.post_install_script + install_script = <<-EOT #!/bin/bash set -o errexit set -o pipefail @@ -216,13 +223,13 @@ module "agentapi" { echo -n '${base64encode(local.start_script)}' | base64 -d > /tmp/start.sh chmod +x /tmp/start.sh - GEMINI_API_KEY='${var.gemini_api_key}' \ - GOOGLE_API_KEY='${var.gemini_api_key}' \ - GOOGLE_GENAI_USE_VERTEXAI='${var.use_vertexai}' \ - GEMINI_YOLO_MODE='${var.enable_yolo_mode}' \ - GEMINI_MODEL='${var.gemini_model}' \ - GEMINI_START_DIRECTORY='${var.folder}' \ - GEMINI_TASK_PROMPT='${var.task_prompt}' \ + GEMINI_API_KEY='${base64encode(var.gemini_api_key)}' \ + GOOGLE_API_KEY='${base64encode(var.gemini_api_key)}' \ + GOOGLE_GENAI_USE_VERTEXAI='${base64encode(var.use_vertexai)}' \ + GEMINI_YOLO_MODE='${base64encode(var.enable_yolo_mode)}' \ + GEMINI_MODEL='${base64encode(var.gemini_model)}' \ + GEMINI_START_DIRECTORY='${base64encode(var.folder)}' \ + GEMINI_TASK_PROMPT='${base64encode(var.task_prompt)}' \ /tmp/start.sh EOT } diff --git a/registry/coder-labs/modules/gemini/main.tftest.hcl b/registry/coder-labs/modules/gemini/main.tftest.hcl new file mode 100644 index 000000000..e121bdeae --- /dev/null +++ b/registry/coder-labs/modules/gemini/main.tftest.hcl @@ -0,0 +1,53 @@ +run "test_gemini_basic" { + command = plan + + variables { + agent_id = "test-agent-123" + folder = "/home/coder/projects" + } + + assert { + condition = var.agent_id == "test-agent-123" + error_message = "Agent ID variable should be set correctly" + } + + assert { + condition = var.folder == "/home/coder/projects" + error_message = "Folder variable should be set correctly" + } + + assert { + condition = var.install_gemini == true + error_message = "install_gemini should default to true" + } + + assert { + condition = var.install_agentapi == true + error_message = "install_agentapi should default to true" + } + + assert { + condition = var.use_vertexai == false + error_message = "use_vertexai should default to false" + } + + assert { + condition = var.enable_yolo_mode == false + error_message = "enable_yolo_mode should default to false" + } +} + +run "test_gemini_with_api_key" { + command = plan + + variables { + agent_id = "test-agent-456" + folder = "/home/coder/workspace" + gemini_api_key = "test-api-key-123" + } + + assert { + condition = coder_env.gemini_api_key[0].value == "test-api-key-123" + error_message = "Gemini API key value should match the input" + } +} diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh index eed550907..e5236498d 100644 --- a/registry/coder-labs/modules/gemini/scripts/start.sh +++ b/registry/coder-labs/modules/gemini/scripts/start.sh @@ -4,9 +4,19 @@ set -o pipefail source "$HOME"/.bashrc +set -o nounset + +GEMINI_API_KEY=$(echo -n "$GEMINI_API_KEY" | base64 -d) +GOOGLE_API_KEY=$(echo -n "$GOOGLE_API_KEY" | base64 -d) +GOOGLE_GENAI_USE_VERTEXAI=$(echo -n "$GOOGLE_GENAI_USE_VERTEXAI" | base64 -d) +GEMINI_YOLO_MODE=$(echo -n "$GEMINI_YOLO_MODE" | base64 -d) +GEMINI_MODEL=$(echo -n "$GEMINI_MODEL" | base64 -d) +GEMINI_START_DIRECTORY=$(echo -n "$GEMINI_START_DIRECTORY" | base64 -d) +GEMINI_TASK_PROMPT=$(echo -n "$GEMINI_TASK_PROMPT" | base64 -d) + +set +o nounset + command_exists() { - command -v "$1" > /dev/null 2>&1 -} if [ -f "$HOME/.nvm/nvm.sh" ]; then source "$HOME"/.nvm/nvm.sh @@ -68,7 +78,8 @@ if [ -n "$GEMINI_API_KEY" ] || [ -n "$GOOGLE_API_KEY" ]; then fi else printf "No API key provided (neither GEMINI_API_KEY nor GOOGLE_API_KEY)\n" + exit 1 fi -agentapi server --term-width 67 --term-height 1190 -- \ +agentapi server --type gemini --term-width 67 --term-height 1190 -- \ bash -c "$(printf '%q ' gemini "${GEMINI_ARGS[@]}")" From 64fa3e85345ea1e3b7edbce1a3949607b6abae23 Mon Sep 17 00:00:00 2001 From: Harsh panwar Date: Sat, 21 Mar 2026 12:39:45 +0530 Subject: [PATCH 2/6] fix: add nodejs install function --- .../modules/gemini/scripts/install.sh | 38 +++++++++++++++---- .../modules/gemini/scripts/start.sh | 2 + 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/registry/coder-labs/modules/gemini/scripts/install.sh b/registry/coder-labs/modules/gemini/scripts/install.sh index 7b70a6af4..030483aa4 100644 --- a/registry/coder-labs/modules/gemini/scripts/install.sh +++ b/registry/coder-labs/modules/gemini/scripts/install.sh @@ -22,18 +22,42 @@ echo "--------------------------------" set +o nounset function check_dependencies() { - if ! command_exists node; then - printf "Error: Node.js is not installed. Please install Node.js manually or use the pre_install_script to install it.\n" - exit 1 - fi + if ! command_exists npm; then printf "Error: npm is not installed. Please install npm manually or use the pre_install_script to install it.\n" - exit 1 + if ! command_exists node; then + printf "Error: Node.js is not installed. Please install Node.js manually or use the pre_install_script to install it.\n" + install_node + fi fi +} - printf "Node.js version: %s\n" "$(node --version)" - printf "npm version: %s\n" "$(npm --version)" +function install_node() { + if ! command_exists npm; then + printf "npm not found, checking for Node.js installation...\n" + if ! command_exists node; then + printf "Node.js not found, installing Node.js via NVM...\n" + export NVM_DIR="$HOME/.nvm" + if [ ! -d "$NVM_DIR" ]; then + mkdir -p "$NVM_DIR" + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + else + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + fi + + nvm install --lts + nvm use --lts + nvm alias default node + + printf "Node.js installed: %s\n" "$(node --version)" + printf "npm installed: %s\n" "$(npm --version)" + else + printf "Node.js is installed but npm is not available. Please install npm manually.\n" + exit 1 + fi + fi } function install_gemini() { diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh index e5236498d..ec138823f 100644 --- a/registry/coder-labs/modules/gemini/scripts/start.sh +++ b/registry/coder-labs/modules/gemini/scripts/start.sh @@ -17,6 +17,8 @@ GEMINI_TASK_PROMPT=$(echo -n "$GEMINI_TASK_PROMPT" | base64 -d) set +o nounset command_exists() { + command -v "$1" > /dev/null 2>&1 +} if [ -f "$HOME/.nvm/nvm.sh" ]; then source "$HOME"/.nvm/nvm.sh From 886f5564ebac20bd1a2d53b31c1c5a11bb072306 Mon Sep 17 00:00:00 2001 From: Harsh panwar Date: Sun, 22 Mar 2026 10:00:52 +0530 Subject: [PATCH 3/6] feat: add enable_state_persistence field --- registry/coder-labs/modules/gemini/main.tf | 12 ++--- .../coder-labs/modules/gemini/main.tftest.hcl | 31 ++++++++++++- .../modules/gemini/scripts/install.sh | 38 +++------------- .../modules/gemini/scripts/start.sh | 44 +++++++++++-------- 4 files changed, 69 insertions(+), 56 deletions(-) diff --git a/registry/coder-labs/modules/gemini/main.tf b/registry/coder-labs/modules/gemini/main.tf index 4fd74fbf8..1b8d57cf4 100644 --- a/registry/coder-labs/modules/gemini/main.tf +++ b/registry/coder-labs/modules/gemini/main.tf @@ -126,11 +126,11 @@ variable "enable_yolo_mode" { default = false } -# variable "enable_state_persistence" { -# type = bool -# description = "Enable AgentAPI conversation state persistence across restarts." -# default = true -# } +variable "enable_state_persistence" { + type = bool + description = "Enable AgentAPI conversation state persistence across restarts." + default = true +} resource "coder_env" "gemini_api_key" { agent_id = var.agent_id @@ -197,7 +197,7 @@ module "agentapi" { module_dir_name = local.module_dir_name install_agentapi = var.install_agentapi agentapi_version = var.agentapi_version - # enable_state_persistence = var.enable_state_persistence + enable_state_persistence = var.enable_state_persistence pre_install_script = var.pre_install_script post_install_script = var.post_install_script install_script = <<-EOT diff --git a/registry/coder-labs/modules/gemini/main.tftest.hcl b/registry/coder-labs/modules/gemini/main.tftest.hcl index e121bdeae..96b664322 100644 --- a/registry/coder-labs/modules/gemini/main.tftest.hcl +++ b/registry/coder-labs/modules/gemini/main.tftest.hcl @@ -42,7 +42,7 @@ run "test_gemini_with_api_key" { variables { agent_id = "test-agent-456" - folder = "/home/coder/workspace" + folder = "/home/coder" gemini_api_key = "test-api-key-123" } @@ -51,3 +51,32 @@ run "test_gemini_with_api_key" { error_message = "Gemini API key value should match the input" } } + +run "test_enable_state_persistence_default" { + command = plan + + variables { + agent_id = "test-agent" + folder = "/home/coder" + } + + assert { + condition = var.enable_state_persistence == true + error_message = "enable_state_persistence should default to true" + } +} + +run "test_disable_state_persistence" { + command = plan + + variables { + agent_id = "test-agent" + folder = "/home/coder" + enable_state_persistence = false + } + + assert { + condition = var.enable_state_persistence == false + error_message = "enable_state_persistence should be false when explicitly disabled" + } +} \ No newline at end of file diff --git a/registry/coder-labs/modules/gemini/scripts/install.sh b/registry/coder-labs/modules/gemini/scripts/install.sh index 030483aa4..7b70a6af4 100644 --- a/registry/coder-labs/modules/gemini/scripts/install.sh +++ b/registry/coder-labs/modules/gemini/scripts/install.sh @@ -22,42 +22,18 @@ echo "--------------------------------" set +o nounset function check_dependencies() { - + if ! command_exists node; then + printf "Error: Node.js is not installed. Please install Node.js manually or use the pre_install_script to install it.\n" + exit 1 + fi if ! command_exists npm; then printf "Error: npm is not installed. Please install npm manually or use the pre_install_script to install it.\n" - if ! command_exists node; then - printf "Error: Node.js is not installed. Please install Node.js manually or use the pre_install_script to install it.\n" - install_node - fi + exit 1 fi -} -function install_node() { - if ! command_exists npm; then - printf "npm not found, checking for Node.js installation...\n" - if ! command_exists node; then - printf "Node.js not found, installing Node.js via NVM...\n" - export NVM_DIR="$HOME/.nvm" - if [ ! -d "$NVM_DIR" ]; then - mkdir -p "$NVM_DIR" - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - else - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - fi - - nvm install --lts - nvm use --lts - nvm alias default node - - printf "Node.js installed: %s\n" "$(node --version)" - printf "npm installed: %s\n" "$(npm --version)" - else - printf "Node.js is installed but npm is not available. Please install npm manually.\n" - exit 1 - fi - fi + printf "Node.js version: %s\n" "$(node --version)" + printf "npm version: %s\n" "$(npm --version)" } function install_gemini() { diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh index ec138823f..daf5f436d 100644 --- a/registry/coder-labs/modules/gemini/scripts/start.sh +++ b/registry/coder-labs/modules/gemini/scripts/start.sh @@ -56,22 +56,6 @@ else } fi -if [ -n "$GEMINI_TASK_PROMPT" ]; then - printf "Running automated task: %s\n" "$GEMINI_TASK_PROMPT" - PROMPT="Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GEMINI_TASK_PROMPT" - PROMPT_FILE="$MODULE_DIR/prompt.txt" - echo -n "$PROMPT" > "$PROMPT_FILE" - GEMINI_ARGS=(--prompt-interactive "$PROMPT") -else - printf "Starting Gemini CLI in interactive mode.\n" - GEMINI_ARGS=() -fi - -if [ -n "$GEMINI_YOLO_MODE" ] && [ "$GEMINI_YOLO_MODE" = "true" ]; then - printf "YOLO mode enabled - will auto-approve all tool calls\n" - GEMINI_ARGS+=(--yolo) -fi - if [ -n "$GEMINI_API_KEY" ] || [ -n "$GOOGLE_API_KEY" ]; then if [ -n "$GOOGLE_GENAI_USE_VERTEXAI" ] && [ "$GOOGLE_GENAI_USE_VERTEXAI" = "true" ]; then printf "Using Vertex AI with API key\n" @@ -83,5 +67,29 @@ else exit 1 fi -agentapi server --type gemini --term-width 67 --term-height 1190 -- \ - bash -c "$(printf '%q ' gemini "${GEMINI_ARGS[@]}")" +if [ -n "$GEMINI_YOLO_MODE" ] && [ "$GEMINI_YOLO_MODE" = "true" ]; then + printf "YOLO mode enabled - will auto-approve all tool calls\n" + GEMINI_ARGS+=(--yolo) +fi + + +if [ ! -d "$HOME/.gemini/tmp/$GEMINI_START_DIRECTORY/chats/" ]; then + printf "No existing Gemini chats found. Starting Gemini CLI in interactive mode.\n" + if [ -n "$GEMINI_TASK_PROMPT" ]; then + printf "Running automated task: %s\n" "$GEMINI_TASK_PROMPT" + PROMPT="Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GEMINI_TASK_PROMPT" + PROMPT_FILE="$MODULE_DIR/prompt.txt" + echo -n "$PROMPT" > "$PROMPT_FILE" + GEMINI_ARGS=(--prompt-interactive "$PROMPT") + else + printf "Starting Gemini CLI in interactive mode.\n" + GEMINI_ARGS=() + fi + agentapi server --type gemini --term-width 67 --term-height 1190 -- \ + bash -c "$(printf '%q ' gemini "${GEMINI_ARGS[@]}")" +else + printf "Existing Gemini chats detected. Starting Gemini CLI in interactive mode with existing chats.\n" + GEMINI_ARGS=(--resume) + agentapi server --type gemini --term-width 67 --term-height 1190 -- \ + bash -c "$(printf '%q ' gemini "${GEMINI_ARGS[@]}")" +fi \ No newline at end of file From 5a7cfaf0a3a25709a08ce31c4657b2a3ac74f011 Mon Sep 17 00:00:00 2001 From: Harsh panwar Date: Sun, 22 Mar 2026 10:21:05 +0530 Subject: [PATCH 4/6] fix: directory path and typos --- registry/coder-labs/modules/gemini/scripts/start.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh index daf5f436d..12a8f9835 100644 --- a/registry/coder-labs/modules/gemini/scripts/start.sh +++ b/registry/coder-labs/modules/gemini/scripts/start.sh @@ -69,27 +69,28 @@ fi if [ -n "$GEMINI_YOLO_MODE" ] && [ "$GEMINI_YOLO_MODE" = "true" ]; then printf "YOLO mode enabled - will auto-approve all tool calls\n" - GEMINI_ARGS+=(--yolo) + GEMINI_ARGS=(--yolo) fi -if [ ! -d "$HOME/.gemini/tmp/$GEMINI_START_DIRECTORY/chats/" ]; then +SESSION_FOLDER_NAME=$(basename "${GEMINI_START_DIRECTORY}") +if [ ! -d "$GEMINI_START_DIRECTORY/.gemini/tmp/$SESSION_FOLDER_NAME/chats/" ]; then printf "No existing Gemini chats found. Starting Gemini CLI in interactive mode.\n" if [ -n "$GEMINI_TASK_PROMPT" ]; then printf "Running automated task: %s\n" "$GEMINI_TASK_PROMPT" PROMPT="Every step of the way, report tasks to Coder with proper descriptions and statuses. Your task at hand: $GEMINI_TASK_PROMPT" PROMPT_FILE="$MODULE_DIR/prompt.txt" echo -n "$PROMPT" > "$PROMPT_FILE" - GEMINI_ARGS=(--prompt-interactive "$PROMPT") + GEMINI_ARGS+=(--prompt-interactive "$PROMPT") else printf "Starting Gemini CLI in interactive mode.\n" - GEMINI_ARGS=() + GEMINI_ARGS+=() fi agentapi server --type gemini --term-width 67 --term-height 1190 -- \ bash -c "$(printf '%q ' gemini "${GEMINI_ARGS[@]}")" else printf "Existing Gemini chats detected. Starting Gemini CLI in interactive mode with existing chats.\n" - GEMINI_ARGS=(--resume) + GEMINI_ARGS+=(--resume) agentapi server --type gemini --term-width 67 --term-height 1190 -- \ bash -c "$(printf '%q ' gemini "${GEMINI_ARGS[@]}")" fi \ No newline at end of file From 49942005ce5c39df4b59cac0f010278c54e21bff Mon Sep 17 00:00:00 2001 From: Harsh panwar Date: Sun, 22 Mar 2026 10:26:07 +0530 Subject: [PATCH 5/6] fix: style --- registry/coder-labs/modules/gemini/main.tf | 2 +- registry/coder-labs/modules/gemini/scripts/start.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/registry/coder-labs/modules/gemini/main.tf b/registry/coder-labs/modules/gemini/main.tf index 1b8d57cf4..6f38e76c2 100644 --- a/registry/coder-labs/modules/gemini/main.tf +++ b/registry/coder-labs/modules/gemini/main.tf @@ -216,7 +216,7 @@ module "agentapi" { GEMINI_SYSTEM_PROMPT='${base64encode(var.gemini_system_prompt)}' \ /tmp/install.sh EOT - start_script = <<-EOT + start_script = <<-EOT #!/bin/bash set -o errexit set -o pipefail diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh index 12a8f9835..c53511d2f 100644 --- a/registry/coder-labs/modules/gemini/scripts/start.sh +++ b/registry/coder-labs/modules/gemini/scripts/start.sh @@ -72,7 +72,6 @@ if [ -n "$GEMINI_YOLO_MODE" ] && [ "$GEMINI_YOLO_MODE" = "true" ]; then GEMINI_ARGS=(--yolo) fi - SESSION_FOLDER_NAME=$(basename "${GEMINI_START_DIRECTORY}") if [ ! -d "$GEMINI_START_DIRECTORY/.gemini/tmp/$SESSION_FOLDER_NAME/chats/" ]; then printf "No existing Gemini chats found. Starting Gemini CLI in interactive mode.\n" @@ -93,4 +92,4 @@ else GEMINI_ARGS+=(--resume) agentapi server --type gemini --term-width 67 --term-height 1190 -- \ bash -c "$(printf '%q ' gemini "${GEMINI_ARGS[@]}")" -fi \ No newline at end of file +fi From 753e417e051cfb07e59d3ec8d8bfdb2839aede79 Mon Sep 17 00:00:00 2001 From: Harsh panwar Date: Mon, 23 Mar 2026 10:10:37 +0530 Subject: [PATCH 6/6] fix: update the agentapi version and improve script logic --- registry/coder-labs/modules/gemini/main.tf | 4 ++-- registry/coder-labs/modules/gemini/scripts/start.sh | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/registry/coder-labs/modules/gemini/main.tf b/registry/coder-labs/modules/gemini/main.tf index 6f38e76c2..61d33c96e 100644 --- a/registry/coder-labs/modules/gemini/main.tf +++ b/registry/coder-labs/modules/gemini/main.tf @@ -39,7 +39,7 @@ variable "icon" { variable "folder" { type = string description = "The folder to run Gemini in." - default = "/home/coder" + default = "/home/coder/project" } variable "install_gemini" { @@ -183,7 +183,7 @@ EOT module "agentapi" { source = "registry.coder.com/coder/agentapi/coder" - version = "2.0.0" + version = "2.2.0" agent_id = var.agent_id folder = local.folder diff --git a/registry/coder-labs/modules/gemini/scripts/start.sh b/registry/coder-labs/modules/gemini/scripts/start.sh index c53511d2f..e60e18f20 100644 --- a/registry/coder-labs/modules/gemini/scripts/start.sh +++ b/registry/coder-labs/modules/gemini/scripts/start.sh @@ -73,7 +73,12 @@ if [ -n "$GEMINI_YOLO_MODE" ] && [ "$GEMINI_YOLO_MODE" = "true" ]; then fi SESSION_FOLDER_NAME=$(basename "${GEMINI_START_DIRECTORY}") -if [ ! -d "$GEMINI_START_DIRECTORY/.gemini/tmp/$SESSION_FOLDER_NAME/chats/" ]; then +if [ -d "$GEMINI_START_DIRECTORY/.gemini/tmp/$SESSION_FOLDER_NAME/chats/" ]; then + printf "Existing Gemini chats detected. Starting Gemini CLI in interactive mode with existing chats.\n" + GEMINI_ARGS+=(--resume) + agentapi server --type gemini --term-width 67 --term-height 1190 -- \ + bash -c "$(printf '%q ' gemini "${GEMINI_ARGS[@]}")" +else printf "No existing Gemini chats found. Starting Gemini CLI in interactive mode.\n" if [ -n "$GEMINI_TASK_PROMPT" ]; then printf "Running automated task: %s\n" "$GEMINI_TASK_PROMPT" @@ -87,9 +92,4 @@ if [ ! -d "$GEMINI_START_DIRECTORY/.gemini/tmp/$SESSION_FOLDER_NAME/chats/" ]; t fi agentapi server --type gemini --term-width 67 --term-height 1190 -- \ bash -c "$(printf '%q ' gemini "${GEMINI_ARGS[@]}")" -else - printf "Existing Gemini chats detected. Starting Gemini CLI in interactive mode with existing chats.\n" - GEMINI_ARGS+=(--resume) - agentapi server --type gemini --term-width 67 --term-height 1190 -- \ - bash -c "$(printf '%q ' gemini "${GEMINI_ARGS[@]}")" fi