Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore: set up pulumi for agent_harness_service (#5747)

Wolf Mermelsteinf975a835196a
diff --git a/.github/actions/deploy-cloud-storage-pulumi/action.yml b/.github/actions/deploy-cloud-storage-pulumi/action.yml
index 421ca5e044..cca599bf96 100644
--- a/.github/actions/deploy-cloud-storage-pulumi/action.yml
+++ b/.github/actions/deploy-cloud-storage-pulumi/action.yml
@@ -190,6 +190,9 @@ runs:
command: up
stack-name: macro-inc/${{ inputs.environment }}
work-dir: ./infra/stacks/${{ inputs.pulumi-service-name }}
+ # Create the stack on first deploy of a new service; no-op for
+ # existing stacks.
+ upsert: true
env:
PULUMI_ACCESS_TOKEN: ${{ inputs.pulumi-access-token }}
DD_APP_KEY: ${{ inputs.dd-app-key }}
diff --git a/.github/services-config.json b/.github/services-config.json
index 6e17bd797e..9f3e31c610 100644
--- a/.github/services-config.json
+++ b/.github/services-config.json
@@ -1,5 +1,19 @@
{
"services": {
+ "agent-harness-service": {
+ "source_paths": [
+ "services/agent_harness_service/**",
+ "crates/agent_harness/**",
+ "crates/agent_fold/**",
+ "crates/agent_session/**",
+ "crates/agent_trigger/**",
+ "crates/agent_runtime_protocol/**"
+ ],
+ "stack_path": "infra/stacks/agent-harness-service/**",
+ "deploy_binaries": [
+ "agent_harness_service"
+ ]
+ },
"agent-schedule-service": {
"source_paths": [
"services/scheduled_action/**"
diff --git a/crates/agent_harness/src/inbound/kafka.rs b/crates/agent_harness/src/inbound/kafka.rs
index f90eebce92..f9d79624bc 100644
--- a/crates/agent_harness/src/inbound/kafka.rs
+++ b/crates/agent_harness/src/inbound/kafka.rs
@@ -11,6 +11,7 @@ use agent_trigger::domain::broker_events::{
AgentTriggerTopicEvent, ChannelEventMetadata, ExistingAgentSessionEvent, NewAgentSessionEvent,
};
use bot_id::BotId;
+use macro_user_id::email::ReadEmailParts;
use crate::domain::model::{
AnnounceOrigin, DeliverAction, HarnessCommand, MentionOrigin, OpenSession,
@@ -31,6 +32,8 @@ pub enum Skipped {
/// vocabulary is non-exhaustive on purpose, and unknown shapes are
/// skipped rather than wedging the partition.
Unrecognized,
+ /// We are in beta and only allow Macro employees to use this new harness system.
+ NotMacroStaff,
}
/// Route one trigger event: a command for `our_bot`, or a reason it was
@@ -41,6 +44,17 @@ pub fn agent_trigger_to_harness_command(
) -> Result<(AgentSessionId, HarnessCommand), Skipped> {
match event {
AgentTriggerTopicEvent::New(NewAgentSessionEvent::TopLevelMentioned(mentioned)) => {
+ // TODO: remove
+ if mentioned.message.sender.as_user().is_some_and(|user| {
+ !user
+ .email_part()
+ .lowercase()
+ .email_str()
+ .ends_with("@macro.com")
+ }) {
+ return Err(Skipped::NotMacroStaff);
+ }
+
if mentioned.bot_id != our_bot {
return Err(Skipped::ForeignBot);
}
diff --git a/crates/agent_harness/src/inbound/kafka/test.rs b/crates/agent_harness/src/inbound/kafka/test.rs
index 925ac06e7a..df5749886f 100644
--- a/crates/agent_harness/src/inbound/kafka/test.rs
+++ b/crates/agent_harness/src/inbound/kafka/test.rs
@@ -15,7 +15,7 @@ use super::*;
use crate::domain::model::HarnessCommand;
fn user() -> MacroUserIdStr<'static> {
- MacroUserIdStr::try_from_email("[email protected]").expect("a valid user id")
+ MacroUserIdStr::try_from_email("[email protected]").expect("a valid user id")
}
fn message(sender: ChannelSender<'static>) -> ChannelMessagePostedMetadata {
@@ -118,6 +118,20 @@ fn a_bot_authored_mention_is_skipped() {
);
}
+#[test]
+fn a_non_staff_mention_is_skipped() {
+ let user = MacroUserIdStr::try_from_email("[email protected]").expect("a valid user id");
+
+ assert_eq!(
+ agent_trigger_to_harness_command(
+ mentioned(BotId::TEST_A, ChannelSender::new_from_user(user)),
+ BotId::TEST_A,
+ )
+ .unwrap_err(),
+ Skipped::NotMacroStaff
+ );
+}
+
#[test]
fn a_channel_message_forwards_to_its_session() {
let (session_id, command) =
diff --git a/infra/bun.lock b/infra/bun.lock
index 375acef765..50800cb015 100644
--- a/infra/bun.lock
+++ b/infra/bun.lock
@@ -49,6 +49,10 @@
"name": "vpc",
"version": "0.0.0",
},
+ "stacks/agent-harness-service": {
+ "name": "agent-harness-service-stack",
+ "version": "0.0.0",
+ },
"stacks/agent-schedule-service": {
"name": "agent-schedule-service-stack",
"version": "0.0.0",
@@ -467,6 +471,8 @@
"agent-base": ["[email protected]", "", {}, "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ=="],
+ "agent-harness-service-stack": ["agent-harness-service-stack@workspace:stacks/agent-harness-service"],
+
"agent-schedule-service-stack": ["agent-schedule-service-stack@workspace:stacks/agent-schedule-service"],
"ansi-regex": ["[email protected]", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
diff --git a/infra/stacks/agent-harness-service/Pulumi.dev.yaml b/infra/stacks/agent-harness-service/Pulumi.dev.yaml
new file mode 100644
index 0000000000..9cfd7a1eb5
--- /dev/null
+++ b/infra/stacks/agent-harness-service/Pulumi.dev.yaml
@@ -0,0 +1,3 @@
+config:
+ aws-native:region: us-east-1
+ aws:region: us-east-1
diff --git a/infra/stacks/agent-harness-service/Pulumi.prod.yaml b/infra/stacks/agent-harness-service/Pulumi.prod.yaml
new file mode 100644
index 0000000000..9cfd7a1eb5
--- /dev/null
+++ b/infra/stacks/agent-harness-service/Pulumi.prod.yaml
@@ -0,0 +1,3 @@
+config:
+ aws-native:region: us-east-1
+ aws:region: us-east-1
diff --git a/infra/stacks/agent-harness-service/Pulumi.yaml b/infra/stacks/agent-harness-service/Pulumi.yaml
new file mode 100644
index 0000000000..34268ed388
--- /dev/null
+++ b/infra/stacks/agent-harness-service/Pulumi.yaml
@@ -0,0 +1,3 @@
+name: agent-harness-service
+runtime: nodejs
+description: Macro Agent Harness Service
diff --git a/infra/stacks/agent-harness-service/agent_harness_service.ts b/infra/stacks/agent-harness-service/agent_harness_service.ts
new file mode 100644
index 0000000000..483a65a3f2
--- /dev/null
+++ b/infra/stacks/agent-harness-service/agent_harness_service.ts
@@ -0,0 +1,449 @@
+import * as aws from '@pulumi/aws';
+import * as awsx from '@pulumi/awsx';
+import * as pulumi from '@pulumi/pulumi';
+import {
+ DATADOG_API_KEY,
+ DEFAULT_CONTINUE_BEFORE_STEADY_STATE,
+ EcsDeploymentFailureAlarm,
+ datadogAgentContainer,
+ fargateLogRouterSidecarContainer,
+ serviceLoadBalancer,
+} from '../../packages/resources';
+import { EcrImage } from '../../packages/service';
+import {
+ BASE_DOMAIN,
+ CLOUD_TRAIL_SNS_TOPIC_ARN,
+ DopplerEcsEnvironment,
+ getKafkaClusterPolicy,
+ stack,
+} from '../../packages/shared';
+
+const BASE_NAME = pulumi.getProject();
+const REPO_ROOT = '../../..';
+
+export const SERVICE_DOMAIN_NAME = `agent-harness${
+ stack === 'prod' ? '' : `-${stack}`
+}.${BASE_DOMAIN}`;
+
+type Args = {
+ vpc: {
+ vpcId: pulumi.Output<string> | string;
+ publicSubnetIds: pulumi.Output<string[]> | string[];
+ privateSubnetIds: pulumi.Output<string[]> | string[];
+ };
+ tags: { [key: string]: string };
+ containerEnvVars: { name: string; value: pulumi.Output<string> | string }[];
+ platform: { family: string; architecture: 'amd64' | 'arm64' };
+ serviceContainerPort: number;
+ healthCheckPath: string;
+ isPrivate?: boolean;
+ ecsClusterArn: pulumi.Output<string> | string;
+ cloudStorageClusterName: pulumi.Output<string> | string;
+ secretKeyArns: (pulumi.Output<string> | string)[];
+ sendQueueArns: pulumi.Output<string>[];
+};
+
+/**
+ * The agent harness service. Like agent-proxy before it, this component pins
+ * `desiredCount` to 1 and forces a stop-then-start deployment (min healthy
+ * 0%, max 100%) with no autoscaling: the harness owns the live agent-session
+ * actors in process memory with no cross-instance sync, and its Kafka
+ * consumer group must not split partitions across two momentarily-coexisting
+ * tasks (see `AgentHarnessConsumerGroup` in `services/agent_harness_service`).
+ */
+export class AgentHarnessService extends pulumi.ComponentResource {
+ public role: aws.iam.Role;
+ public ecr: awsx.ecr.Repository;
+ public serviceAlbSg: aws.ec2.SecurityGroup;
+ public serviceSg: aws.ec2.SecurityGroup;
+ public domain: string;
+ public targetGroup: aws.lb.TargetGroup;
+ public lb: aws.lb.LoadBalancer;
+ public listener: aws.lb.Listener;
+ public service: awsx.ecs.FargateService;
+ public cloudStorageClusterName: pulumi.Output<string> | string;
+ public tags: { [key: string]: string };
+
+ constructor(
+ name: string,
+ args: Args,
+ opts?: pulumi.ComponentResourceOptions
+ ) {
+ super('my:components:AgentHarnessService', name, {}, opts);
+ const {
+ vpc,
+ tags,
+ platform,
+ serviceContainerPort,
+ healthCheckPath,
+ isPrivate,
+ ecsClusterArn,
+ cloudStorageClusterName,
+ containerEnvVars,
+ secretKeyArns,
+ sendQueueArns,
+ } = args;
+
+ this.domain = `https://${SERVICE_DOMAIN_NAME}`;
+ this.cloudStorageClusterName = cloudStorageClusterName;
+ this.tags = tags;
+
+ const secretsManagerPolicy = new aws.iam.Policy(
+ `${BASE_NAME}-secrets-manager-policy`,
+ {
+ name: `${BASE_NAME}-secrets-manager-policy-${stack}`,
+ policy: {
+ Version: '2012-10-17',
+ Statement: [
+ {
+ Action: [
+ 'secretsmanager:GetSecretValue',
+ 'secretsmanager:DescribeSecret',
+ ],
+ Resource: secretKeyArns,
+ Effect: 'Allow',
+ },
+ ],
+ },
+ tags,
+ },
+ { parent: this }
+ );
+
+ // The harness fans channel side effects out over SQS (notification
+ // ingress and contacts) when it announces a session in a channel.
+ const queuePolicy = new aws.iam.Policy(
+ `${BASE_NAME}-queue-policy`,
+ {
+ name: `${BASE_NAME}-queue-policy-${stack}`,
+ policy: {
+ Version: '2012-10-17',
+ Statement: [
+ {
+ Action: [
+ 'sqs:SendMessage',
+ 'sqs:GetQueueUrl',
+ 'sqs:GetQueueAttributes',
+ ],
+ Resource: sendQueueArns,
+ Effect: 'Allow',
+ },
+ ],
+ },
+ tags,
+ },
+ { parent: this }
+ );
+
+ this.role = new aws.iam.Role(
+ `${BASE_NAME}-role`,
+ {
+ name: `${BASE_NAME}-role-${stack}`,
+ assumeRolePolicy: {
+ Version: '2012-10-17',
+ Statement: [
+ {
+ Action: 'sts:AssumeRole',
+ Principal: {
+ Service: 'ecs-tasks.amazonaws.com',
+ },
+ Effect: 'Allow',
+ },
+ ],
+ },
+ managedPolicyArns: [secretsManagerPolicy.arn, queuePolicy.arn],
+ tags,
+ },
+ { parent: this }
+ );
+
+ // Producer/consumer access to the macro event Kafka cluster: the harness
+ // consumes `macro.agent_sessions` and publishes channel side effects.
+ new aws.iam.RolePolicyAttachment(
+ `${BASE_NAME}-role-kafka-client-att-${stack}`,
+ {
+ role: this.role,
+ policyArn: getKafkaClusterPolicy(),
+ },
+ { parent: this, dependsOn: [this.role] }
+ );
+
+ const image = new EcrImage(
+ `${BASE_NAME}-ecr-image-${stack}`,
+ {
+ repositoryId: `${BASE_NAME}-ecr-${stack}`,
+ repositoryName: `${BASE_NAME}-${stack}`,
+ imageId: `${BASE_NAME}-image-${stack}`,
+ imagePath: REPO_ROOT,
+ dockerfile: 'docker/Dockerfile',
+ platform,
+ buildArgs: {
+ SERVICE_NAME: 'agent_harness_service',
+ },
+ tags,
+ },
+ { parent: this }
+ );
+ this.ecr = image.ecr;
+
+ const { serviceAlbSg, serviceSg } = this.initializeSecurityGroups({
+ vpcId: vpc.vpcId,
+ serviceContainerPort,
+ });
+ this.serviceAlbSg = serviceAlbSg;
+ this.serviceSg = serviceSg;
+
+ const { targetGroup, lb, listener } = serviceLoadBalancer(this, {
+ serviceName: BASE_NAME,
+ serviceContainerPort,
+ healthCheckPath,
+ vpc,
+ albSecurityGroupId: serviceAlbSg.id,
+ isPrivate,
+ tags,
+ });
+ this.targetGroup = targetGroup;
+ this.lb = lb;
+ this.listener = listener;
+
+ const dopplerEcsEnvironment = new DopplerEcsEnvironment(
+ BASE_NAME,
+ { tags: this.tags },
+ { parent: this }
+ );
+
+ this.service = new awsx.ecs.FargateService(
+ `${BASE_NAME}`,
+ {
+ tags,
+ cluster: ecsClusterArn,
+ networkConfiguration: {
+ subnets: vpc.privateSubnetIds,
+ securityGroups: [serviceSg.id],
+ },
+ continueBeforeSteadyState: DEFAULT_CONTINUE_BEFORE_STEADY_STATE,
+ deploymentCircuitBreaker: {
+ enable: true,
+ rollback: true,
+ },
+ // Never run 2 tasks at once, even transiently during a deploy: stop
+ // the old one before the new one starts (see the class doc comment).
+ deploymentMinimumHealthyPercent: 0,
+ deploymentMaximumPercent: 100,
+ desiredCount: 1,
+ taskDefinitionArgs: {
+ taskRole: {
+ roleArn: this.role.arn,
+ },
+ executionRole: {
+ roleArn: dopplerEcsEnvironment.executionRole.arn,
+ },
+ containers: {
+ log_router: fargateLogRouterSidecarContainer,
+ datadog_agent: datadogAgentContainer,
+ service: {
+ name: BASE_NAME,
+ image: image.image.imageUri,
+ stopTimeout: 10,
+ cpu: 1024,
+ memory: 2048,
+ environment: [
+ ...containerEnvVars,
+ {
+ name: 'BASE_URL',
+ value: this.domain,
+ },
+ ],
+ secrets: [...dopplerEcsEnvironment.containerSecrets],
+ logConfiguration: {
+ logDriver: 'awsfirelens',
+ options: {
+ Name: 'datadog',
+ Host: 'http-intake.logs.us5.datadoghq.com',
+ apikey: DATADOG_API_KEY,
+ dd_service: 'agent-harness-service',
+ dd_source: 'fargate',
+ dd_tags: `project:agent-harness-service, env:${stack}`,
+ provider: 'ecs',
+ },
+ },
+ portMappings: [
+ {
+ appProtocol: 'http',
+ name: `${BASE_NAME}-tcp-${stack}`,
+ hostPort: serviceContainerPort,
+ containerPort: serviceContainerPort,
+ targetGroup,
+ },
+ ],
+ },
+ },
+ runtimePlatform: {
+ operatingSystemFamily: platform.family.toUpperCase(),
+ cpuArchitecture:
+ platform.architecture === 'amd64'
+ ? 'X86_64'
+ : platform.architecture.toUpperCase(),
+ },
+ },
+ },
+ {
+ parent: this,
+ }
+ );
+
+ this.setupServiceAlarms();
+
+ const zone = aws.route53.getZoneOutput({ name: BASE_DOMAIN });
+ new aws.route53.Record(
+ `${BASE_NAME}-domain-record`,
+ {
+ name: SERVICE_DOMAIN_NAME,
+ type: 'A',
+ zoneId: zone.zoneId,
+ aliases: [
+ {
+ evaluateTargetHealth: false,
+ name: this.lb.dnsName,
+ zoneId: this.lb.zoneId,
+ },
+ ],
+ },
+ { parent: this }
+ );
+ }
+
+ private initializeSecurityGroups({
+ vpcId,
+ serviceContainerPort,
+ }: {
+ vpcId: pulumi.Output<string> | string;
+ serviceContainerPort: number;
+ }) {
+ const serviceAlbSg = new aws.ec2.SecurityGroup(
+ `${BASE_NAME}-alb-sg-${stack}`,
+ {
+ name: `${BASE_NAME}-alb-sg-${stack}`,
+ description: `${BASE_NAME} application load balancer security group`,
+ vpcId,
+ tags: this.tags,
+ },
+ { parent: this }
+ );
+
+ const serviceSg = new aws.ec2.SecurityGroup(
+ `${BASE_NAME}-sg-${stack}`,
+ {
+ name: `${BASE_NAME}-sg-${stack}`,
+ vpcId,
+ description: `${BASE_NAME} service security group`,
+ tags: this.tags,
+ },
+ { parent: this }
+ );
+
+ new aws.vpc.SecurityGroupIngressRule(
+ `${BASE_NAME}-alb-in`,
+ {
+ securityGroupId: serviceSg.id,
+ description: 'Allow inbound traffic from the service ALB',
+ referencedSecurityGroupId: serviceAlbSg.id,
+ fromPort: serviceContainerPort,
+ toPort: serviceContainerPort,
+ ipProtocol: 'tcp',
+ tags: this.tags,
+ },
+ { parent: this }
+ );
+
+ new aws.vpc.SecurityGroupEgressRule(
+ `${BASE_NAME}-service-out`,
+ {
+ securityGroupId: serviceSg.id,
+ description: 'Allow all outbound traffic',
+ cidrIpv4: '0.0.0.0/0',
+ ipProtocol: '-1',
+ tags: this.tags,
+ },
+ { parent: this }
+ );
+
+ new aws.vpc.SecurityGroupIngressRule(
+ `${BASE_NAME}-http`,
+ {
+ securityGroupId: serviceAlbSg.id,
+ description: 'Allow inbound HTTP traffic',
+ cidrIpv4: '0.0.0.0/0',
+ fromPort: 80,
+ toPort: 80,
+ ipProtocol: 'tcp',
+ tags: this.tags,
+ },
+ { parent: this }
+ );
+
+ new aws.vpc.SecurityGroupIngressRule(
+ `${BASE_NAME}-https`,
+ {
+ securityGroupId: serviceAlbSg.id,
+ description: 'Allow inbound HTTPS traffic',
+ cidrIpv4: '0.0.0.0/0',
+ fromPort: 443,
+ toPort: 443,
+ ipProtocol: 'tcp',
+ tags: this.tags,
+ },
+ { parent: this }
+ );
+
+ new aws.vpc.SecurityGroupEgressRule(
+ `${BASE_NAME}-alb-out`,
+ {
+ securityGroupId: serviceAlbSg.id,
+ description: 'Allow traffic to the service security group',
+ referencedSecurityGroupId: serviceSg.id,
+ fromPort: serviceContainerPort,
+ toPort: serviceContainerPort,
+ ipProtocol: 'tcp',
+ tags: this.tags,
+ },
+ { parent: this }
+ );
+
+ return { serviceAlbSg, serviceSg };
+ }
+
+ private setupServiceAlarms() {
+ new EcsDeploymentFailureAlarm(
+ `${BASE_NAME}-deployment-failure-alarm`,
+ {
+ serviceName: BASE_NAME,
+ serviceArn: this.service.service.arn,
+ tags: this.tags,
+ },
+ { parent: this }
+ );
+
+ new aws.cloudwatch.MetricAlarm(
+ `${BASE_NAME}-service-cpu-alarm`,
+ {
+ name: `${BASE_NAME}-service-cpu-${stack}`,
+ alarmDescription: `Alarm when ${BASE_NAME} CPU stays elevated (no autoscaling on this service - single replica only)`,
+ namespace: 'AWS/ECS',
+ metricName: 'CPUUtilization',
+ statistic: 'Average',
+ period: 300,
+ evaluationPeriods: 2,
+ threshold: 90,
+ comparisonOperator: 'GreaterThanOrEqualToThreshold',
+ dimensions: {
+ ClusterName: pulumi.interpolate`${this.cloudStorageClusterName}`,
+ ServiceName: this.service.service.name,
+ },
+ alarmActions: [CLOUD_TRAIL_SNS_TOPIC_ARN],
+ tags: this.tags,
+ },
+ { parent: this }
+ );
+ }
+}
diff --git a/infra/stacks/agent-harness-service/index.ts b/infra/stacks/agent-harness-service/index.ts
new file mode 100644
index 0000000000..f114163fee
--- /dev/null
+++ b/infra/stacks/agent-harness-service/index.ts
@@ -0,0 +1,88 @@
+import * as aws from '@pulumi/aws';
+import * as pulumi from '@pulumi/pulumi';
+import { getMacroApiToken, stack } from '../../packages/shared';
+import { get_coparse_api_vpc } from '../../packages/vpc';
+import { AgentHarnessService } from './agent_harness_service';
+
+const tags = {
+ environment: stack,
+ env: stack,
+ tech_lead: 'wolf',
+ project: 'agent-harness-service',
+ service: 'agent-harness-service',
+};
+
+// ── Secrets ──────────────────────────────────────────────────────────────────
+// Config (DATABASE_URL, DAYTONA_API_KEY, KAFKA_BROKERS, ...) arrives through
+// the Doppler-synced APP_SECRETS_JSON. Doppler's JWT_SECRET_KEY and
+// MACRO_API_TOKEN_PUBLIC_KEY hold Secrets Manager secret *names* that
+// `JwtValidationArgs::new_with_secret_manager` resolves at runtime
+// (crates/remote_env_var), so the task role needs read access to those two
+// secrets - the same code path as agent-schedule-service and
+// connection-gateway.
+
+const jwtSecretKeyArn = aws.secretsmanager
+ .getSecretVersionOutput({ secretId: `fusionauth-jwt-secret-${stack}` })
+ .apply((secret) => secret.arn);
+
+const MACRO_API_TOKENS = getMacroApiToken();
+
+// ── Stack references ─────────────────────────────────────────────────────────
+
+const cloudStorageStack = new pulumi.StackReference('cloud-storage-stack', {
+ name: `macro-inc/document-storage/${stack}`,
+});
+
+const cloudStorageClusterArn = cloudStorageStack
+ .getOutput('cloudStorageClusterArn')
+ .apply((value) => value as string);
+
+const cloudStorageClusterName = cloudStorageStack
+ .getOutput('cloudStorageClusterName')
+ .apply((value) => value as string);
+
+// ── Queues ───────────────────────────────────────────────────────────────────
+// Channel side effects fan out over these; names match `macro_queues`.
+
+const notificationIngressQueueArn = aws.sqs
+ .getQueueOutput({ name: `notification-ingress-queue-${stack}` })
+ .apply((queue) => queue.arn);
+
+const contactsQueueArn = aws.sqs
+ .getQueueOutput({ name: `contacts-queue-${stack}` })
+ .apply((queue) => queue.arn);
+
+// ── Service ──────────────────────────────────────────────────────────────────
+
+const vpc = get_coparse_api_vpc();
+
+const service = new AgentHarnessService(`agent-harness-service-${stack}`, {
+ vpc,
+ tags,
+ platform: { family: 'linux', architecture: 'amd64' },
+ serviceContainerPort: 8101,
+ healthCheckPath: '/health',
+ isPrivate: false,
+ ecsClusterArn: cloudStorageClusterArn,
+ cloudStorageClusterName,
+ secretKeyArns: [jwtSecretKeyArn, MACRO_API_TOKENS.macroApiTokenPublicKeyArn],
+ sendQueueArns: [notificationIngressQueueArn, contactsQueueArn],
+ containerEnvVars: [
+ {
+ name: 'ENVIRONMENT',
+ value: stack,
+ },
+ // Datadog
+ {
+ name: 'DD_SERVICE',
+ value: 'agent-harness-service',
+ },
+ {
+ name: 'DD_ENV',
+ value: stack,
+ },
+ ],
+});
+
+export const agentHarnessServiceUrl = pulumi.interpolate`${service.domain}`;
+export const agentHarnessServiceRoleArn = service.role.arn;
diff --git a/infra/stacks/agent-harness-service/package.json b/infra/stacks/agent-harness-service/package.json
new file mode 100644
index 0000000000..9b08cd6ef1
--- /dev/null
+++ b/infra/stacks/agent-harness-service/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "agent-harness-service-stack",
+ "version": "0.0.0",
+ "private": true,
+ "license": "MIT"
+}
diff --git a/infra/stacks/agent-harness-service/tsconfig.json b/infra/stacks/agent-harness-service/tsconfig.json
new file mode 100644
index 0000000000..4082f16a5d
--- /dev/null
+++ b/infra/stacks/agent-harness-service/tsconfig.json
@@ -0,0 +1,3 @@
+{
+ "extends": "../../tsconfig.json"
+}
diff --git a/infra/stacks/doppler-projects/index.ts b/infra/stacks/doppler-projects/index.ts
index a8c64f6134..38f0bbec1e 100644
--- a/infra/stacks/doppler-projects/index.ts
+++ b/infra/stacks/doppler-projects/index.ts
@@ -15,6 +15,7 @@ const SERVICE_NAMES = [
'mcp-server',
'email-service',
'document-cognition',
+ 'agent-harness-service',
];
for (const service_name of SERVICE_NAMES) {
diff --git a/nix/cloud-storage.nix b/nix/cloud-storage.nix
index 5705462638..35ac6f3f7c 100644
--- a/nix/cloud-storage.nix
+++ b/nix/cloud-storage.nix
@@ -337,6 +337,11 @@
);
deployServiceBinaryDefinitions = [
+ {
+ serviceName = "agent-harness-service";
+ packageName = "agent_harness_service";
+ binaries = [ "agent_harness_service" ];
+ }
{
serviceName = "agent-schedule-service";
packageName = "scheduled_action";