Skip to content

Commit d75a401

Browse files
author
Michael Orlov
committed
feat: enhance Amazon Q module with task reporting and configuration improvements
- Add report_tasks variable for controlling task reporting to Coder UI - Add cli_app support with configurable display names - Add workdir variable for custom working directory - Add agentapi_chat_based_path for environments without wildcard access - Update AgentAPI version from v0.6.0 to v0.6.1 - Remove pre_install_script and post_install_script variables - Update module directory from .amazonq to .amazonq-module - Enhance install and start scripts with improved task reporting - Update README with new configuration options and examples
1 parent 64b5ac8 commit d75a401

File tree

4 files changed

+176
-121
lines changed

4 files changed

+176
-121
lines changed

registry/coder/modules/amazon-q/README.md

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ This module has critical dependencies on AgentAPI components for proper web inte
4747

4848
### AgentAPI Binary
4949

50-
- **Binary Version**: `v0.6.0` (configurable via `agentapi_version` parameter)
50+
- **Binary Version**: `v0.6.1` (configurable via `agentapi_version` parameter)
5151
- **Installation**: Automatically downloaded and installed when `install_agentapi = true`
5252
- **Purpose**: The actual AgentAPI server binary that runs the web interface
5353
- **Functionality**: Provides the runtime server for web-based interactions
@@ -64,7 +64,7 @@ This module has critical dependencies on AgentAPI components for proper web inte
6464
**Version Compatibility:**
6565

6666
- **Module Version**: Fixed at `1.1.1` for stability and compatibility
67-
- **Binary Version**: Configurable (default `v0.6.0`) to allow updates and customization
67+
- **Binary Version**: Configurable (default `v0.6.1`) to allow updates and customization
6868
- **Coder Integration**: Ensure your Coder deployment supports both component versions
6969
- **Upgrade Path**: Binary version can be updated via `agentapi_version` parameter
7070

@@ -181,21 +181,25 @@ module "amazon-q" {
181181

182182
### Optional Variables
183183

184-
| Variable | Type | Default | Description |
185-
| ------------------------ | -------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
186-
| `auth_tarball` | `string` | `""` | Base64 encoded, zstd compressed tarball of authenticated Amazon Q directory (sensitive) |
187-
| `amazon_q_version` | `string` | `"1.14.1"` | Version of Amazon Q to install |
188-
| `q_install_url` | `string` | `"https://desktop-release.q.us-east-1.amazonaws.com"` | Base URL for Amazon Q installation downloads (supports air-gapped installations) |
189-
| `install_amazon_q` | `bool` | `true` | Whether to install Amazon Q CLI |
190-
| `install_agentapi` | `bool` | `true` | Whether to install AgentAPI for web integration |
191-
| `agentapi_version` | `string` | `"v0.6.0"` | Version of AgentAPI to install |
192-
| `trust_all_tools` | `bool` | `false` | Whether to trust all tools in Amazon Q (security consideration) |
193-
| `ai_prompt` | `string` | `""` | Initial task prompt to send to Amazon Q (used for automated task execution) |
194-
| `system_prompt` | `string` | _See below_ | System prompt that defines the agent's behavior and task reporting instructions |
195-
| `coder_mcp_instructions` | `string` | _See below_ | Specific instructions for Coder MCP server integration. Defines task reporting format and requirements |
196-
| `pre_install_script` | `string` | `null` | Optional script to run before installing Amazon Q (supports custom environment setup) |
197-
| `post_install_script` | `string` | `null` | Optional script to run after installing Amazon Q (supports custom configuration) |
198-
| `agent_config` | `string` | `null` | Custom agent configuration JSON. The "name" field is used as agent name and config filename. Supports full agent customization |
184+
| Variable | Type | Default | Description |
185+
| -------------------------- | -------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
186+
| `auth_tarball` | `string` | `""` | Base64 encoded, zstd compressed tarball of authenticated Amazon Q directory (sensitive) |
187+
| `amazon_q_version` | `string` | `"1.14.1"` | Version of Amazon Q to install |
188+
| `q_install_url` | `string` | `"https://desktop-release.q.us-east-1.amazonaws.com"` | Base URL for Amazon Q installation downloads (supports air-gapped installations) |
189+
| `install_amazon_q` | `bool` | `true` | Whether to install Amazon Q CLI |
190+
| `install_agentapi` | `bool` | `true` | Whether to install AgentAPI for web integration |
191+
| `agentapi_version` | `string` | `"v0.6.1"` | Version of AgentAPI to install |
192+
| `trust_all_tools` | `bool` | `false` | Whether to trust all tools in Amazon Q (security consideration) |
193+
| `ai_prompt` | `string` | `""` | Initial task prompt to send to Amazon Q (used for automated task execution) |
194+
| `system_prompt` | `string` | _See below_ | System prompt that defines the agent's behavior and task reporting instructions |
195+
| `coder_mcp_instructions` | `string` | _See below_ | Specific instructions for Coder MCP server integration. Defines task reporting format and requirements |
196+
| `agent_config` | `string` | `null` | Custom agent configuration JSON. The "name" field is used as agent name and config filename. Supports full agent customization |
197+
| `report_tasks` | `bool` | `true` | Whether to enable task reporting to Coder UI via AgentAPI |
198+
| `cli_app` | `bool` | `false` | Whether to create a CLI app for Amazon Q |
199+
| `web_app_display_name` | `string` | `"AmazonQ"` | Display name for the web app |
200+
| `cli_app_display_name` | `string` | `"AmazonQ CLI"` | Display name for the CLI app |
201+
| `workdir` | `string` | `"/home/coder"` | The folder to run Amazon Q in |
202+
| `agentapi_chat_based_path` | `bool` | `true` | Whether to use chat-based path for AgentAPI. Required if CODER_WILDCARD_ACCESS_URL is not defined in coder deployment |
199203

200204
### UI Configuration
201205

@@ -412,6 +416,41 @@ module "amazon-q" {
412416
}
413417
```
414418

419+
### With Task Reporting and Custom Working Directory
420+
421+
```tf
422+
module "amazon-q" {
423+
source = "registry.coder.com/coder/amazon-q/coder"
424+
version = "2.0.0"
425+
agent_id = coder_agent.example.id
426+
auth_tarball = var.amazon_q_auth_tarball
427+
428+
# Task reporting configuration
429+
report_tasks = true
430+
workdir = "/workspace/project"
431+
432+
# Enable CLI app alongside web app
433+
cli_app = true
434+
web_app_display_name = "Amazon Q Assistant"
435+
cli_app_display_name = "Q CLI"
436+
}
437+
```
438+
439+
### With Custom AgentAPI Configuration
440+
441+
```tf
442+
module "amazon-q" {
443+
source = "registry.coder.com/coder/amazon-q/coder"
444+
version = "2.0.0"
445+
agent_id = coder_agent.example.id
446+
auth_tarball = var.amazon_q_auth_tarball
447+
448+
# AgentAPI configuration for environments without wildcard access
449+
agentapi_chat_based_path = true
450+
agentapi_version = "v0.6.1"
451+
}
452+
```
453+
415454
### UI Customization
416455

417456
```tf

registry/coder/modules/amazon-q/main.tf

Lines changed: 70 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,72 @@ variable "icon" {
3737
default = "/icon/amazon-q.svg"
3838
}
3939

40-
41-
variable "install_amazon_q" {
40+
variable "report_tasks" {
4241
type = bool
43-
description = "Whether to install Amazon Q."
42+
description = "Whether to enable task reporting to Coder UI via AgentAPI"
4443
default = true
4544
}
4645

46+
variable "cli_app" {
47+
type = bool
48+
description = "Whether to create a CLI app for Amazon Q"
49+
default = false
50+
}
51+
52+
variable "web_app_display_name" {
53+
type = string
54+
description = "Display name for the web app"
55+
default = "AmazonQ"
56+
}
57+
58+
variable "cli_app_display_name" {
59+
type = string
60+
description = "Display name for the CLI app"
61+
default = "AmazonQ CLI"
62+
}
63+
4764
variable "install_agentapi" {
4865
type = bool
4966
description = "Whether to install AgentAPI."
5067
default = true
5168
}
5269

70+
variable "ai_prompt" {
71+
type = string
72+
description = "The initial task prompt to send to Amazon Q."
73+
default = ""
74+
}
75+
76+
variable "pre_install_script" {
77+
type = string
78+
description = "Optional script to run before installing Amazon Q."
79+
default = null
80+
}
81+
82+
variable "post_install_script" {
83+
type = string
84+
description = "Optional script to run after installing Amazon Q."
85+
default = null
86+
}
87+
5388
variable "agentapi_version" {
5489
type = string
5590
description = "The version of AgentAPI to install."
56-
default = "v0.6.0"
91+
default = "v0.6.1"
92+
}
93+
94+
variable "workdir" {
95+
type = string
96+
description = "The folder to run Amazon Q in."
97+
default = "/home/coder"
98+
}
99+
100+
# ---------------------------------------------
101+
102+
variable "install_amazon_q" {
103+
type = bool
104+
description = "Whether to install Amazon Q."
105+
default = true
57106
}
58107

59108
variable "amazon_q_version" {
@@ -74,12 +123,6 @@ variable "trust_all_tools" {
74123
default = false
75124
}
76125

77-
variable "ai_prompt" {
78-
type = string
79-
description = "The initial task prompt to send to Amazon Q."
80-
default = ""
81-
}
82-
83126
variable "system_prompt" {
84127
type = string
85128
description = "The system prompt to use for Amazon Q. This should instruct the agent how to do task reporting."
@@ -119,24 +162,18 @@ variable "auth_tarball" {
119162
sensitive = true
120163
}
121164

122-
variable "pre_install_script" {
123-
type = string
124-
description = "Optional script to run before installing Amazon Q."
125-
default = null
126-
}
127-
128-
variable "post_install_script" {
129-
type = string
130-
description = "Optional script to run after installing Amazon Q."
131-
default = null
132-
}
133-
134165
variable "agent_config" {
135166
type = string
136167
description = "Optional Agent configuration JSON for Amazon Q."
137168
default = null
138169
}
139170

171+
variable "agentapi_chat_based_path" {
172+
type = bool
173+
description = "Whether to use chat-based path for AgentAPI.Required if CODER_WILDCARD_ACCESS_URL is not defined in coder deployment"
174+
default = true
175+
}
176+
140177
# Expose status slug to the agent environment
141178
resource "coder_env" "status_slug" {
142179
agent_id = var.agent_id
@@ -156,7 +193,7 @@ locals {
156193
app_slug = "amazonq"
157194
install_script = file("${path.module}/scripts/install.sh")
158195
start_script = file("${path.module}/scripts/start.sh")
159-
module_dir_name = ".amazonq"
196+
module_dir_name = ".amazonq-module"
160197
system_prompt = jsonencode(replace(var.system_prompt, "/[\r\n]/", ""))
161198
coder_mcp_instructions = jsonencode(replace(var.coder_mcp_instructions, "/[\r\n]/", ""))
162199

@@ -165,17 +202,15 @@ locals {
165202
system_prompt = local.system_prompt
166203
})
167204

168-
# Use either custom agent config OR default, not merged
169-
# Check if custom config is provided and valid
170-
has_custom_config = var.agent_config != null && var.agent_config != ""
171-
172205
# Choose the JSON string: use var.agent_config if provided, otherwise encode default
173206
agent_config = var.agent_config != null ? var.agent_config : local.default_agent_config
174207

175208
# Extract agent name from the selected config
176209
agent_name = try(jsondecode(local.agent_config).name, "agent")
177210

178211
full_prompt = var.ai_prompt != null ? "${var.ai_prompt}" : ""
212+
213+
server_chat_parameters = var.agentapi_chat_based_path ? "--chat-base-path /@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}.${var.agent_id}/apps/${local.app_slug}/chat" : ""
179214
}
180215

181216

@@ -188,9 +223,10 @@ module "agentapi" {
188223
web_app_order = var.order
189224
web_app_group = var.group
190225
web_app_icon = var.icon
191-
web_app_display_name = "Amazon Q"
192-
cli_app_slug = local.app_slug
193-
cli_app_display_name = "Amazon Q"
226+
web_app_display_name = var.web_app_display_name
227+
cli_app = var.cli_app
228+
cli_app_slug = var.cli_app ? "${local.app_slug}-cli" : null
229+
cli_app_display_name = var.cli_app ? var.cli_app_display_name : null
194230
module_dir_name = local.module_dir_name
195231
install_agentapi = var.install_agentapi
196232
agentapi_version = var.agentapi_version
@@ -207,7 +243,9 @@ module "agentapi" {
207243
ARG_TRUST_ALL_TOOLS='${var.trust_all_tools}' \
208244
ARG_AI_PROMPT='${base64encode(local.full_prompt)}' \
209245
ARG_MODULE_DIR_NAME='${local.module_dir_name}' \
210-
ARG_SERVER_PARAMETERS="-c /@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}.${var.agent_id}/apps/${local.app_slug}/chat" \
246+
ARG_WORKDIR='${var.workdir}' \
247+
ARG_SERVER_PARAMETERS="${local.server_chat_parameters}" \
248+
ARG_REPORT_TASKS='${var.report_tasks}' \
211249
/tmp/start.sh
212250
EOT
213251

@@ -227,8 +265,7 @@ module "agentapi" {
227265
ARG_MODULE_DIR_NAME='${local.module_dir_name}' \
228266
ARG_CODER_MCP_APP_STATUS_SLUG='${local.app_slug}' \
229267
ARG_CODER_MCP_INSTRUCTIONS='${base64encode(local.coder_mcp_instructions)}' \
230-
ARG_PRE_INSTALL_SCRIPT='${var.pre_install_script != null ? base64encode(var.pre_install_script) : ""}' \
231-
ARG_POST_INSTALL_SCRIPT='${var.post_install_script != null ? base64encode(var.post_install_script) : ""}' \
268+
ARG_REPORT_TASKS='${var.report_tasks}' \
232269
/tmp/install.sh
233270
EOT
234271
}

0 commit comments

Comments
 (0)