@opengeni/runtime 0.2.0

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 (65) hide show
  1. package/dist/chunk-2PO56VAL.js +3478 -0
  2. package/dist/chunk-2PO56VAL.js.map +1 -0
  3. package/dist/index.d.ts +912 -0
  4. package/dist/index.js +3663 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/sandbox/index.d.ts +1738 -0
  7. package/dist/sandbox/index.js +187 -0
  8. package/dist/sandbox/index.js.map +1 -0
  9. package/package.json +49 -0
  10. package/src/bundled_hashicorp_terraform_skills/LICENSE +373 -0
  11. package/src/bundled_hashicorp_terraform_skills/README.md +18 -0
  12. package/src/bundled_hashicorp_terraform_skills/UPSTREAM_GIT_SHA +1 -0
  13. package/src/bundled_hashicorp_terraform_skills/azure-verified-modules/SKILL.md +613 -0
  14. package/src/bundled_hashicorp_terraform_skills/checkov/SKILL.md +43 -0
  15. package/src/bundled_hashicorp_terraform_skills/refactor-module/SKILL.md +538 -0
  16. package/src/bundled_hashicorp_terraform_skills/social-media-marketing/SKILL.md +35 -0
  17. package/src/bundled_hashicorp_terraform_skills/terraform-search-import/SKILL.md +372 -0
  18. package/src/bundled_hashicorp_terraform_skills/terraform-search-import/references/MANUAL-IMPORT.md +113 -0
  19. package/src/bundled_hashicorp_terraform_skills/terraform-search-import/scripts/list_resources.sh +38 -0
  20. package/src/bundled_hashicorp_terraform_skills/terraform-stacks/SKILL.md +480 -0
  21. package/src/bundled_hashicorp_terraform_skills/terraform-stacks/references/api-monitoring.md +543 -0
  22. package/src/bundled_hashicorp_terraform_skills/terraform-stacks/references/component-blocks.md +476 -0
  23. package/src/bundled_hashicorp_terraform_skills/terraform-stacks/references/deployment-blocks.md +391 -0
  24. package/src/bundled_hashicorp_terraform_skills/terraform-stacks/references/examples.md +1529 -0
  25. package/src/bundled_hashicorp_terraform_skills/terraform-stacks/references/linked-stacks.md +187 -0
  26. package/src/bundled_hashicorp_terraform_skills/terraform-stacks/references/troubleshooting.md +671 -0
  27. package/src/bundled_hashicorp_terraform_skills/terraform-style-guide/SKILL.md +353 -0
  28. package/src/bundled_hashicorp_terraform_skills/terraform-test/SKILL.md +451 -0
  29. package/src/bundled_hashicorp_terraform_skills/terraform-test/references/CI_CD.md +80 -0
  30. package/src/bundled_hashicorp_terraform_skills/terraform-test/references/EXAMPLES.md +314 -0
  31. package/src/bundled_hashicorp_terraform_skills/terraform-test/references/MOCK_PROVIDERS.md +171 -0
  32. package/src/codex-tool-search.ts +267 -0
  33. package/src/context-compaction.ts +538 -0
  34. package/src/history-sanitizer.ts +719 -0
  35. package/src/index.ts +3299 -0
  36. package/src/sandbox/capabilities.ts +69 -0
  37. package/src/sandbox/channel-a.ts +1031 -0
  38. package/src/sandbox/display-stack.ts +231 -0
  39. package/src/sandbox/errors.ts +34 -0
  40. package/src/sandbox/index.ts +832 -0
  41. package/src/sandbox/providers/blaxel.ts +35 -0
  42. package/src/sandbox/providers/cloudflare.ts +24 -0
  43. package/src/sandbox/providers/daytona.ts +34 -0
  44. package/src/sandbox/providers/docker.ts +17 -0
  45. package/src/sandbox/providers/e2b.ts +36 -0
  46. package/src/sandbox/providers/index.ts +107 -0
  47. package/src/sandbox/providers/local.ts +13 -0
  48. package/src/sandbox/providers/modal.ts +55 -0
  49. package/src/sandbox/providers/none.ts +13 -0
  50. package/src/sandbox/providers/runloop.ts +32 -0
  51. package/src/sandbox/providers/selfhosted.ts +96 -0
  52. package/src/sandbox/providers/types.ts +38 -0
  53. package/src/sandbox/providers/vercel.ts +29 -0
  54. package/src/sandbox/recording.ts +286 -0
  55. package/src/sandbox/routing/backend-resolver.ts +189 -0
  56. package/src/sandbox/routing/routing-session.ts +455 -0
  57. package/src/sandbox/select.ts +371 -0
  58. package/src/sandbox/selfhosted/capabilities.ts +255 -0
  59. package/src/sandbox/selfhosted/control-rpc.ts +351 -0
  60. package/src/sandbox/selfhosted/session.ts +930 -0
  61. package/src/sandbox/selfhosted/testing.ts +230 -0
  62. package/src/sandbox/stream-port.ts +185 -0
  63. package/src/sandbox/stream-token.ts +90 -0
  64. package/src/sandbox/terminal-server.ts +203 -0
  65. package/src/sandbox-computer.ts +835 -0
@@ -0,0 +1,372 @@
1
+ ---
2
+ name: terraform-search-import
3
+ description: Discover existing cloud resources using Terraform Search queries and bulk import them into Terraform management. Use when bringing unmanaged infrastructure under Terraform control, auditing cloud resources, or migrating to IaC.
4
+ metadata:
5
+ copyright: Copyright IBM Corp. 2026
6
+ version: "0.1.0"
7
+ compatibility: Requires Terraform >= 1.14 and providers with list resource support (always use latest provider version)
8
+ ---
9
+
10
+ # Terraform Search and Bulk Import
11
+
12
+ Discover existing cloud resources using declarative queries and generate configuration for bulk import into Terraform state.
13
+
14
+ **References:**
15
+ - [Terraform Search - list block](https://developer.hashicorp.com/terraform/language/block/tfquery/list)
16
+ - [Bulk Import](https://developer.hashicorp.com/terraform/language/import/bulk)
17
+
18
+ ## When to Use
19
+
20
+ - Bringing unmanaged resources under Terraform control
21
+ - Auditing existing cloud infrastructure
22
+ - Migrating from manual provisioning to IaC
23
+ - Discovering resources across multiple regions/accounts
24
+
25
+ ## IMPORTANT: Check Provider Support First
26
+
27
+ **BEFORE starting, you MUST verify the target resource type is supported:**
28
+
29
+ ```bash
30
+ # Check what list resources are available
31
+ ./scripts/list_resources.sh aws # Specific provider
32
+ ./scripts/list_resources.sh # All configured providers
33
+ ```
34
+
35
+ ## Decision Tree
36
+
37
+ 1. **Identify target resource type** (e.g., aws_s3_bucket, aws_instance)
38
+ 2. **Check if supported**: Run `./scripts/list_resources.sh <provider>`
39
+ 3. **Choose workflow**:
40
+ - ** If supported**: Check for terraform version available.
41
+ - ** If terraform version is above 1.14.0** Use Terraform Search workflow (below)
42
+ - ** If not supported or terraform version is below 1.14.0 **: Use Manual Discovery workflow (see [references/MANUAL-IMPORT.md](references/MANUAL-IMPORT.md))
43
+
44
+ **Note**: The list of supported resources is rapidly expanding. Always verify current support before using manual import.
45
+
46
+ ## Prerequisites
47
+
48
+ Before writing queries, verify the provider supports list resources for your target resource type.
49
+
50
+ ### Discover Available List Resources
51
+
52
+ Run the helper script to extract supported list resources from your provider:
53
+
54
+ ```bash
55
+ # From a directory with provider configuration (runs terraform init if needed)
56
+ ./scripts/list_resources.sh aws # Specific provider
57
+ ./scripts/list_resources.sh # All configured providers
58
+ ```
59
+
60
+ Or manually query the provider schema:
61
+
62
+ ```bash
63
+ terraform providers schema -json | jq '.provider_schemas | to_entries | map({key: (.key | split("/")[-1]), value: (.value.list_resource_schemas // {} | keys)})'
64
+ ```
65
+
66
+ Terraform Search requires an initialized working directory. Ensure you have a configuration with the required provider before running queries:
67
+
68
+ ```hcl
69
+ # terraform.tf
70
+ terraform {
71
+ required_providers {
72
+ aws = {
73
+ source = "hashicorp/aws"
74
+ version = "~> 6.0"
75
+ }
76
+ }
77
+ }
78
+ ```
79
+
80
+ Run `terraform init` to download the provider, then proceed with queries.
81
+
82
+ ## Terraform Search Workflow (Supported Resources Only)
83
+
84
+ 1. Create `.tfquery.hcl` files with `list` blocks defining search queries
85
+ 2. Run `terraform query` to discover matching resources
86
+ 3. Generate configuration with `-generate-config-out=<file>`
87
+ 4. Review and refine generated `resource` and `import` blocks
88
+ 5. Run `terraform plan` and `terraform apply` to import
89
+
90
+ ## Query File Structure
91
+
92
+ Query files use `.tfquery.hcl` extension and support:
93
+ - `provider` blocks for authentication
94
+ - `list` blocks for resource discovery
95
+ - `variable` and `locals` blocks for parameterization
96
+
97
+ ```hcl
98
+ # discovery.tfquery.hcl
99
+ provider "aws" {
100
+ region = "us-west-2"
101
+ }
102
+
103
+ list "aws_instance" "all" {
104
+ provider = aws
105
+ }
106
+ ```
107
+
108
+ ## List Block Syntax
109
+
110
+ ```hcl
111
+ list "<list_type>" "<symbolic_name>" {
112
+ provider = <provider_reference> # Required
113
+
114
+ # Optional: filter configuration (provider-specific)
115
+ # The `config` block schema is provider-specific. Discover available options using `terraform providers schema -json | jq '.provider_schemas."registry.terraform.io/hashicorp/<provider>".list_resource_schemas."<resource_type>"'`
116
+
117
+ config {
118
+ filter {
119
+ name = "<filter_name>"
120
+ values = ["<value1>", "<value2>"]
121
+ }
122
+ region = "<region>" # AWS-specific
123
+ }
124
+ # Optional: limit results
125
+ limit = 100
126
+ }
127
+ ```
128
+
129
+ ## Supported List Resources
130
+
131
+ Provider support for list resources varies by version. **Always check what's available for your specific provider version using the discovery script.**
132
+
133
+ ## Query Examples
134
+
135
+ ### Basic Discovery
136
+
137
+ ```hcl
138
+ # Find all EC2 instances in configured region
139
+ list "aws_instance" "all" {
140
+ provider = aws
141
+ }
142
+ ```
143
+
144
+ ### Filtered Discovery
145
+
146
+ ```hcl
147
+ # Find instances by tag
148
+ list "aws_instance" "production" {
149
+ provider = aws
150
+
151
+ config {
152
+ filter {
153
+ name = "tag:Environment"
154
+ values = ["production"]
155
+ }
156
+ }
157
+ }
158
+
159
+ # Find instances by type
160
+ list "aws_instance" "large" {
161
+ provider = aws
162
+
163
+ config {
164
+ filter {
165
+ name = "instance-type"
166
+ values = ["t3.large", "t3.xlarge"]
167
+ }
168
+ }
169
+ }
170
+ ```
171
+
172
+ ### Multi-Region Discovery
173
+
174
+ ```hcl
175
+ provider "aws" {
176
+ region = "us-west-2"
177
+ }
178
+
179
+ locals {
180
+ regions = ["us-west-2", "us-east-1", "eu-west-1"]
181
+ }
182
+
183
+ list "aws_instance" "all_regions" {
184
+ for_each = toset(local.regions)
185
+ provider = aws
186
+
187
+ config {
188
+ region = each.value
189
+ }
190
+ }
191
+ ```
192
+
193
+ ### Parameterized Queries
194
+
195
+ ```hcl
196
+ variable "target_environment" {
197
+ type = string
198
+ default = "staging"
199
+ }
200
+
201
+ list "aws_instance" "by_env" {
202
+ provider = aws
203
+
204
+ config {
205
+ filter {
206
+ name = "tag:Environment"
207
+ values = [var.target_environment]
208
+ }
209
+ }
210
+ }
211
+ ```
212
+
213
+ ## Running Queries
214
+
215
+ ```bash
216
+ # Execute queries and display results
217
+ terraform query
218
+
219
+ # Generate configuration file
220
+ terraform query -generate-config-out=imported.tf
221
+
222
+ # Pass variables
223
+ terraform query -var='target_environment=production'
224
+ ```
225
+
226
+ ## Query Output Format
227
+
228
+ ```
229
+ list.aws_instance.all account_id=123456789012,id=i-0abc123,region=us-west-2 web-server
230
+ ```
231
+
232
+ Columns: `<query_address> <identity_attributes> <name_tag>`
233
+
234
+ ## Generated Configuration
235
+
236
+ The `-generate-config-out` flag creates:
237
+
238
+ ```hcl
239
+ # __generated__ by Terraform
240
+ resource "aws_instance" "all_0" {
241
+ ami = "ami-0c55b159cbfafe1f0"
242
+ instance_type = "t2.micro"
243
+ # ... all attributes
244
+ }
245
+
246
+ import {
247
+ to = aws_instance.all_0
248
+ provider = aws
249
+ identity = {
250
+ account_id = "123456789012"
251
+ id = "i-0abc123"
252
+ region = "us-west-2"
253
+ }
254
+ }
255
+ ```
256
+
257
+ ## Post-Generation Cleanup
258
+
259
+ Generated configuration includes all attributes. Clean up by:
260
+
261
+ 1. Remove computed/read-only attributes
262
+ 2. Replace hardcoded values with variables
263
+ 3. Add proper resource naming
264
+ 4. Organize into appropriate files
265
+
266
+ ```hcl
267
+ # Before: generated
268
+ resource "aws_instance" "all_0" {
269
+ ami = "ami-0c55b159cbfafe1f0"
270
+ instance_type = "t2.micro"
271
+ arn = "arn:aws:ec2:..." # Remove - computed
272
+ id = "i-0abc123" # Remove - computed
273
+ # ... many more attributes
274
+ }
275
+
276
+ # After: cleaned
277
+ resource "aws_instance" "web_server" {
278
+ ami = var.ami_id
279
+ instance_type = var.instance_type
280
+ subnet_id = var.subnet_id
281
+
282
+ tags = {
283
+ Name = "web-server"
284
+ Environment = var.environment
285
+ }
286
+ }
287
+ ```
288
+
289
+ ## Import by Identity
290
+
291
+ Generated imports use identity-based import (Terraform 1.12+):
292
+
293
+ ```hcl
294
+ import {
295
+ to = aws_instance.web
296
+ provider = aws
297
+ identity = {
298
+ account_id = "123456789012"
299
+ id = "i-0abc123"
300
+ region = "us-west-2"
301
+ }
302
+ }
303
+ ```
304
+
305
+ ## Best Practices
306
+
307
+ ### Query Design
308
+ - Start broad, then add filters to narrow results
309
+ - Use `limit` to prevent overwhelming output
310
+ - Test queries before generating configuration
311
+
312
+ ### Configuration Management
313
+ - Review all generated code before applying
314
+ - Remove unnecessary default values
315
+ - Use consistent naming conventions
316
+ - Add proper variable abstraction
317
+
318
+ ## Troubleshooting
319
+
320
+ | Issue | Solution |
321
+ |-------|----------|
322
+ | "No list resources found" | Check provider version supports list resources |
323
+ | Query returns empty | Verify region and filter values |
324
+ | Generated config has errors | Remove computed attributes, fix deprecated arguments |
325
+ | Import fails | Ensure resource not already in state |
326
+
327
+ ## Complete Example
328
+
329
+ ```hcl
330
+ # main.tf - Initialize provider
331
+ terraform {
332
+ required_version = ">= 1.14"
333
+ required_providers {
334
+ aws = {
335
+ source = "hashicorp/aws"
336
+ version = "~> 6.0" # Always use latest version
337
+ }
338
+ }
339
+ }
340
+
341
+ # discovery.tfquery.hcl - Define queries
342
+ provider "aws" {
343
+ region = "us-west-2"
344
+ }
345
+
346
+ list "aws_instance" "team_instances" {
347
+ provider = aws
348
+
349
+ config {
350
+ filter {
351
+ name = "tag:Owner"
352
+ values = ["platform"]
353
+ }
354
+ filter {
355
+ name = "instance-state-name"
356
+ values = ["running"]
357
+ }
358
+ }
359
+
360
+ limit = 50
361
+ }
362
+ ```
363
+
364
+ ```bash
365
+ # Execute workflow
366
+ terraform init
367
+ terraform query
368
+ terraform query -generate-config-out=generated.tf
369
+ # Review and clean generated.tf
370
+ terraform plan
371
+ terraform apply
372
+ ```
@@ -0,0 +1,113 @@
1
+ # Manual Terraform Import Reference
2
+
3
+ Use this workflow when your target resource type isn't supported by Terraform Search.
4
+
5
+ ## 1. Discover Resources Using Provider CLI
6
+
7
+ AWS CLI examples:
8
+
9
+ ```bash
10
+ # RDS instances (not yet supported by Terraform Search)
11
+ aws rds describe-db-instances --query 'DBInstances[].DBInstanceIdentifier'
12
+
13
+ # DynamoDB tables (not yet supported by Terraform Search)
14
+ aws dynamodb list-tables --query 'TableNames[]'
15
+
16
+ # API Gateway REST APIs (not yet supported by Terraform Search)
17
+ aws apigateway get-rest-apis --query 'items[].id'
18
+
19
+ # SNS topics (not yet supported by Terraform Search)
20
+ aws sns list-topics --query 'Topics[].TopicArn'
21
+ ```
22
+
23
+ ## 2. Create Resource Blocks Manually
24
+
25
+ ```hcl
26
+ # Example for RDS instance
27
+ resource "aws_db_instance" "existing_db" {
28
+ identifier = "my-existing-db"
29
+ # Add other required attributes
30
+ }
31
+
32
+ # Example for DynamoDB table
33
+ resource "aws_dynamodb_table" "existing_table" {
34
+ name = "my-existing-table"
35
+ # Add other required attributes
36
+ }
37
+
38
+ # Example for SNS topic
39
+ resource "aws_sns_topic" "existing_topic" {
40
+ name = "my-existing-topic"
41
+ }
42
+ ```
43
+
44
+ ## 3. Create Import Blocks (Config-Driven Import)
45
+
46
+ ```hcl
47
+ # Example for RDS instance
48
+ resource "aws_db_instance" "existing_db" {
49
+ identifier = "my-existing-db"
50
+ # Add other required attributes
51
+ }
52
+
53
+ import {
54
+ to = aws_db_instance.existing_db
55
+ id = "my-existing-db"
56
+ }
57
+
58
+ # Example for DynamoDB table
59
+ resource "aws_dynamodb_table" "existing_table" {
60
+ name = "my-existing-table"
61
+ # Add other required attributes
62
+ }
63
+
64
+ import {
65
+ to = aws_dynamodb_table.existing_table
66
+ id = "my-existing-table"
67
+ }
68
+ ```
69
+
70
+ ## 4. Run Import Plan
71
+
72
+ ```bash
73
+ # Plan the import to see what will happen
74
+ terraform plan
75
+
76
+ # Apply to import the resources
77
+ terraform apply
78
+ ```
79
+
80
+ ## Bulk Import Script Example
81
+
82
+ For multiple resources of the same type:
83
+
84
+ ```bash
85
+ #!/bin/bash
86
+ # bulk-import-dynamodb.sh
87
+
88
+ # Get all table names
89
+ tables=$(aws dynamodb list-tables --query 'TableNames[]' --output text)
90
+
91
+ # Generate import configuration
92
+ cat > dynamodb-imports.tf << 'EOF'
93
+ # DynamoDB Table Resources and Imports
94
+ EOF
95
+
96
+ for table in $tables; do
97
+ # Create resource and import blocks
98
+ cat >> dynamodb-imports.tf << EOF
99
+ resource "aws_dynamodb_table" "table_${table//[-.]/_}" {
100
+ name = "$table"
101
+ }
102
+
103
+ import {
104
+ to = aws_dynamodb_table.table_${table//[-.]/_}
105
+ id = "$table"
106
+ }
107
+
108
+ EOF
109
+ done
110
+
111
+ echo "Generated dynamodb-imports.tf with import blocks"
112
+ echo "Run 'terraform plan' to review, then 'terraform apply' to import"
113
+ ```
@@ -0,0 +1,38 @@
1
+ #!/bin/bash
2
+ # Copyright IBM Corp. 2025, 2026
3
+ # SPDX-License-Identifier: MPL-2.0
4
+
5
+ # Extract list resources supported by Terraform providers
6
+ # Usage: ./list_resources.sh [provider_name]
7
+ # Requires: terraform, jq
8
+ # Note: Run from an initialized Terraform directory (terraform init)
9
+
10
+ set -e
11
+
12
+ PROVIDER=$1
13
+
14
+ # Ensure terraform is initialized
15
+ if [ ! -d ".terraform" ]; then
16
+ echo "Initializing Terraform..." >&2
17
+ terraform init -upgrade > /dev/null 2>&1
18
+ fi
19
+
20
+ # Get provider schema and extract list_resource_schemas
21
+ if [ -n "$PROVIDER" ]; then
22
+ # Specific provider
23
+ provider_key=$(terraform providers schema -json 2>/dev/null | jq -r '.provider_schemas | keys[]' | grep "/${PROVIDER}$" || true)
24
+ if [ -n "$provider_key" ]; then
25
+ terraform providers schema -json 2>/dev/null | jq -r \
26
+ "{\"$PROVIDER\": (.provider_schemas.\"${provider_key}\" | .list_resource_schemas // {} | keys | sort)}"
27
+ else
28
+ echo "{\"$PROVIDER\": []}"
29
+ fi
30
+ else
31
+ # All providers
32
+ terraform providers schema -json 2>/dev/null | jq -r '
33
+ .provider_schemas
34
+ | to_entries
35
+ | map({key: (.key | split("/")[-1]), value: (.value.list_resource_schemas // {} | keys | sort)})
36
+ | from_entries
37
+ '
38
+ fi