From c61c6fdb26079a90a83593a99bff59d03f53e676 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Wed, 11 Mar 2026 17:16:13 +0530 Subject: [PATCH 01/12] chore: update installation script and bump agentapi version to 2.2.0 --- registry/coder-labs/modules/copilot/main.tf | 2 +- .../modules/copilot/scripts/install.sh | 43 +++---------------- 2 files changed, 7 insertions(+), 38 deletions(-) diff --git a/registry/coder-labs/modules/copilot/main.tf b/registry/coder-labs/modules/copilot/main.tf index 2837961f5..c2ff48aca 100644 --- a/registry/coder-labs/modules/copilot/main.tf +++ b/registry/coder-labs/modules/copilot/main.tf @@ -271,7 +271,7 @@ resource "coder_env" "github_token" { module "agentapi" { source = "registry.coder.com/coder/agentapi/coder" - version = "2.0.0" + version = "2.2.0" agent_id = var.agent_id folder = local.workdir diff --git a/registry/coder-labs/modules/copilot/scripts/install.sh b/registry/coder-labs/modules/copilot/scripts/install.sh index 44c480e3a..ea2d0b86e 100644 --- a/registry/coder-labs/modules/copilot/scripts/install.sh +++ b/registry/coder-labs/modules/copilot/scripts/install.sh @@ -19,31 +19,13 @@ ARG_EXTERNAL_AUTH_ID=${ARG_EXTERNAL_AUTH_ID:-github} ARG_COPILOT_VERSION=${ARG_COPILOT_VERSION:-0.0.334} ARG_COPILOT_MODEL=${ARG_COPILOT_MODEL:-claude-sonnet-4.5} -validate_prerequisites() { - if ! command_exists node; then - echo "ERROR: Node.js not found. Copilot requires Node.js v22+." - echo "Install with: curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && sudo apt-get install -y nodejs" - exit 1 - fi - - if ! command_exists npm; then - echo "ERROR: npm not found. Copilot requires npm v10+." - exit 1 - fi - - node_version=$(node --version | sed 's/v//' | cut -d. -f1) - if [ "$node_version" -lt 22 ]; then - echo "WARNING: Node.js v$node_version detected. Copilot requires v22+." - fi -} - install_copilot() { if ! command_exists copilot; then echo "Installing GitHub Copilot CLI (version: ${ARG_COPILOT_VERSION})..." if [ "$ARG_COPILOT_VERSION" = "latest" ]; then - npm install -g @github/copilot + curl -fsSL https://gh.io/copilot-install | bash else - npm install -g "@github/copilot@${ARG_COPILOT_VERSION}" + VERSION="${ARG_COPILOT_VERSION}" curl -fsSL https://gh.io/copilot-install | bash fi if ! command_exists copilot; then @@ -190,27 +172,15 @@ add_custom_mcp_servers() { local updated_config updated_config=$(jq --argjson custom "$custom_servers" '.mcpServers += $custom' "$mcp_config_file") echo "$updated_config" > "$mcp_config_file" - elif command_exists node; then - node -e " - const fs = require('fs'); - const existing = JSON.parse(fs.readFileSync('$mcp_config_file', 'utf8')); - const input = JSON.parse(\`$ARG_MCP_CONFIG\`); - const custom = input.mcpServers || {}; - existing.mcpServers = {...existing.mcpServers, ...custom}; - fs.writeFileSync('$mcp_config_file', JSON.stringify(existing, null, 2)); - " else - echo "WARNING: jq and node not available, cannot merge custom MCP servers" + echo "WARNING: jq not available, cannot merge custom MCP servers" fi } configure_copilot_model() { - if [ -n "$ARG_COPILOT_MODEL" ] && [ "$ARG_COPILOT_MODEL" != "claude-sonnet-4.5" ]; then - echo "Setting Copilot model to: $ARG_COPILOT_MODEL" - copilot config model "$ARG_COPILOT_MODEL" || { - echo "WARNING: Failed to set model via copilot config, will use environment variable fallback" - export COPILOT_MODEL="$ARG_COPILOT_MODEL" - } + if [[ -n "${ARG_COPILOT_MODEL}" ]]; then + echo "Setting Copilot model to: ${ARG_COPILOT_MODEL}" + export COPILOT_MODEL="${ARG_COPILOT_MODEL}" fi } @@ -227,7 +197,6 @@ configure_coder_integration() { fi } -validate_prerequisites install_copilot check_github_authentication setup_copilot_configurations From 45d3d8ee19ad15a3a9d5ebbf42a89dd4f3facc41 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Wed, 11 Mar 2026 18:46:42 +0530 Subject: [PATCH 02/12] chore: adjust terminal dimensions in start.sh for copilot server --- registry/coder-labs/modules/copilot/scripts/start.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/registry/coder-labs/modules/copilot/scripts/start.sh b/registry/coder-labs/modules/copilot/scripts/start.sh index 0aecb1feb..c7954f75f 100644 --- a/registry/coder-labs/modules/copilot/scripts/start.sh +++ b/registry/coder-labs/modules/copilot/scripts/start.sh @@ -186,16 +186,16 @@ start_agentapi() { echo "Using initial prompt with system context" if [ ${#COPILOT_ARGS[@]} -gt 0 ]; then echo "Copilot arguments: ${COPILOT_ARGS[*]}" - agentapi server -I="$initial_prompt" --type copilot --term-width 120 --term-height 40 -- copilot "${COPILOT_ARGS[@]}" + agentapi server -I="$initial_prompt" --type copilot --term-width 67 --term-height 1190 -- copilot "${COPILOT_ARGS[@]}" else - agentapi server -I="$initial_prompt" --type copilot --term-width 120 --term-height 40 -- copilot + agentapi server -I="$initial_prompt" --type copilot --term-width 67 --term-height 1190 -- copilot fi else if [ ${#COPILOT_ARGS[@]} -gt 0 ]; then echo "Copilot arguments: ${COPILOT_ARGS[*]}" - agentapi server --type copilot --term-width 120 --term-height 40 -- copilot "${COPILOT_ARGS[@]}" + agentapi server --type copilot --term-width 67 --term-height 1190 -- copilot "${COPILOT_ARGS[@]}" else - agentapi server --type copilot --term-width 120 --term-height 40 -- copilot + agentapi server --type copilot --term-width 67 --term-height 1190 -- copilot fi fi fi From b5e79685e61d153aea452b778e9229ff57e2ae22 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Thu, 12 Mar 2026 22:11:54 +0530 Subject: [PATCH 03/12] feat: add allow_all variable to enable all tools without prompting --- registry/coder-labs/modules/copilot/main.tf | 7 ++++++ .../modules/copilot/scripts/start.sh | 25 +++++++++---------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/registry/coder-labs/modules/copilot/main.tf b/registry/coder-labs/modules/copilot/main.tf index c2ff48aca..4604f11a1 100644 --- a/registry/coder-labs/modules/copilot/main.tf +++ b/registry/coder-labs/modules/copilot/main.tf @@ -155,6 +155,12 @@ variable "cli_app_display_name" { default = "Copilot" } +variable "allow_all" { + type = bool + description = "Allow all tools without prompting (equivalent to --allow-all)." + default = true +} + variable "resume_session" { type = bool description = "Whether to automatically resume the latest Copilot session on workspace restart." @@ -299,6 +305,7 @@ module "agentapi" { chmod +x /tmp/start.sh ARG_WORKDIR='${local.workdir}' \ + ARG_ALLOW_ALL='${var.allow_all}' \ ARG_AI_PROMPT='${base64encode(var.ai_prompt)}' \ ARG_SYSTEM_PROMPT='${base64encode(local.final_system_prompt)}' \ ARG_COPILOT_MODEL='${var.copilot_model}' \ diff --git a/registry/coder-labs/modules/copilot/scripts/start.sh b/registry/coder-labs/modules/copilot/scripts/start.sh index c7954f75f..792a8ce2d 100644 --- a/registry/coder-labs/modules/copilot/scripts/start.sh +++ b/registry/coder-labs/modules/copilot/scripts/start.sh @@ -13,6 +13,7 @@ command_exists() { } ARG_WORKDIR=${ARG_WORKDIR:-"$HOME"} +ARG_ALLOW_ALL=${ARG_ALLOW_ALL:-true} ARG_AI_PROMPT=$(echo -n "${ARG_AI_PROMPT:-}" | base64 -d 2> /dev/null || echo "") ARG_SYSTEM_PROMPT=$(echo -n "${ARG_SYSTEM_PROMPT:-}" | base64 -d 2> /dev/null || echo "") ARG_COPILOT_MODEL=${ARG_COPILOT_MODEL:-} @@ -73,6 +74,10 @@ build_copilot_args() { fi done fi + + if [ "$ARG_ALLOW_ALL" = "true" ]; then + COPILOT_ARGS+=(--allow-all) + fi } check_existing_session() { @@ -183,20 +188,14 @@ start_agentapi() { initial_prompt=$(build_initial_prompt) if [ -n "$initial_prompt" ]; then - echo "Using initial prompt with system context" - if [ ${#COPILOT_ARGS[@]} -gt 0 ]; then - echo "Copilot arguments: ${COPILOT_ARGS[*]}" - agentapi server -I="$initial_prompt" --type copilot --term-width 67 --term-height 1190 -- copilot "${COPILOT_ARGS[@]}" - else - agentapi server -I="$initial_prompt" --type copilot --term-width 67 --term-height 1190 -- copilot - fi + COPILOT_ARGS+=(-i "$initial_prompt") + fi + + if [ ${#COPILOT_ARGS[@]} -gt 0 ]; then + echo "Copilot arguments: ${COPILOT_ARGS[*]}" + agentapi server --type copilot --term-width 67 --term-height 1190 -- copilot "${COPILOT_ARGS[@]}" else - if [ ${#COPILOT_ARGS[@]} -gt 0 ]; then - echo "Copilot arguments: ${COPILOT_ARGS[*]}" - agentapi server --type copilot --term-width 67 --term-height 1190 -- copilot "${COPILOT_ARGS[@]}" - else - agentapi server --type copilot --term-width 67 --term-height 1190 -- copilot - fi + agentapi server --type copilot --term-width 67 --term-height 1190 -- copilot fi fi } From d6b490ecb2914703940d3d6d0249a88cd34b85d1 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Thu, 12 Mar 2026 22:34:24 +0530 Subject: [PATCH 04/12] feat: add enable_state_persistence variable and update README for state management --- registry/coder-labs/modules/copilot/README.md | 19 ++++++++++-- .../modules/copilot/copilot.tftest.hcl | 29 +++++++++++++++++++ registry/coder-labs/modules/copilot/main.tf | 17 +++++++---- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/registry/coder-labs/modules/copilot/README.md b/registry/coder-labs/modules/copilot/README.md index 7c0e56935..f67ad5600 100644 --- a/registry/coder-labs/modules/copilot/README.md +++ b/registry/coder-labs/modules/copilot/README.md @@ -13,7 +13,7 @@ Run [GitHub Copilot CLI](https://docs.github.com/copilot/concepts/agents/about-c ```tf module "copilot" { source = "registry.coder.com/coder-labs/copilot/coder" - version = "0.4.0" + version = "0.5.0" agent_id = coder_agent.example.id workdir = "/home/coder/projects" } @@ -51,7 +51,7 @@ data "coder_parameter" "ai_prompt" { module "copilot" { source = "registry.coder.com/coder-labs/copilot/coder" - version = "0.4.0" + version = "0.5.0" agent_id = coder_agent.example.id workdir = "/home/coder/projects" @@ -71,7 +71,7 @@ Customize tool permissions, MCP servers, and Copilot settings: ```tf module "copilot" { source = "registry.coder.com/coder-labs/copilot/coder" - version = "0.4.0" + version = "0.5.0" agent_id = coder_agent.example.id workdir = "/home/coder/projects" @@ -215,6 +215,19 @@ By default, the module resumes the latest Copilot session when the workspace res > [!NOTE] > Session resumption requires persistent storage for the home directory or workspace volume. Without persistent storage, sessions will not resume across workspace restarts. +## State Persistence + +AgentAPI can save and restore its conversation state to disk across workspace restarts. This complements `resume_session` (which resumes the Copilot 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 "copilot" { + # ... other config + enable_state_persistence = false +} +``` + ## Troubleshooting If you encounter any issues, check the log files in the `~/.copilot-module` directory within your workspace for detailed information. diff --git a/registry/coder-labs/modules/copilot/copilot.tftest.hcl b/registry/coder-labs/modules/copilot/copilot.tftest.hcl index 0ff2379a0..9fdf93708 100644 --- a/registry/coder-labs/modules/copilot/copilot.tftest.hcl +++ b/registry/coder-labs/modules/copilot/copilot.tftest.hcl @@ -347,3 +347,32 @@ run "aibridge_proxy_with_copilot_config" { error_message = "copilot_model environment variable should be set alongside proxy" } } + +run "enable_state_persistence_default" { + command = plan + + variables { + agent_id = "test-agent" + workdir = "/home/coder" + } + + assert { + condition = var.enable_state_persistence == true + error_message = "enable_state_persistence should default to true" + } +} + +run "disable_state_persistence" { + command = plan + + variables { + agent_id = "test-agent" + workdir = "/home/coder" + enable_state_persistence = false + } + + assert { + condition = var.enable_state_persistence == false + error_message = "enable_state_persistence should be false when explicitly disabled" + } +} diff --git a/registry/coder-labs/modules/copilot/main.tf b/registry/coder-labs/modules/copilot/main.tf index 4604f11a1..9327fb877 100644 --- a/registry/coder-labs/modules/copilot/main.tf +++ b/registry/coder-labs/modules/copilot/main.tf @@ -119,6 +119,12 @@ variable "subdomain" { default = false } +variable "enable_state_persistence" { + type = bool + description = "Enable AgentAPI conversation state persistence across restarts." + default = true +} + variable "order" { type = number description = "The order determines the position of app in the UI presentation." @@ -291,11 +297,12 @@ module "agentapi" { cli_app_icon = var.cli_app ? var.icon : null cli_app_display_name = var.cli_app ? var.cli_app_display_name : null agentapi_subdomain = var.subdomain - 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 + 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 start_script = <<-EOT #!/bin/bash From 496c29dda76ea899c374bb594155618ef0fac954 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Thu, 12 Mar 2026 22:55:56 +0530 Subject: [PATCH 05/12] chore: add ARG_REPORT_TASKS to start.sh and update initial prompt logic --- registry/coder-labs/modules/copilot/main.tf | 25 ++++++++++--------- .../modules/copilot/scripts/start.sh | 15 ++++++++--- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/registry/coder-labs/modules/copilot/main.tf b/registry/coder-labs/modules/copilot/main.tf index 9327fb877..7a6f73f4e 100644 --- a/registry/coder-labs/modules/copilot/main.tf +++ b/registry/coder-labs/modules/copilot/main.tf @@ -285,18 +285,18 @@ module "agentapi" { source = "registry.coder.com/coder/agentapi/coder" version = "2.2.0" - agent_id = var.agent_id - folder = local.workdir - 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 = var.web_app_display_name - cli_app = var.cli_app - cli_app_slug = var.cli_app ? "${local.app_slug}-cli" : null - cli_app_icon = var.cli_app ? var.icon : null - cli_app_display_name = var.cli_app ? var.cli_app_display_name : null - agentapi_subdomain = var.subdomain + agent_id = var.agent_id + folder = local.workdir + 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 = var.web_app_display_name + cli_app = var.cli_app + cli_app_slug = var.cli_app ? "${local.app_slug}-cli" : null + cli_app_icon = var.cli_app ? var.icon : null + cli_app_display_name = var.cli_app ? var.cli_app_display_name : null + agentapi_subdomain = var.subdomain module_dir_name = local.module_dir_name install_agentapi = var.install_agentapi agentapi_version = var.agentapi_version @@ -322,6 +322,7 @@ module "agentapi" { ARG_TRUSTED_DIRECTORIES='${join(",", var.trusted_directories)}' \ ARG_EXTERNAL_AUTH_ID='${var.external_auth_id}' \ ARG_RESUME_SESSION='${var.resume_session}' \ + ARG_REPORT_TASKS='${var.report_tasks}' \ ARG_ENABLE_AIBRIDGE_PROXY='${var.enable_aibridge_proxy}' \ ARG_AIBRIDGE_PROXY_AUTH_URL='${var.aibridge_proxy_auth_url != null ? var.aibridge_proxy_auth_url : ""}' \ ARG_AIBRIDGE_PROXY_CERT_PATH='${var.aibridge_proxy_cert_path != null ? var.aibridge_proxy_cert_path : ""}' \ diff --git a/registry/coder-labs/modules/copilot/scripts/start.sh b/registry/coder-labs/modules/copilot/scripts/start.sh index 792a8ce2d..c7a1afb3d 100644 --- a/registry/coder-labs/modules/copilot/scripts/start.sh +++ b/registry/coder-labs/modules/copilot/scripts/start.sh @@ -23,27 +23,34 @@ ARG_DENY_TOOLS=${ARG_DENY_TOOLS:-} ARG_TRUSTED_DIRECTORIES=${ARG_TRUSTED_DIRECTORIES:-} ARG_EXTERNAL_AUTH_ID=${ARG_EXTERNAL_AUTH_ID:-github} ARG_RESUME_SESSION=${ARG_RESUME_SESSION:-true} +ARG_REPORT_TASKS=${ARG_REPORT_TASKS:-true} ARG_ENABLE_AIBRIDGE_PROXY=${ARG_ENABLE_AIBRIDGE_PROXY:-false} ARG_AIBRIDGE_PROXY_AUTH_URL=${ARG_AIBRIDGE_PROXY_AUTH_URL:-} ARG_AIBRIDGE_PROXY_CERT_PATH=${ARG_AIBRIDGE_PROXY_CERT_PATH:-} validate_copilot_installation() { if ! command_exists copilot; then - echo "ERROR: Copilot not installed. Run: npm install -g @github/copilot" + echo "ERROR: Copilot not installed or not in PATH. Please ensure Copilot CLI is installed and accessible." exit 1 fi } build_initial_prompt() { local initial_prompt="" + local task_prompt="$ARG_AI_PROMPT" - if [ -n "$ARG_AI_PROMPT" ]; then + # Add task reporting instruction when report_tasks is enabled + if [ -n "$ARG_AI_PROMPT" ] && [ "$ARG_REPORT_TASKS" = "true" ]; then + task_prompt="Every step of the way, report your progress using Coder.coder_report_task tool with proper summary and statuses. Your task at hand: $ARG_AI_PROMPT" + fi + + if [ -n "$task_prompt" ]; then if [ -n "$ARG_SYSTEM_PROMPT" ]; then initial_prompt="$ARG_SYSTEM_PROMPT -$ARG_AI_PROMPT" +$task_prompt" else - initial_prompt="$ARG_AI_PROMPT" + initial_prompt="$task_prompt" fi fi From 9e827d526e87752c888bb654991a3c92a3a000bd Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Fri, 13 Mar 2026 12:57:03 +0530 Subject: [PATCH 06/12] wip --- registry/coder-labs/modules/copilot/main.tf | 1 - .../modules/copilot/scripts/install.sh | 6 +- .../modules/copilot/scripts/start.sh | 55 ++++++------------- 3 files changed, 20 insertions(+), 42 deletions(-) diff --git a/registry/coder-labs/modules/copilot/main.tf b/registry/coder-labs/modules/copilot/main.tf index 7a6f73f4e..9194fa993 100644 --- a/registry/coder-labs/modules/copilot/main.tf +++ b/registry/coder-labs/modules/copilot/main.tf @@ -322,7 +322,6 @@ module "agentapi" { ARG_TRUSTED_DIRECTORIES='${join(",", var.trusted_directories)}' \ ARG_EXTERNAL_AUTH_ID='${var.external_auth_id}' \ ARG_RESUME_SESSION='${var.resume_session}' \ - ARG_REPORT_TASKS='${var.report_tasks}' \ ARG_ENABLE_AIBRIDGE_PROXY='${var.enable_aibridge_proxy}' \ ARG_AIBRIDGE_PROXY_AUTH_URL='${var.aibridge_proxy_auth_url != null ? var.aibridge_proxy_auth_url : ""}' \ ARG_AIBRIDGE_PROXY_CERT_PATH='${var.aibridge_proxy_cert_path != null ? var.aibridge_proxy_cert_path : ""}' \ diff --git a/registry/coder-labs/modules/copilot/scripts/install.sh b/registry/coder-labs/modules/copilot/scripts/install.sh index ea2d0b86e..5a4658655 100644 --- a/registry/coder-labs/modules/copilot/scripts/install.sh +++ b/registry/coder-labs/modules/copilot/scripts/install.sh @@ -1,11 +1,9 @@ #!/bin/bash -if [ -f "$HOME/.bashrc" ]; then - source "$HOME"/.bashrc -fi - set -euo pipefail +export PATH="$HOME/.local/bin:$PATH" + command_exists() { command -v "$1" > /dev/null 2>&1 } diff --git a/registry/coder-labs/modules/copilot/scripts/start.sh b/registry/coder-labs/modules/copilot/scripts/start.sh index c7a1afb3d..06a5546c1 100644 --- a/registry/coder-labs/modules/copilot/scripts/start.sh +++ b/registry/coder-labs/modules/copilot/scripts/start.sh @@ -1,9 +1,5 @@ #!/bin/bash -if [ -f "$HOME/.bashrc" ]; then - source "$HOME"/.bashrc -fi - set -euo pipefail export PATH="$HOME/.local/bin:$PATH" @@ -23,7 +19,6 @@ ARG_DENY_TOOLS=${ARG_DENY_TOOLS:-} ARG_TRUSTED_DIRECTORIES=${ARG_TRUSTED_DIRECTORIES:-} ARG_EXTERNAL_AUTH_ID=${ARG_EXTERNAL_AUTH_ID:-github} ARG_RESUME_SESSION=${ARG_RESUME_SESSION:-true} -ARG_REPORT_TASKS=${ARG_REPORT_TASKS:-true} ARG_ENABLE_AIBRIDGE_PROXY=${ARG_ENABLE_AIBRIDGE_PROXY:-false} ARG_AIBRIDGE_PROXY_AUTH_URL=${ARG_AIBRIDGE_PROXY_AUTH_URL:-} ARG_AIBRIDGE_PROXY_CERT_PATH=${ARG_AIBRIDGE_PROXY_CERT_PATH:-} @@ -36,21 +31,15 @@ validate_copilot_installation() { } build_initial_prompt() { - local initial_prompt="" - local task_prompt="$ARG_AI_PROMPT" - - # Add task reporting instruction when report_tasks is enabled - if [ -n "$ARG_AI_PROMPT" ] && [ "$ARG_REPORT_TASKS" = "true" ]; then - task_prompt="Every step of the way, report your progress using Coder.coder_report_task tool with proper summary and statuses. Your task at hand: $ARG_AI_PROMPT" - fi + local initial_prompt="" - if [ -n "$task_prompt" ]; then + if [ -n "$ARG_AI_PROMPT" ]; then if [ -n "$ARG_SYSTEM_PROMPT" ]; then initial_prompt="$ARG_SYSTEM_PROMPT -$task_prompt" +$ARG_AI_PROMPT" else - initial_prompt="$task_prompt" + initial_prompt="$ARG_AI_PROMPT" fi fi @@ -85,6 +74,16 @@ build_copilot_args() { if [ "$ARG_ALLOW_ALL" = "true" ]; then COPILOT_ARGS+=(--allow-all) fi + + if check_existing_session; then + COPILOT_ARGS+=(--continue) + else + local initial_prompt + initial_prompt=$(build_initial_prompt) + if [[ -n "${initial_prompt}" ]]; then + COPILOT_ARGS+=(-i "${initial_prompt}") + fi + fi } check_existing_session() { @@ -181,29 +180,11 @@ start_agentapi() { build_copilot_args - if check_existing_session; then - echo "Continuing latest Copilot session..." - if [ ${#COPILOT_ARGS[@]} -gt 0 ]; then - echo "Copilot arguments: ${COPILOT_ARGS[*]}" - agentapi server --type copilot --term-width 120 --term-height 40 -- copilot --continue "${COPILOT_ARGS[@]}" - else - agentapi server --type copilot --term-width 120 --term-height 40 -- copilot --continue - fi + if [ ${#COPILOT_ARGS[@]} -gt 0 ]; then + echo "Copilot arguments: ${COPILOT_ARGS[*]}" + agentapi server --type copilot --term-width 67 --term-height 1190 -- copilot "${COPILOT_ARGS[@]}" else - echo "Starting new Copilot session..." - local initial_prompt - initial_prompt=$(build_initial_prompt) - - if [ -n "$initial_prompt" ]; then - COPILOT_ARGS+=(-i "$initial_prompt") - fi - - if [ ${#COPILOT_ARGS[@]} -gt 0 ]; then - echo "Copilot arguments: ${COPILOT_ARGS[*]}" - agentapi server --type copilot --term-width 67 --term-height 1190 -- copilot "${COPILOT_ARGS[@]}" - else - agentapi server --type copilot --term-width 67 --term-height 1190 -- copilot - fi + agentapi server --type copilot --term-width 67 --term-height 1190 -- copilot fi } From 2d8699b465272fc3846430a804571211cdd53d8a Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Fri, 13 Mar 2026 13:03:48 +0530 Subject: [PATCH 07/12] wip --- registry/coder-labs/modules/copilot/scripts/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/registry/coder-labs/modules/copilot/scripts/install.sh b/registry/coder-labs/modules/copilot/scripts/install.sh index 5a4658655..226f10dda 100644 --- a/registry/coder-labs/modules/copilot/scripts/install.sh +++ b/registry/coder-labs/modules/copilot/scripts/install.sh @@ -27,6 +27,7 @@ install_copilot() { fi if ! command_exists copilot; then + echo "PATH after installation: $PATH" echo "ERROR: Failed to install Copilot" exit 1 fi From c70954191ef0a0f275e5426b3003a785b3746f83 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Fri, 13 Mar 2026 15:10:30 +0530 Subject: [PATCH 08/12] chore: update XDG_CONFIG_HOME default path in setup_copilot_config function --- registry/coder-labs/modules/copilot/scripts/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/coder-labs/modules/copilot/scripts/install.sh b/registry/coder-labs/modules/copilot/scripts/install.sh index 226f10dda..f5f461d2a 100644 --- a/registry/coder-labs/modules/copilot/scripts/install.sh +++ b/registry/coder-labs/modules/copilot/scripts/install.sh @@ -76,7 +76,7 @@ setup_copilot_configurations() { } setup_copilot_config() { - export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" + export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME}" local copilot_config_dir="$XDG_CONFIG_HOME/.copilot" local copilot_config_file="$copilot_config_dir/config.json" local mcp_config_file="$copilot_config_dir/mcp-config.json" From 70f4d625b8822ea8d59be30ed4370bcc937db8c2 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Fri, 13 Mar 2026 18:38:02 +0530 Subject: [PATCH 09/12] bun fmt --- registry/coder-labs/modules/copilot/scripts/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/coder-labs/modules/copilot/scripts/start.sh b/registry/coder-labs/modules/copilot/scripts/start.sh index 06a5546c1..7c5d21c5b 100644 --- a/registry/coder-labs/modules/copilot/scripts/start.sh +++ b/registry/coder-labs/modules/copilot/scripts/start.sh @@ -31,7 +31,7 @@ validate_copilot_installation() { } build_initial_prompt() { - local initial_prompt="" + local initial_prompt="" if [ -n "$ARG_AI_PROMPT" ]; then if [ -n "$ARG_SYSTEM_PROMPT" ]; then From 90fe6a50a08e27986784acdd8a68ece6f812be19 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Fri, 13 Mar 2026 18:57:02 +0530 Subject: [PATCH 10/12] fix: fix version installation --- registry/coder-labs/modules/copilot/scripts/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/coder-labs/modules/copilot/scripts/install.sh b/registry/coder-labs/modules/copilot/scripts/install.sh index f5f461d2a..9c0c2d49a 100644 --- a/registry/coder-labs/modules/copilot/scripts/install.sh +++ b/registry/coder-labs/modules/copilot/scripts/install.sh @@ -23,7 +23,7 @@ install_copilot() { if [ "$ARG_COPILOT_VERSION" = "latest" ]; then curl -fsSL https://gh.io/copilot-install | bash else - VERSION="${ARG_COPILOT_VERSION}" curl -fsSL https://gh.io/copilot-install | bash + curl -fsSL https://gh.io/copilot-install | VERSION="${ARG_COPILOT_VERSION}" bash fi if ! command_exists copilot; then From f73c20a50a792605f34b5c10d2a5abf4a7968d5a Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Fri, 13 Mar 2026 18:58:02 +0530 Subject: [PATCH 11/12] feat: remove version check --- registry/coder-labs/modules/copilot/scripts/install.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/registry/coder-labs/modules/copilot/scripts/install.sh b/registry/coder-labs/modules/copilot/scripts/install.sh index 9c0c2d49a..4609376c3 100644 --- a/registry/coder-labs/modules/copilot/scripts/install.sh +++ b/registry/coder-labs/modules/copilot/scripts/install.sh @@ -20,11 +20,7 @@ ARG_COPILOT_MODEL=${ARG_COPILOT_MODEL:-claude-sonnet-4.5} install_copilot() { if ! command_exists copilot; then echo "Installing GitHub Copilot CLI (version: ${ARG_COPILOT_VERSION})..." - if [ "$ARG_COPILOT_VERSION" = "latest" ]; then - curl -fsSL https://gh.io/copilot-install | bash - else - curl -fsSL https://gh.io/copilot-install | VERSION="${ARG_COPILOT_VERSION}" bash - fi + curl -fsSL https://gh.io/copilot-install | VERSION="${ARG_COPILOT_VERSION}" bash if ! command_exists copilot; then echo "PATH after installation: $PATH" From aa6c429a3cc809ae52ada3c209ff584e4b62cb3d Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Fri, 13 Mar 2026 19:23:14 +0530 Subject: [PATCH 12/12] feat: add warning in README.md --- registry/coder-labs/modules/copilot/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/registry/coder-labs/modules/copilot/README.md b/registry/coder-labs/modules/copilot/README.md index f67ad5600..7005e1ca3 100644 --- a/registry/coder-labs/modules/copilot/README.md +++ b/registry/coder-labs/modules/copilot/README.md @@ -19,6 +19,9 @@ module "copilot" { } ``` +> [!WARNING] +> **Security Notice**: This module runs Copilot with `--allow-all` by default, which enables all permissions (equivalent to `--allow-all-tools --allow-all-paths --allow-all-urls`). This bypasses permission prompts and allows Copilot unrestricted access to tools, file paths, and URLs. Use this module _only_ in trusted environments. + > [!IMPORTANT] > This example assumes you have [Coder external authentication](https://coder.com/docs/admin/external-auth) configured with `id = "github"`. If not, you can provide a direct token using the `github_token` variable or provide the correct external authentication id for GitHub by setting `external_auth_id = "my-github"`.