thinkwork-cli 0.12.1 → 0.12.3

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.
Files changed (29) hide show
  1. package/dist/cli.js +1062 -45
  2. package/dist/commands/enterprise/templates/deploy-repo/.github/workflows/deploy.yml +232 -0
  3. package/dist/commands/enterprise/templates/deploy-repo/README.md +31 -0
  4. package/dist/commands/enterprise/templates/deploy-repo/customer/branding/README.md +7 -0
  5. package/dist/commands/enterprise/templates/deploy-repo/customer/deployment.json +6 -0
  6. package/dist/commands/enterprise/templates/deploy-repo/customer/evals/README.md +10 -0
  7. package/dist/commands/enterprise/templates/deploy-repo/customer/seeds/README.md +7 -0
  8. package/dist/commands/enterprise/templates/deploy-repo/customer/skills/README.md +7 -0
  9. package/dist/commands/enterprise/templates/deploy-repo/customer/workspace-defaults/README.md +7 -0
  10. package/dist/commands/enterprise/templates/deploy-repo/scripts/apply-release.mjs +606 -0
  11. package/dist/commands/enterprise/templates/deploy-repo/scripts/smoke.mjs +99 -0
  12. package/dist/commands/enterprise/templates/deploy-repo/terraform/backend-dev.hcl +6 -0
  13. package/dist/commands/enterprise/templates/deploy-repo/terraform/main.tf +101 -0
  14. package/dist/commands/enterprise/templates/deploy-repo/terraform/stages/dev.tfvars +9 -0
  15. package/dist/commands/enterprise/templates/deploy-repo/terraform/stages/prod.tfvars +9 -0
  16. package/dist/commands/enterprise/templates/deploy-repo/thinkwork.lock +17 -0
  17. package/dist/terraform/examples/greenfield/main.tf +26 -0
  18. package/dist/terraform/examples/greenfield/terraform.tfvars.example +12 -0
  19. package/dist/terraform/modules/app/lambda-api/eval-fanout.tf +7 -7
  20. package/dist/terraform/modules/app/lambda-api/handlers.tf +78 -68
  21. package/dist/terraform/modules/app/lambda-api/outputs.tf +9 -4
  22. package/dist/terraform/modules/app/lambda-api/remote-artifacts.tf +36 -0
  23. package/dist/terraform/modules/app/lambda-api/variables.tf +7 -0
  24. package/dist/terraform/modules/app/lambda-api/workspace-events.tf +1 -1
  25. package/dist/terraform/modules/thinkwork/main.tf +3 -2
  26. package/dist/terraform/modules/thinkwork/outputs.tf +5 -0
  27. package/dist/terraform/modules/thinkwork/variables.tf +6 -0
  28. package/dist/terraform/schema.graphql +10 -40
  29. package/package.json +1 -1
@@ -0,0 +1,101 @@
1
+ # thinkwork-managed: enterprise-deploy-template
2
+
3
+ terraform {
4
+ required_version = ">= 1.5"
5
+
6
+ required_providers {
7
+ aws = {
8
+ source = "hashicorp/aws"
9
+ version = "~> 5.0"
10
+ }
11
+ archive = {
12
+ source = "hashicorp/archive"
13
+ version = "~> 2.0"
14
+ }
15
+ null = {
16
+ source = "hashicorp/null"
17
+ version = "~> 3.0"
18
+ }
19
+ cloudflare = {
20
+ source = "cloudflare/cloudflare"
21
+ version = "~> 4.0"
22
+ }
23
+ }
24
+
25
+ backend "s3" {}
26
+ }
27
+
28
+ provider "aws" {
29
+ region = var.region
30
+ }
31
+
32
+ provider "cloudflare" {}
33
+
34
+ variable "stage" {
35
+ description = "Deployment stage. Must match the selected Terraform workspace."
36
+ type = string
37
+ }
38
+
39
+ variable "region" {
40
+ description = "AWS region."
41
+ type = string
42
+ }
43
+
44
+ variable "account_id" {
45
+ description = "Customer AWS account ID."
46
+ type = string
47
+ }
48
+
49
+ variable "db_password" {
50
+ description = "Aurora master password. Set through the GitHub Environment secret TF_VAR_DB_PASSWORD."
51
+ type = string
52
+ sensitive = true
53
+ }
54
+
55
+ variable "api_auth_secret" {
56
+ description = "Shared service API secret. Set through the GitHub Environment secret TF_VAR_API_AUTH_SECRET."
57
+ type = string
58
+ sensitive = true
59
+ }
60
+
61
+ variable "database_engine" {
62
+ description = "Database engine for this stage."
63
+ type = string
64
+ default = "aurora-serverless"
65
+ }
66
+
67
+ variable "lambda_artifact_bucket" {
68
+ description = "Customer-owned S3 bucket containing pinned ThinkWork Lambda release artifacts."
69
+ type = string
70
+ }
71
+
72
+ variable "lambda_artifact_prefix" {
73
+ description = "S3 prefix for the pinned ThinkWork Lambda release artifacts."
74
+ type = string
75
+ }
76
+
77
+ module "thinkwork" {
78
+ source = "thinkwork-ai/thinkwork/aws"
79
+ version = "{{TERRAFORM_MODULE_VERSION}}"
80
+
81
+ stage = var.stage
82
+ region = var.region
83
+ account_id = var.account_id
84
+
85
+ database_engine = var.database_engine
86
+ db_password = var.db_password
87
+ api_auth_secret = var.api_auth_secret
88
+
89
+ lambda_artifact_bucket = var.lambda_artifact_bucket
90
+ lambda_artifact_prefix = var.lambda_artifact_prefix
91
+ require_lambda_artifacts = true
92
+ }
93
+
94
+ output "api_endpoint" {
95
+ value = module.thinkwork.api_endpoint
96
+ }
97
+
98
+ output "lambda_artifact_mode" {
99
+ value = module.thinkwork.lambda_artifact_mode
100
+ }
101
+
@@ -0,0 +1,9 @@
1
+ # thinkwork-managed: enterprise-deploy-template
2
+ stage = "{{STAGE}}"
3
+ region = "{{REGION}}"
4
+ account_id = "{{ACCOUNT_ID}}"
5
+ database_engine = "rds-postgres"
6
+
7
+ lambda_artifact_bucket = "{{ARTIFACT_BUCKET}}"
8
+ lambda_artifact_prefix = "{{LAMBDA_ARTIFACT_PREFIX}}"
9
+
@@ -0,0 +1,9 @@
1
+ # thinkwork-managed: enterprise-deploy-template
2
+ stage = "{{STAGE}}"
3
+ region = "{{REGION}}"
4
+ account_id = "{{ACCOUNT_ID}}"
5
+ database_engine = "aurora-serverless"
6
+
7
+ lambda_artifact_bucket = "{{ARTIFACT_BUCKET}}"
8
+ lambda_artifact_prefix = "{{LAMBDA_ARTIFACT_PREFIX}}"
9
+
@@ -0,0 +1,17 @@
1
+ {
2
+ "_comment": "thinkwork-managed: enterprise-deploy-template",
3
+ "schemaVersion": 1,
4
+ "customerSlug": "{{CUSTOMER_SLUG}}",
5
+ "thinkwork": {
6
+ "release": "{{RELEASE_VERSION}}",
7
+ "manifestUrl": "{{RELEASE_MANIFEST_URL}}",
8
+ "manifestSha256": "{{RELEASE_MANIFEST_SHA256}}",
9
+ "terraformModuleVersion": "{{TERRAFORM_MODULE_VERSION}}",
10
+ "overlaySchemaVersion": 1
11
+ },
12
+ "artifacts": {
13
+ "bucket": "{{ARTIFACT_BUCKET}}",
14
+ "lambdaPrefix": "{{LAMBDA_ARTIFACT_PREFIX}}"
15
+ }
16
+ }
17
+
@@ -111,6 +111,24 @@ variable "lambda_zips_dir" {
111
111
  default = ""
112
112
  }
113
113
 
114
+ variable "lambda_artifact_bucket" {
115
+ description = "S3 bucket containing Lambda release artifacts. Mutually exclusive with lambda_zips_dir."
116
+ type = string
117
+ default = ""
118
+ }
119
+
120
+ variable "lambda_artifact_prefix" {
121
+ description = "S3 key prefix containing Lambda release artifacts, for example releases/v1.2.3/lambdas."
122
+ type = string
123
+ default = "latest/lambdas"
124
+ }
125
+
126
+ variable "require_lambda_artifacts" {
127
+ description = "Fail planning unless either lambda_zips_dir or lambda_artifact_bucket/lambda_artifact_prefix is configured."
128
+ type = bool
129
+ default = false
130
+ }
131
+
114
132
  variable "enable_workspace_orchestration" {
115
133
  description = "Enable S3 EventBridge/SQS routing and the workspace event dispatcher for folder-native workspace orchestration."
116
134
  type = bool
@@ -355,6 +373,9 @@ module "thinkwork" {
355
373
  google_oauth_client_secret = var.google_oauth_client_secret
356
374
  pre_signup_lambda_zip = var.pre_signup_lambda_zip
357
375
  lambda_zips_dir = var.lambda_zips_dir
376
+ lambda_artifact_bucket = var.lambda_artifact_bucket
377
+ lambda_artifact_prefix = var.lambda_artifact_prefix
378
+ require_lambda_artifacts = var.require_lambda_artifacts
358
379
  enable_workspace_orchestration = var.enable_workspace_orchestration
359
380
  api_auth_secret = var.api_auth_secret
360
381
 
@@ -496,6 +517,11 @@ output "api_endpoint" {
496
517
  value = module.thinkwork.api_endpoint
497
518
  }
498
519
 
520
+ output "lambda_artifact_mode" {
521
+ description = "Resolved Lambda artifact source mode: local, s3, or placeholder."
522
+ value = module.thinkwork.lambda_artifact_mode
523
+ }
524
+
499
525
  output "api_domain" {
500
526
  description = "Custom domain for the HTTP API (e.g. api.thinkwork.ai). Empty string when www_domain/cloudflare_zone_id aren't configured. Read by scripts/build-www.sh to set PUBLIC_API_URL at build time."
501
527
  value = local.www_dns_enabled ? local.api_domain : ""
@@ -30,6 +30,18 @@ db_password = "CHANGE_ME_strong_password_here"
30
30
  # Pre-signup Lambda (optional — leave empty if not using custom pre-signup logic)
31
31
  # pre_signup_lambda_zip = "./lambdas/pre-signup.zip"
32
32
 
33
+ # Lambda artifacts:
34
+ # - Source checkout deploys can set lambda_zips_dir after `pnpm build:lambdas`.
35
+ # - Enterprise deployment repos should upload release zips to their
36
+ # customer-owned artifact bucket and set lambda_artifact_bucket/prefix.
37
+ # - Set require_lambda_artifacts=true in generated enterprise stage files so
38
+ # Terraform fails before creating placeholder-only API handlers.
39
+ #
40
+ # lambda_zips_dir = "../../dist/lambdas"
41
+ # lambda_artifact_bucket = "customer-thinkwork-release-artifacts"
42
+ # lambda_artifact_prefix = "releases/v1.2.3/lambdas"
43
+ # require_lambda_artifacts = true
44
+
33
45
  # Google Places API key (optional — leave empty to run compile pipeline
34
46
  # without live place-hierarchy enrichment; records fall back to
35
47
  # metadata-only rows and no country/city backing pages are auto-created).
@@ -7,7 +7,7 @@
7
7
  # ---------------------------------------------------------------------------
8
8
 
9
9
  resource "aws_sqs_queue" "eval_fanout_dlq" {
10
- count = local.use_local_zips ? 1 : 0
10
+ count = local.deploy_lambda_handlers ? 1 : 0
11
11
  name = "thinkwork-${var.stage}-eval-fanout-dlq.fifo"
12
12
  fifo_queue = true
13
13
  message_retention_seconds = 1209600 # 14 days
@@ -19,7 +19,7 @@ resource "aws_sqs_queue" "eval_fanout_dlq" {
19
19
  }
20
20
 
21
21
  resource "aws_sqs_queue" "eval_fanout" {
22
- count = local.use_local_zips ? 1 : 0
22
+ count = local.deploy_lambda_handlers ? 1 : 0
23
23
  name = "thinkwork-${var.stage}-eval-fanout.fifo"
24
24
  fifo_queue = true
25
25
  content_based_deduplication = true
@@ -38,7 +38,7 @@ resource "aws_sqs_queue" "eval_fanout" {
38
38
  }
39
39
 
40
40
  resource "aws_iam_role_policy" "eval_fanout_send" {
41
- count = local.use_local_zips ? 1 : 0
41
+ count = local.deploy_lambda_handlers ? 1 : 0
42
42
  name = "eval-fanout-send"
43
43
  role = aws_iam_role.lambda.id
44
44
 
@@ -57,7 +57,7 @@ resource "aws_iam_role_policy" "eval_fanout_send" {
57
57
  }
58
58
 
59
59
  resource "aws_iam_role_policy" "eval_worker_sqs" {
60
- count = local.use_local_zips ? 1 : 0
60
+ count = local.deploy_lambda_handlers ? 1 : 0
61
61
  name = "eval-worker-sqs"
62
62
  role = aws_iam_role.lambda.id
63
63
 
@@ -86,7 +86,7 @@ resource "aws_iam_role_policy" "eval_worker_sqs" {
86
86
  }
87
87
 
88
88
  resource "aws_lambda_event_source_mapping" "eval_fanout" {
89
- count = local.use_local_zips ? 1 : 0
89
+ count = local.deploy_lambda_handlers ? 1 : 0
90
90
 
91
91
  event_source_arn = aws_sqs_queue.eval_fanout[0].arn
92
92
  function_name = aws_lambda_function.handler["eval-worker"].function_name
@@ -100,7 +100,7 @@ resource "aws_lambda_event_source_mapping" "eval_fanout" {
100
100
  }
101
101
 
102
102
  resource "aws_lambda_function_event_invoke_config" "eval_worker" {
103
- count = local.use_local_zips ? 1 : 0
103
+ count = local.deploy_lambda_handlers ? 1 : 0
104
104
 
105
105
  function_name = aws_lambda_function.handler["eval-worker"].function_name
106
106
  maximum_event_age_in_seconds = 3600
@@ -108,7 +108,7 @@ resource "aws_lambda_function_event_invoke_config" "eval_worker" {
108
108
  }
109
109
 
110
110
  resource "aws_cloudwatch_metric_alarm" "eval_fanout_dlq_depth" {
111
- count = local.use_local_zips ? 1 : 0
111
+ count = local.deploy_lambda_handlers ? 1 : 0
112
112
 
113
113
  alarm_name = "thinkwork-${var.stage}-eval-fanout-dlq-depth"
114
114
  alarm_description = "Eval fan-out DLQ has messages — eval-worker crashed before recording a case result; operator must inspect."