thinkwork-cli 0.12.5 → 0.12.7
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.
- package/dist/api-client-MC4NOZ4L.js +16 -0
- package/dist/chunk-34NMB5AK.js +359 -0
- package/dist/cli.js +523 -682
- package/dist/commands/enterprise/templates/deploy-repo/docs/runbook.md +197 -27
- package/dist/terraform/modules/app/lambda-api/handlers.tf +2 -1
- package/dist/terraform/modules/app/lambda-api/main.tf +19 -4
- package/package.json +1 -1
|
@@ -5,50 +5,218 @@
|
|
|
5
5
|
This repository deploys a pinned ThinkWork release into the customer AWS
|
|
6
6
|
account. It is a deployment repository, not a source fork.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
The exact operational path is:
|
|
9
|
+
|
|
10
|
+
```text
|
|
11
|
+
bootstrap -> workflow dispatch -> CI deploy -> overlay apply -> smoke summary
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## First-Time Setup
|
|
15
|
+
|
|
16
|
+
Run these commands from an operator machine with temporary customer AWS admin
|
|
17
|
+
access and GitHub admin access to this repository.
|
|
18
|
+
|
|
19
|
+
1. Confirm access:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
gh auth status
|
|
23
|
+
aws sts get-caller-identity
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
2. Install the CLI:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install -g thinkwork-cli
|
|
30
|
+
thinkwork --version
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
3. Choose the release and checksum:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
VERSION="$(thinkwork --version)"
|
|
37
|
+
RELEASE="v${VERSION#v}"
|
|
38
|
+
MANIFEST_URL="https://github.com/thinkwork-ai/thinkwork/releases/download/${RELEASE}/thinkwork-release.json"
|
|
39
|
+
MANIFEST_SHA256="$(curl -fsSL "$MANIFEST_URL" | shasum -a 256 | awk '{print $1}')"
|
|
40
|
+
```
|
|
9
41
|
|
|
10
|
-
|
|
42
|
+
4. Bootstrap AWS trust, GitHub Environments, and managed repo files:
|
|
11
43
|
|
|
12
44
|
```bash
|
|
13
45
|
thinkwork enterprise bootstrap . \
|
|
14
46
|
--customer {{CUSTOMER_SLUG}} \
|
|
15
47
|
--repo <github-owner>/<github-repo> \
|
|
16
48
|
--stage dev \
|
|
17
|
-
--stage prod
|
|
49
|
+
--stage prod \
|
|
50
|
+
--region {{REGION}} \
|
|
51
|
+
--release-version "$RELEASE" \
|
|
52
|
+
--manifest-url "$MANIFEST_URL" \
|
|
53
|
+
--manifest-sha256 "$MANIFEST_SHA256" \
|
|
54
|
+
--yes
|
|
18
55
|
```
|
|
19
56
|
|
|
20
|
-
|
|
21
|
-
3. Add required secrets such as `TF_VAR_db_password` and
|
|
22
|
-
`TF_VAR_api_auth_secret`.
|
|
23
|
-
4. Dispatch `.github/workflows/deploy.yml`.
|
|
24
|
-
5. CI verifies `thinkwork.lock`, prepares release artifacts, runs Terraform,
|
|
25
|
-
updates AgentCore runtimes, applies customer overlays, runs smoke checks,
|
|
26
|
-
and writes a summary artifact.
|
|
57
|
+
5. Commit and push generated files:
|
|
27
58
|
|
|
28
|
-
|
|
59
|
+
```bash
|
|
60
|
+
git add .
|
|
61
|
+
git commit -m "chore: bootstrap ThinkWork deployment repo"
|
|
62
|
+
git push
|
|
63
|
+
```
|
|
29
64
|
|
|
30
|
-
|
|
31
|
-
bootstrap -> workflow dispatch -> CI deploy -> overlay apply -> smoke summary
|
|
32
|
-
```
|
|
65
|
+
6. Set required GitHub Environment secrets for each stage:
|
|
33
66
|
|
|
34
|
-
|
|
67
|
+
```bash
|
|
68
|
+
gh secret set TF_VAR_DB_PASSWORD \
|
|
69
|
+
--repo <github-owner>/<github-repo> \
|
|
70
|
+
--env dev \
|
|
71
|
+
--body "$DEV_DB_PASSWORD"
|
|
72
|
+
|
|
73
|
+
gh secret set TF_VAR_API_AUTH_SECRET \
|
|
74
|
+
--repo <github-owner>/<github-repo> \
|
|
75
|
+
--env dev \
|
|
76
|
+
--body "$DEV_API_AUTH_SECRET"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Repeat for `prod` before the production deploy.
|
|
80
|
+
|
|
81
|
+
7. Verify GitHub Environment variables:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
gh variable list --repo <github-owner>/<github-repo> --env dev
|
|
85
|
+
gh variable list --repo <github-owner>/<github-repo> --env prod
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Expected variables are `AWS_REGION`, `AWS_ROLE_ARN`, and
|
|
89
|
+
`THINKWORK_ARTIFACT_BUCKET`.
|
|
90
|
+
|
|
91
|
+
8. Review stage config:
|
|
92
|
+
- `terraform/stages/dev.tfvars`
|
|
93
|
+
- `terraform/stages/prod.tfvars`
|
|
94
|
+
- `customer/deployment.json`
|
|
35
95
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
96
|
+
Do not commit plaintext secrets to `terraform/stages/*.tfvars`,
|
|
97
|
+
`customer/`, `.env`, or this runbook.
|
|
98
|
+
|
|
99
|
+
9. Dispatch the first deploy:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
gh workflow run deploy.yml \
|
|
103
|
+
--repo <github-owner>/<github-repo> \
|
|
104
|
+
-f stage=dev \
|
|
105
|
+
-f component=all \
|
|
106
|
+
-f run_smokes=true
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
10. Watch the run and download evidence:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
RUN_ID="$(gh run list --repo <github-owner>/<github-repo> --workflow deploy.yml --limit 1 --json databaseId --jq '.[0].databaseId')"
|
|
113
|
+
gh run watch "$RUN_ID" --repo <github-owner>/<github-repo> --exit-status
|
|
114
|
+
|
|
115
|
+
mkdir -p "deploy-artifacts/dev-${RUN_ID}"
|
|
116
|
+
gh run download "$RUN_ID" \
|
|
117
|
+
--repo <github-owner>/<github-repo> \
|
|
118
|
+
--name "thinkwork-deploy-dev-${RUN_ID}" \
|
|
119
|
+
--dir "deploy-artifacts/dev-${RUN_ID}"
|
|
120
|
+
|
|
121
|
+
jq . "deploy-artifacts/dev-${RUN_ID}/deploy-summary.json"
|
|
122
|
+
jq . "deploy-artifacts/dev-${RUN_ID}/smoke-summary.json"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
11. Log in to the deployed stack:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
thinkwork login --stage dev --region {{REGION}}
|
|
129
|
+
thinkwork me --stage dev --region {{REGION}}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
12. Deploy production after the `prod` GitHub Environment has required
|
|
133
|
+
approvals and secrets:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
gh workflow run deploy.yml \
|
|
137
|
+
--repo <github-owner>/<github-repo> \
|
|
138
|
+
-f stage=prod \
|
|
139
|
+
-f component=all \
|
|
140
|
+
-f run_smokes=true
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Workflow Components
|
|
144
|
+
|
|
145
|
+
| Component | What it does |
|
|
146
|
+
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
147
|
+
| `all` | First deploy and normal release upgrades: release artifact prep, Terraform apply, runtime image copy, AgentCore update, static sync, overlays, smokes. |
|
|
148
|
+
| `foundation` | Terraform apply and artifact/runtime/static sync without overlays. |
|
|
149
|
+
| `artifacts` | Re-copy pinned Lambda/static/runtime artifacts without Terraform apply. |
|
|
150
|
+
| `overlays` | Apply only `customer/` evals, skills, workspace defaults, seeds, and branding records. |
|
|
151
|
+
| `smokes` | Run smoke checks against an already-deployed stage. |
|
|
40
152
|
|
|
41
153
|
## Overlay-Only Changes
|
|
42
154
|
|
|
43
155
|
1. Edit files under `customer/`.
|
|
44
|
-
2.
|
|
156
|
+
2. Validate locally:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
thinkwork enterprise overlay apply . --stage dev --region {{REGION}} --dry-run --json
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
3. Commit and push:
|
|
45
163
|
|
|
46
164
|
```bash
|
|
47
|
-
|
|
165
|
+
git add customer
|
|
166
|
+
git commit -m "chore: update customer ThinkWork overlays"
|
|
167
|
+
git push
|
|
48
168
|
```
|
|
49
169
|
|
|
50
|
-
|
|
51
|
-
|
|
170
|
+
4. Dispatch:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
gh workflow run deploy.yml \
|
|
174
|
+
--repo <github-owner>/<github-repo> \
|
|
175
|
+
-f stage=dev \
|
|
176
|
+
-f component=overlays \
|
|
177
|
+
-f run_smokes=false
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Release Upgrades
|
|
181
|
+
|
|
182
|
+
1. Update `thinkwork.lock`:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
VERSION="0.12.5"
|
|
186
|
+
RELEASE="v${VERSION#v}"
|
|
187
|
+
MANIFEST_URL="https://github.com/thinkwork-ai/thinkwork/releases/download/${RELEASE}/thinkwork-release.json"
|
|
188
|
+
MANIFEST_SHA256="$(curl -fsSL "$MANIFEST_URL" | shasum -a 256 | awk '{print $1}')"
|
|
189
|
+
|
|
190
|
+
tmp="$(mktemp)"
|
|
191
|
+
jq \
|
|
192
|
+
--arg release "$RELEASE" \
|
|
193
|
+
--arg manifestUrl "$MANIFEST_URL" \
|
|
194
|
+
--arg manifestSha256 "$MANIFEST_SHA256" \
|
|
195
|
+
--arg terraformModuleVersion "${RELEASE#v}" \
|
|
196
|
+
'.thinkwork.release = $release
|
|
197
|
+
| .thinkwork.manifestUrl = $manifestUrl
|
|
198
|
+
| .thinkwork.manifestSha256 = $manifestSha256
|
|
199
|
+
| .thinkwork.terraformModuleVersion = $terraformModuleVersion
|
|
200
|
+
| .artifacts.lambdaPrefix = ("releases/" + $release + "/lambdas")' \
|
|
201
|
+
thinkwork.lock > "$tmp"
|
|
202
|
+
mv "$tmp" thinkwork.lock
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
2. Commit and deploy to dev:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
git add thinkwork.lock
|
|
209
|
+
git commit -m "chore: bump ThinkWork to ${RELEASE}"
|
|
210
|
+
git push
|
|
211
|
+
|
|
212
|
+
gh workflow run deploy.yml \
|
|
213
|
+
--repo <github-owner>/<github-repo> \
|
|
214
|
+
-f stage=dev \
|
|
215
|
+
-f component=all \
|
|
216
|
+
-f run_smokes=true
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
3. Deploy to production after dev passes.
|
|
52
220
|
|
|
53
221
|
## Secrets
|
|
54
222
|
|
|
@@ -65,12 +233,14 @@ Do not store plaintext secrets in `terraform/stages/*.tfvars`, `.env`,
|
|
|
65
233
|
## Rollback
|
|
66
234
|
|
|
67
235
|
To roll back application code, restore `thinkwork.lock` to the previously
|
|
68
|
-
working release and dispatch the workflow
|
|
69
|
-
|
|
236
|
+
working release and dispatch the workflow with `component=all`.
|
|
237
|
+
|
|
238
|
+
To roll back customer overlays, revert the customer repo commit and dispatch
|
|
239
|
+
the workflow with `component=overlays`.
|
|
70
240
|
|
|
71
241
|
If a deploy fails after Terraform apply but before smoke summary, inspect the
|
|
72
|
-
workflow
|
|
73
|
-
|
|
242
|
+
workflow artifact first. `deploy-summary.json`, `overlay-report.json`, and
|
|
243
|
+
`smoke-summary.json` identify which stage failed.
|
|
74
244
|
|
|
75
245
|
## Break Glass
|
|
76
246
|
|
|
@@ -231,7 +231,8 @@ locals {
|
|
|
231
231
|
ROUTINE_TASK_PYTHON_FUNCTION_NAME = "thinkwork-${var.stage}-api-routine-task-python"
|
|
232
232
|
ADMIN_OPS_MCP_FUNCTION_NAME = "thinkwork-${var.stage}-api-admin-ops-mcp"
|
|
233
233
|
SLACK_SEND_FUNCTION_NAME = "thinkwork-${var.stage}-api-slack-send"
|
|
234
|
-
|
|
234
|
+
# requester idle memory learning defaults on in API code so this
|
|
235
|
+
# env-heavy Lambda can stay below AWS's 4 KB environment limit.
|
|
235
236
|
# Phase 3 U10 — compliance read resolvers (complianceEvents,
|
|
236
237
|
# complianceEvent, complianceEventByHash) connect to Aurora as
|
|
237
238
|
# the compliance_reader role. The existing lambda_secrets policy
|
|
@@ -535,10 +535,6 @@ resource "aws_iam_role_policy" "lambda_api_cross_invoke" {
|
|
|
535
535
|
# decision. Calls SendTaskSuccess/SendTaskFailure on the SFN
|
|
536
536
|
# task token; idempotent on already-consumed tokens.
|
|
537
537
|
"arn:aws:lambda:${var.region}:${var.account_id}:function:thinkwork-${var.stage}-api-routine-resume",
|
|
538
|
-
# thread-idle-memory-learning: job-trigger invokes this
|
|
539
|
-
# RequestResponse after a 15-minute requester-thread idle timer
|
|
540
|
-
# passes its stale guard.
|
|
541
|
-
"arn:aws:lambda:${var.region}:${var.account_id}:function:thinkwork-${var.stage}-api-thread-idle-memory-learning",
|
|
542
538
|
# workspace-files-efs: workspace-files invokes this (RequestResponse)
|
|
543
539
|
# for Computer-target list/get to bypass the computer_tasks queue
|
|
544
540
|
# and read EFS directly. Standalone resource below.
|
|
@@ -548,6 +544,25 @@ resource "aws_iam_role_policy" "lambda_api_cross_invoke" {
|
|
|
548
544
|
})
|
|
549
545
|
}
|
|
550
546
|
|
|
547
|
+
resource "aws_iam_policy" "thread_idle_memory_learning_invoke" {
|
|
548
|
+
name = "thinkwork-${var.stage}-thread-idle-memory-learning-invoke"
|
|
549
|
+
description = "Allow API job-trigger Lambda to invoke requester idle memory learning worker."
|
|
550
|
+
|
|
551
|
+
policy = jsonencode({
|
|
552
|
+
Version = "2012-10-17"
|
|
553
|
+
Statement = [{
|
|
554
|
+
Effect = "Allow"
|
|
555
|
+
Action = ["lambda:InvokeFunction"]
|
|
556
|
+
Resource = "arn:aws:lambda:${var.region}:${var.account_id}:function:thinkwork-${var.stage}-api-thread-idle-memory-learning"
|
|
557
|
+
}]
|
|
558
|
+
})
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
resource "aws_iam_role_policy_attachment" "lambda_thread_idle_memory_learning_invoke" {
|
|
562
|
+
role = aws_iam_role.lambda.name
|
|
563
|
+
policy_arn = aws_iam_policy.thread_idle_memory_learning_invoke.arn
|
|
564
|
+
}
|
|
565
|
+
|
|
551
566
|
# Step Functions admin operations — for createRoutine / publishRoutineVersion
|
|
552
567
|
# / triggerRoutineRun / updateRoutine resolvers (Phase B U7) and the
|
|
553
568
|
# routine-asl-validator Lambda (Phase A U5). State-machine ARNs follow the
|