Skip to content

Commit ddf8c50

Browse files
bsquizzclaude
andauthored
feat: OpenShell SSH payload delivery, runner MCP hardening, and ConfigMap reconciler removal (openshift-online#246)
* feat(rbac): add GitOps resource gating with RBAC_ENABLED and auto-create projects Introduce RBAC_ENABLED env var (default true) that restricts project, agent, provider, and policy CRUD to service accounts (configmap-syncer), rejecting user-initiated mutations with 403. This decouples GitOps resource gating from gateway mode so it works independently. Key changes: - New rbac.RequireGitOpsManaged() gate on all resource mutation handlers - Static token HTTP middleware (AMBIENT_API_TOKEN) to tag service callers - Control plane auto-creates ACP projects for gateway tenant namespaces - Kind setup script defers project creation to control plane, polls for readiness - platformInfo endpoint exposes rbac_enabled flag - Gateway mode defaults to true in Makefile - Updated gateway-rbac-policy spec to document independent activation conditions Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: rename test token constant to avoid false-positive secret detection Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(rbac): bypass GitOps gate in RBAC integration tests The RBAC owner-binding and auto-provisioning tests create projects as regular users, but the GitOps gate rejects non-service-caller mutations when RBAC is enabled (the default). These tests verify service-layer RBAC behavior, not the GitOps gate, so they disable it via a new OverrideForTesting helper. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(rbac): use pointer override to bypass init-time sync.Once latch The previous OverrideForTesting reset the sync.Once, but platformInfo's init() calls IsRBACEnabled() at import time before any test runs, latching the value permanently. Switch to a pointer-based override that IsRBACEnabled() checks before the sync.Once cache. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(rbac): address Amber review — add tests, fix search injection 1. Add unit tests for gitops_gate.go covering IsRBACEnabled defaults, OverrideForTesting, and RequireGitOpsManaged paths (service caller, user caller, disabled). 2. Add integration test verifying the RBAC_ENABLED=true path end-to-end: user requests get 403, service account requests succeed. Registers a pre-auth middleware for the test service token so the full middleware chain (staticTokenHTTPMiddleware → IsServiceCaller → RequireGitOpsManaged) is exercised. 3. Fix search query injection in ensureProject — replace string concatenation with list-all and filter in Go, removing the injection surface entirely. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(rbac): use valid JWT for service account integration test The previous approach registered a pre-auth middleware with a static token, but the upstream JWT handler wraps outside pre-auth middlewares in the chain, so non-JWT tokens get rejected with 401 before pre-auth ever runs. Switch to creating a real JWT whose username matches the configured service account — this tests the actual OIDC-based service caller detection path in the RBAC middleware. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(rbac): bypass GitOps gate in agent and project plugin integration tests These tests exercise CRUD via HTTP endpoints as regular users, but the GitOps gate defaults RBAC to enabled, rejecting non-service-account mutations with 403. Add OverrideForTesting(false) to each affected test. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(ci): provide dummy Vertex credentials in local-dev test The test-local-dev-simulation job now creates a dummy vertex.json and passes VERTEX_CRED to make kind-up. The Makefile explicitly forwards VERTEX_CRED to the kind-setup-vertex sub-make in both gateway and non-gateway paths. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(ci): disable gateway in local-dev test simulation CI doesn't have the gateway infrastructure, so explicitly set OPENSHELL_USE_GATEWAY=false to avoid failures. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(ci): pass Vertex AI env vars to setup-vertex-kind.sh in local-dev test The non-gateway path in kind-setup-vertex calls setup-vertex-kind.sh, which reads GOOGLE_APPLICATION_CREDENTIALS, ANTHROPIC_VERTEX_PROJECT_ID, and CLOUD_ML_REGION from the environment. CI only set VERTEX_CRED (used by the gateway path), so the script failed with [MISSING] for all three. Set dummy values in the CI workflow env and pass the Make variables through explicitly in the Makefile recipe. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(security): reduce glog verbosity to prevent Bearer token logging The rh-trex-ai framework's JSONLogFormatter dumps full HTTP request headers (including Authorization: Bearer) when glog.V(10) is active. Lower Kind overlay verbosity from -v=10 to -v=5 to prevent credential leakage in pod logs. Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(openshell): add SSH session and TCP forwarding proto definitions Add CreateSshSession, ForwardTcp, and TcpForwardInit message types to the OpenShell proto to support SSH-over-gRPC payload delivery into sandboxes with read-only root filesystems. Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(openshell): implement SSH-over-gRPC payload upload Add ssh_upload.go with GatewayClient.UploadPayloads() that writes files into running sandboxes via SSH-over-gRPC, bypassing the read-only root filesystem restriction. Update gateway interface and add golang.org/x/crypto dependency for SSH client support. Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(control-plane): add namespace labeling and payload delivery in gateway mode Wire NamespaceProvisioner into initGatewayProvisioning to apply managed labels to gateway namespaces for ConfigMapSyncer discovery. Add payload delivery via SSH upload in execAfterReady. Update runner path from /sandbox/runner to /runner and switch inbox messages to ListByAgent API. Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(runner): restructure paths from /sandbox/runner to /runner and update sandbox config Move runner files to /runner to avoid conflicts with the sandbox read-only root filesystem. Add atlassian-mcp to the image, update sandbox policy with include_workdir and refined filesystem rules, and add example-jira-agent.yaml for Jira MCP agent declarations. Co-Authored-By: Claude Opus 4.6 <[email protected]> * docs(specs): update platform specs for SSH payload delivery, namespace labels, and path changes Update gateway-provisioning spec with managed namespace labels and SSH-over-gRPC payload delivery requirements. Update sandbox provisioning spec for /runner path and gateway-init namespace labeling. Update agent-sandbox-config spec with generic credential type and SSH delivery mechanism. Update runner spec with /runner path. Co-Authored-By: Claude Opus 4.6 <[email protected]> * Tweak sandbox config * fix(security): validate SSH payload paths and pin atlassian-mcp version Address PR review findings: add path validation to prevent shell injection via crafted sandbox_path values, replace strings.LastIndex with filepath.Dir to prevent panic on paths without '/', add SSH trust model documentation matching OpenShell upstream patterns, pin atlassian-mcp==0.21.1 for reproducible builds, and add unit tests for payload path validation. Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat: remove RBAC GitOps gating and ConfigMapSyncer, add payloads to acpctl apply Remove RequireGitOpsManaged guards from all API handlers, delete gitops_gate.go, ConfigMapSyncer (replaced by acpctl apply -k), and ensureProject/namespace labeling (no longer needed without ConfigMapSyncer). Add payloads support to acpctl apply for the Agent kind so declarative YAML can specify files to upload into the sandbox via SSH-over-gRPC. Convert the JIRA agent example from ConfigMap format to a native ACP kustomize overlay with payloads. Co-Authored-By: Claude Opus 4.6 <[email protected]> * refactor(examples): move jira agent to base, jira infra to tenant-a Move jira-task-summarizer agent into base/agents/ so all tenants inherit it. Move jira provider and credential into tenant-a overlay. Remove the standalone jira-demo overlay. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(cli): always rebuild acpctl during kind-up to prevent stale binaries Add build-cli as a prerequisite of the kind-up target so acpctl is always compiled from current source. Remove the now-redundant conditional build logic in the OPENSHELL_USE_GATEWAY block. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(cli): install acpctl to ~/.local/bin during build-cli Ensures the PATH-resolved binary stays in sync with the built source, preventing stale binary issues. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(examples): add VERTEX_CRED default and credential setup comments Default VERTEX_CRED to GOOGLE_APPLICATION_CREDENTIALS so kind-up auto-detects the user's ADC without requiring an explicit path. Add prerequisite comments to provider examples showing how to create the backing K8s secrets (carried over from PR 246 ConfigMap examples). Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(runner): pin atlassian-mcp to 1.0.0 in openshell image Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(runner): add .dockerignore to exclude .venv and build artifacts from openshell image The COPY . /runner/ambient-runner step was pulling in the local .venv (92MB), __pycache__, and .egg-info directories into the build context and image layer unnecessarily. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(control-plane): delete sandbox when session completes in gateway mode Previously, completed sessions in gateway mode never had their sandboxes cleaned up (FIXME openshift-online#223). The exec stream left sessions in Running phase indefinitely, and the reconciler skipped deprovision for Completed in gateway mode. Both sides now work: execAfterReady marks the session PhaseCompleted, and the reconciler handles Completed uniformly across pod and gateway modes. Co-Authored-By: Claude Opus 4.6 <[email protected]> * docs(skills): add podman ctr image loading guidance to kind skills kind load docker-image is unreliable on podman-based clusters and may load stale image IDs. Updated dev-cluster and kind skills with the direct ctr import method (podman save/cp/exec) as the recommended approach. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(runner): remove stray WORKDIR and add /runner to sandbox policy Remove the intermediate `WORKDIR /runner` from Dockerfile.openshell that caused `openshell sandbox connect` to land in /sandbox/runner instead of /sandbox. Add /runner to the read_only filesystem policy so the runner process can read its entrypoint and Python code under Landlock. Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(runner): add Atlassian network policy to sandbox default Allow mcp-atlassian MCP server to reach Jira and Confluence REST APIs (*.atlassian.net, *.atlassian.com, auth/api.atlassian.com) from inside the sandbox. The MCP server is a Python script so binaries reference the venv Python interpreters. Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(runner): bake Claude Code config into openshell image Add claude.json (trust config) and claude-settings.json (permissions) as build-time artifacts copied into the image. This replaces the runtime bootstrapping in the wrapper script, which wrote minimal defaults on first invocation. The settings include granular Bash allow/deny lists and pre-approve mcp-atlassian tools. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(runner): enable mcp-atlassian server in claude settings Add enabledMcpjsonServers so Claude Code auto-approves the mcp-atlassian MCP server declared in .mcp.json payloads. Co-Authored-By: Claude Opus 4.6 <[email protected]> * refactor(examples): rename jira-task-summarizer to jira-simple-whoami Simplifies the example Jira agent to a basic whoami check instead of a multi-step task summary, making it a better smoke test for Jira integration. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(control-plane): patch sandbox ndots via CR instead of in-container sed The sed/tee workaround in execAfterReady was unreliable against read-only bind-mounted resolv.conf and was skipped entirely on the already-exists sandbox path, leaving ndots:5 in place. Replace it with the CR-level dnsConfig patch on both new and pre-existing sandbox paths. Workaround for NVIDIA/OpenShell#2053 Co-Authored-By: Claude Opus 4.6 <[email protected]> * Revert "fix(control-plane): delete sandbox when session completes in gateway mode" This reverts commit c0a81bd. * Tweak claude settings in runner * fix(runner): restore allowed_tools in SDK options to fix MCP permission denials The SDK's acceptEdits permission mode only auto-approves file edit tools, not MCP tools. Settings file permissions alone are insufficient in SDK mode — allowed_tools must be passed explicitly in the SDK options dict. Also loads all three setting sources (user, project, local), merges cwd-level .mcp.json for payload-injected servers, and adds comprehensive permissions to claude-settings.json as belt-and-suspenders. Co-Authored-By: Claude Opus 4.6 <[email protected]> * refactor(runner): stop expanding env vars in MCP config, preserve gateway credentials MCP server configs now pass ${VAR} patterns through as-is instead of eagerly expanding them. This is critical for OpenShell gateway mode where credentials use lazy-resolution tokens (openshell:resolve:env:) that the backend cannot repopulate. Also removes the PROJECT_MCP_SERVERS / CUSTOM_MCP_SERVERS / disabled merge layers — config now loads from baked-in + cwd-level .mcp.json only. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(runner): remove credential wiper that was clearing agent environment vars clear_runtime_credentials was designed for a shared-session multi-user model that no longer exists — pods and gateway sandboxes are both per-session. The wiper was actively harmful: it cleared non-secret config like JIRA_URL set via the Agent environment field, and interfered with OpenShell gateway lazy-resolution tokens. Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(runner): bake JIRA MCP into image, add skill-payload example, wire environment in acpctl apply - Add mcp.json with mcp-atlassian config and COPY it to /sandbox/.mcp.json in Dockerfile.openshell so JIRA MCP is available out of the box - Simplify jira-simple-whoami agent: remove payload, add environment.JIRA_URL - Add jira-simple-whoami-with-skill-payload example demonstrating SKILL.md payload pattern - Fix acpctl apply: the resource struct was missing the environment field, so Agent environment vars were silently dropped on create and patch Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(examples): use absolute path for SKILL.md in jira-simple-whoami agent Co-Authored-By: Claude Opus 4.6 <[email protected]> * chore: fix lint and format issues in runner and Go integration tests Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(security): address PR review feedback — SSH host key verification, MCP config trust boundary, narrow deny rules - Verify SSH host key fingerprint from CreateSshSession response instead of InsecureIgnoreHostKey, falling back to accept when gateway doesn't pin one - Stop reading .mcp.json from cwd (user-controlled workspace) — merge only from platform-controlled PAYLOAD_MCP_CONFIG_FILE (default /sandbox/.mcp.json) - Narrow curl/chmod deny rules to target dangerous operations (upload/exfil, chmod 777) instead of blanket-blocking legitimate agent usage - Update tests to cover new trust boundary (test_ignores_cwd_mcp_json) Co-Authored-By: Claude Opus 4.6 <[email protected]> * test(e2e): verify sandbox payload upload, env vars, MCP config, and baked-in settings Add payload and environment variable to hello-world agent. Extend the gateway e2e test with section 9 (sandbox configuration verification): - 9a: payload file uploaded via SSH-over-gRPC - 9b: agent env var passed through to sandbox (not wiped) - 9c: MCP config ${} patterns preserved (not auto-expanded) - 9d: claude settings.json matches source - 9e: claude settings.local.json matches source - 9f: sandbox policy.yaml at /etc/openshell/policy.yaml matches source Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix(manifests): remove duplicate -v=8 flag in api-server migration init container Co-Authored-By: Claude Opus 4.6 <[email protected]> * docs(specs): update runner spec for MCP config, credentials, baked-in files, and policy changes Co-Authored-By: Claude Opus 4.6 <[email protected]> * docs(specs): update provisioning spec for DNS patching, SSH payloads, and proto vendoring Add DNS Configuration via Sandbox CRD Patch requirement (patchSandboxDNSConfig workaround for OpenShell#2053), Payload Upload via SSH requirement (CreateSshSession/ForwardTcp), update proto vendoring with new RPCs and messages, add migration table entries for UploadPayloads, ExecSandboxStreaming, patchSandboxDNSConfig, resolveEntrypoint path change, and ssh_upload.go. Replace stale ConfigMapSyncer reference with ApplicationReconciler. Co-Authored-By: Claude Opus 4.6 <[email protected]> * docs(specs): add /runner to sandbox filesystem read-only paths The gateway runner image uses /runner as its runner directory root. Add it to the Landlock read-only path list alongside /app. Co-Authored-By: Claude Opus 4.6 <[email protected]> * docs(specs): note gitAgentDeclaration missing payloads, sandbox_template, sandbox_policy The ApplicationReconciler's git-sourced declaration struct does not yet include payloads, sandbox_template, or sandbox_policy fields. Document this as a known gap under Iteration 2. Co-Authored-By: Claude Opus 4.6 <[email protected]> * feat(control-plane): add payloads field to gitAgentDeclaration struct Git-sourced agent declarations can now declare payloads, which are mapped through buildAgentPatch and buildAgentResource to the Agent entity. The UploadPayloads SSH mechanism delivers them end-to-end at sandbox creation time. Updated the agent-sandbox-config spec known-gap note to reflect that only sandbox_template and sandbox_policy remain. Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
1 parent 0b6a552 commit ddf8c50

70 files changed

Lines changed: 1826 additions & 2095 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/test-local-dev.yml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,18 @@ jobs:
133133
fi
134134
done
135135
136+
- name: Create dummy Vertex credentials
137+
run: |
138+
echo '{"type":"service_account","project_id":"test","private_key_id":"dummy","private_key":"-----BEGIN RSA PRIVATE KEY-----\nMIIBogIBAAJBALRiMLAH\n-----END RSA PRIVATE KEY-----\n","client_email":"[email protected]","client_id":"0","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token"}' > /tmp/vertex.json
139+
136140
- name: Deploy using Makefile
141+
env:
142+
GOOGLE_APPLICATION_CREDENTIALS: /tmp/vertex.json
143+
ANTHROPIC_VERTEX_PROJECT_ID: test-project
144+
CLOUD_ML_REGION: global
137145
run: |
138146
echo "Using Makefile to deploy complete stack..."
139-
make kind-up CONTAINER_ENGINE=docker CI_MODE=true
147+
make kind-up CONTAINER_ENGINE=docker CI_MODE=true VERTEX_CRED=/tmp/vertex.json OPENSHELL_USE_GATEWAY=false
140148
141149
- name: Wait for deployments
142150
run: |

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ vendor/
4343
# SDK binaries (build artifacts, not source)
4444
**/ambient-sdk-generator
4545
**/examples/examples
46+
**/ambient-control-plane/ambient-control-plane
4647

4748
# Node / Frontend
4849
node_modules/

‎Makefile‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ ANTHROPIC_VERTEX_PROJECT_ID ?= $(shell echo $$ANTHROPIC_VERTEX_PROJECT_ID)
120120
CLOUD_ML_REGION ?= $(shell echo $$CLOUD_ML_REGION)
121121
# Default to ADC location if not set (created by: gcloud auth application-default login)
122122
GOOGLE_APPLICATION_CREDENTIALS ?= $(or $(shell echo $$GOOGLE_APPLICATION_CREDENTIALS),$(HOME)/.config/gcloud/application_default_credentials.json)
123+
VERTEX_CRED ?= $(GOOGLE_APPLICATION_CREDENTIALS)
123124

124125
# OpenShell Gateway Configuration (OPENSHELL_USE_GATEWAY=true by default)
125126
# Provisions two tenant namespaces (tenant-a, tenant-b) with an OpenShell gateway each.
@@ -274,7 +275,9 @@ build-credential-google: ## Build Google credential sidecar image
274275
build-cli: ## Build acpctl CLI binary
275276
@echo "$(COLOR_BLUE)▶$(COLOR_RESET) Building acpctl CLI..."
276277
@cd components/ambient-cli && make build
277-
@echo "$(COLOR_GREEN)✓$(COLOR_RESET) CLI built: components/ambient-cli/acpctl"
278+
@install -d $(HOME)/.local/bin
279+
@install components/ambient-cli/acpctl $(HOME)/.local/bin/acpctl
280+
@echo "$(COLOR_GREEN)✓$(COLOR_RESET) CLI built and installed: $(HOME)/.local/bin/acpctl"
278281

279282
lint-cli: ## Lint acpctl CLI
280283
@echo "$(COLOR_BLUE)▶$(COLOR_RESET) Linting acpctl CLI..."
@@ -867,7 +870,7 @@ benchmark-ci: ## Run component benchmarks in CI mode
867870
$(if $(CANDIDATE),--candidate-ref $(CANDIDATE)) \
868871
$(if $(FORMAT),--format $(FORMAT))
869872

870-
kind-up: preflight-cluster ## Start kind cluster and deploy the platform (LOCAL_IMAGES=true builds from source)
873+
kind-up: preflight-cluster build-cli ## Start kind cluster and deploy the platform (LOCAL_IMAGES=true builds from source)
871874
@echo "$(COLOR_BLUE)▶$(COLOR_RESET) Starting kind cluster '$(KIND_CLUSTER_NAME)'..."
872875
@KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) KIND_HTTP_PORT=$(KIND_HTTP_PORT) KIND_HTTPS_PORT=$(KIND_HTTPS_PORT) KIND_HOST=$(KIND_HOST) CONTAINER_ENGINE=$(CONTAINER_ENGINE) ./tests/infra/setup-kind.sh
873876
@if [ -n "$(KIND_HOST)" ]; then \
@@ -938,19 +941,7 @@ kind-up: preflight-cluster ## Start kind cluster and deploy the platform (LOCAL_
938941
CLOUD_ML_REGION="$(CLOUD_ML_REGION)" \
939942
./scripts/setup-kind-openshell.sh; \
940943
echo "$(COLOR_BLUE)▶$(COLOR_RESET) Applying tenant fleet definitions via acpctl..."; \
941-
ACPCTL=""; \
942-
if command -v acpctl >/dev/null 2>&1; then \
943-
ACPCTL=acpctl; \
944-
elif [ -x components/ambient-cli/acpctl ]; then \
945-
ACPCTL=components/ambient-cli/acpctl; \
946-
elif [ -x ./acpctl ]; then \
947-
ACPCTL=./acpctl; \
948-
fi; \
949-
if [ -z "$$ACPCTL" ]; then \
950-
echo "$(COLOR_BLUE)▶$(COLOR_RESET) acpctl not found — building CLI..."; \
951-
$(MAKE) --no-print-directory build-cli; \
952-
ACPCTL=components/ambient-cli/acpctl; \
953-
fi; \
944+
ACPCTL=components/ambient-cli/acpctl; \
954945
PF_PORT=18766; \
955946
kubectl port-forward -n $(NAMESPACE) svc/ambient-api-server "$${PF_PORT}:8000" >/dev/null 2>&1 & \
956947
PF_PID=$$!; \
@@ -974,7 +965,7 @@ kind-up: preflight-cluster ## Start kind cluster and deploy the platform (LOCAL_
974965
@# Vertex AI setup if requested (non-gateway)
975966
@if [ "$(OPENSHELL_USE_GATEWAY)" != "true" ]; then \
976967
echo "$(COLOR_BLUE)▶$(COLOR_RESET) Configuring Vertex AI..."; \
977-
$(MAKE) --no-print-directory kind-setup-vertex; \
968+
$(MAKE) --no-print-directory kind-setup-vertex VERTEX_CRED="$(VERTEX_CRED)"; \
978969
fi
979970
@if [ -f .dev-bootstrap.env ] && [ -f ./scripts/bootstrap-workspace.sh ]; then \
980971
echo "$(COLOR_BLUE)▶$(COLOR_RESET) Bootstrapping developer workspace..."; \
@@ -1333,6 +1324,9 @@ kind-setup-vertex: check-kubectl _kind-require-cluster ## Configure Vertex AI fo
13331324
done; \
13341325
else \
13351326
NAMESPACE=$(NAMESPACE) \
1327+
GOOGLE_APPLICATION_CREDENTIALS="$(GOOGLE_APPLICATION_CREDENTIALS)" \
1328+
ANTHROPIC_VERTEX_PROJECT_ID="$(ANTHROPIC_VERTEX_PROJECT_ID)" \
1329+
CLOUD_ML_REGION="$(CLOUD_ML_REGION)" \
13361330
AMBIENT_UI_URL="http://$$(if [ -n "$(KIND_HOST)" ]; then echo "$(KIND_HOST)"; else echo "localhost"; fi):$(KIND_FWD_AMBIENT_UI_PORT)" \
13371331
./scripts/setup-vertex-kind.sh; \
13381332
fi

‎components/ambient-api-server/plugins/agents/integration_test.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func TestAgentGet(t *testing.T) {
7676
}
7777

7878
func TestAgentPost(t *testing.T) {
79+
7980
h, client := test.RegisterIntegration(t)
8081

8182
account := h.NewRandAccount()
@@ -126,6 +127,7 @@ func TestAgentPost(t *testing.T) {
126127
}
127128

128129
func TestAgentPostLlmDefaults(t *testing.T) {
130+
129131
h, client := test.RegisterIntegration(t)
130132

131133
account := h.NewRandAccount()
@@ -153,6 +155,7 @@ func TestAgentPostLlmDefaults(t *testing.T) {
153155
}
154156

155157
func TestAgentPatch(t *testing.T) {
158+
156159
h, client := test.RegisterIntegration(t)
157160

158161
account := h.NewRandAccount()
@@ -206,6 +209,7 @@ func TestAgentPatch(t *testing.T) {
206209
}
207210

208211
func TestAgentPatchTemperatureZeroPreserved(t *testing.T) {
212+
209213
h, client := test.RegisterIntegration(t)
210214

211215
account := h.NewRandAccount()
@@ -309,6 +313,7 @@ func TestAgentListSearch(t *testing.T) {
309313
}
310314

311315
func TestAgentDelete(t *testing.T) {
316+
312317
h, client := test.RegisterIntegration(t)
313318

314319
account := h.NewRandAccount()
@@ -337,6 +342,7 @@ func TestAgentDelete(t *testing.T) {
337342
}
338343

339344
func TestAgentCrossProjectIsolation(t *testing.T) {
345+
340346
h, client := test.RegisterIntegration(t)
341347

342348
account := h.NewRandAccount()

‎components/ambient-api-server/plugins/policies/handler.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func NewPolicyHandler(policy PolicyService, generic services.GenericService) *po
2525
}
2626

2727
func (h policyHandler) Create(w http.ResponseWriter, r *http.Request) {
28+
2829
var policy openapi.Policy
2930
cfg := &handlers.HandlerConfig{
3031
Body: &policy,
@@ -104,6 +105,7 @@ func (h policyHandler) Get(w http.ResponseWriter, r *http.Request) {
104105
}
105106

106107
func (h policyHandler) Patch(w http.ResponseWriter, r *http.Request) {
108+
107109
var patch openapi.PolicyPatchRequest
108110
cfg := &handlers.HandlerConfig{
109111
Body: &patch,
@@ -153,6 +155,7 @@ func (h policyHandler) Patch(w http.ResponseWriter, r *http.Request) {
153155
}
154156

155157
func (h policyHandler) Delete(w http.ResponseWriter, r *http.Request) {
158+
156159
cfg := &handlers.HandlerConfig{
157160
Action: func() (interface{}, *errors.ServiceError) {
158161
projectID := mux.Vars(r)["id"]

‎components/ambient-api-server/plugins/projects/handler.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func NewProjectHandler(project ProjectService, generic services.GenericService,
3333
}
3434

3535
func (h projectHandler) Create(w http.ResponseWriter, r *http.Request) {
36+
3637
var project openapi.Project
3738
cfg := &handlers.HandlerConfig{
3839
Body: &project,
@@ -55,6 +56,7 @@ func (h projectHandler) Create(w http.ResponseWriter, r *http.Request) {
5556
}
5657

5758
func (h projectHandler) Patch(w http.ResponseWriter, r *http.Request) {
59+
5860
var patch openapi.ProjectPatchRequest
5961

6062
cfg := &handlers.HandlerConfig{
@@ -157,6 +159,7 @@ func (h projectHandler) Get(w http.ResponseWriter, r *http.Request) {
157159
}
158160

159161
func (h projectHandler) Delete(w http.ResponseWriter, r *http.Request) {
162+
160163
cfg := &handlers.HandlerConfig{
161164
Action: func() (interface{}, *errors.ServiceError) {
162165
id := mux.Vars(r)["id"]

‎components/ambient-api-server/plugins/projects/integration_test.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func TestProjectGet(t *testing.T) {
4343
}
4444

4545
func TestProjectPost(t *testing.T) {
46+
4647
h, client := test.RegisterIntegration(t)
4748

4849
account := h.NewRandAccount()
@@ -72,6 +73,7 @@ func TestProjectPost(t *testing.T) {
7273
}
7374

7475
func TestProjectPatch(t *testing.T) {
76+
7577
h, client := test.RegisterIntegration(t)
7678

7779
account := h.NewRandAccount()

‎components/ambient-api-server/plugins/providers/handler.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func NewProviderHandler(provider ProviderService, generic services.GenericServic
2424
}
2525

2626
func (h providerHandler) Create(w http.ResponseWriter, r *http.Request) {
27+
2728
var provider openapi.Provider
2829
cfg := &handlers.HandlerConfig{
2930
Body: &provider,
@@ -103,6 +104,7 @@ func (h providerHandler) Get(w http.ResponseWriter, r *http.Request) {
103104
}
104105

105106
func (h providerHandler) Patch(w http.ResponseWriter, r *http.Request) {
107+
106108
var patch openapi.ProviderPatchRequest
107109
cfg := &handlers.HandlerConfig{
108110
Body: &patch,
@@ -150,6 +152,7 @@ func (h providerHandler) Patch(w http.ResponseWriter, r *http.Request) {
150152
}
151153

152154
func (h providerHandler) Delete(w http.ResponseWriter, r *http.Request) {
155+
153156
cfg := &handlers.HandlerConfig{
154157
Action: func() (interface{}, *errors.ServiceError) {
155158
projectID := mux.Vars(r)["id"]

‎components/ambient-api-server/test/integration/rbac_test.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ func TestRBAC_UserAutoProvisioned(t *testing.T) {
137137
ctx := h.NewAuthenticatedContext(account)
138138

139139
// Any authenticated request triggers auto-provisioning
140-
// POST /projects is auth-exempt so it should work
141140
projectInput := openapi.Project{Name: "auto-prov-test"}
142141
_, resp, err := client.DefaultAPI.ApiAmbientV1ProjectsPost(ctx).Project(projectInput).Execute()
143142
Expect(err).NotTo(HaveOccurred())

‎components/ambient-cli/cmd/acpctl/apply/cmd.go‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ File format (one or more documents separated by ---):
5353
ambient.io/ready: "true"
5454
annotations:
5555
work.ambient.io/current-task: ""
56+
payloads:
57+
- sandbox_path: /workspace/config.yaml
58+
content: |
59+
key: value
5660
inbox:
5761
- from_name: platform-bootstrap
5862
body: |
@@ -113,6 +117,8 @@ type resource struct {
113117
Annotations map[string]string `yaml:"annotations"`
114118
Inbox []inboxSeed `yaml:"inbox"`
115119
Providers []string `yaml:"providers"`
120+
Payloads []payloadDecl `yaml:"payloads"`
121+
Environment map[string]string `yaml:"environment"`
116122
Provider string `yaml:"provider"`
117123
Token string `yaml:"token"`
118124
URL string `yaml:"url"`
@@ -125,6 +131,13 @@ type resource struct {
125131
UserID string `yaml:"user_id"`
126132
}
127133

134+
type payloadDecl struct {
135+
SandboxPath string `yaml:"sandbox_path"`
136+
Content string `yaml:"content,omitempty"`
137+
RepoURL string `yaml:"repo_url,omitempty"`
138+
Ref string `yaml:"ref,omitempty"`
139+
}
140+
128141
type inboxSeed struct {
129142
FromName string `yaml:"from_name"`
130143
Body string `yaml:"body"`
@@ -618,6 +631,19 @@ func docDisplayName(d resource) string {
618631
return d.Kind
619632
}
620633

634+
func toSDKPayloads(decls []payloadDecl) []sdktypes.Payload {
635+
out := make([]sdktypes.Payload, len(decls))
636+
for i, d := range decls {
637+
out[i] = sdktypes.Payload{
638+
SandboxPath: d.SandboxPath,
639+
Content: d.Content,
640+
RepoURL: d.RepoURL,
641+
Ref: d.Ref,
642+
}
643+
}
644+
return out
645+
}
646+
621647
func marshalStringMap(m map[string]string) string {
622648
if len(m) == 0 {
623649
return ""
@@ -667,6 +693,12 @@ func applyAgent(ctx context.Context, client *sdkclient.Client, doc resource, pro
667693
if len(doc.Providers) > 0 {
668694
builder = builder.Providers(doc.Providers)
669695
}
696+
if len(doc.Payloads) > 0 {
697+
builder = builder.Payloads(toSDKPayloads(doc.Payloads))
698+
}
699+
if len(doc.Environment) > 0 {
700+
builder = builder.Environment(doc.Environment)
701+
}
670702
pa, buildErr := builder.Build()
671703
if buildErr != nil {
672704
return applyResult{}, buildErr
@@ -715,6 +747,12 @@ func buildAgentPatch(existing *sdktypes.Agent, doc resource) map[string]any {
715747
if len(doc.Providers) > 0 {
716748
patch["providers"] = doc.Providers
717749
}
750+
if len(doc.Payloads) > 0 {
751+
patch["payloads"] = toSDKPayloads(doc.Payloads)
752+
}
753+
if len(doc.Environment) > 0 {
754+
patch["environment"] = doc.Environment
755+
}
718756
if len(doc.Labels) > 0 {
719757
patch["labels"] = marshalStringMap(doc.Labels)
720758
}
@@ -967,6 +1005,15 @@ func strategicMerge(base, patch resource) resource {
9671005
if patch.Email != "" {
9681006
base.Email = patch.Email
9691007
}
1008+
if len(patch.Payloads) > 0 {
1009+
base.Payloads = patch.Payloads
1010+
}
1011+
for k, v := range patch.Environment {
1012+
if base.Environment == nil {
1013+
base.Environment = make(map[string]string)
1014+
}
1015+
base.Environment[k] = v
1016+
}
9701017
for k, v := range patch.Labels {
9711018
if base.Labels == nil {
9721019
base.Labels = make(map[string]string)

0 commit comments

Comments
 (0)